File size: 765 Bytes
13fbd2e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from llama_index.core import load_index_from_storage
from llama_index.core import StorageContext
from llama_index.llms.ollama import Ollama
from langchain_community.embeddings import OllamaEmbeddings
from llama_index.core import Settings

# load index from storage


llm = Ollama(model="llama3", request_timeout=120, base_url="http://localhost:11434")
embed_model = OllamaEmbeddings(model="llama3")
Settings.llm = llm
Settings.embed_model = embed_model

storage_context = StorageContext.from_defaults(persist_dir="../kb/index")
index = load_index_from_storage(storage_context)


query_engine = index.as_query_engine(response_mode="tree_summarize")
# response = query_engine.query("What's the process of reasoning?")


print(index._index_struct.to_dict()['summary'])