| 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']) |