Find answers from the community

Updated last year

Hey guys, I have this code, where I use

Hey guys, I have this code, where I use the chat engined I had started earlier based on the documentation here: https://docs.llamaindex.ai/en/stable/examples/docstore/MongoDocstoreDemo.html


It answers correctly using the storage_context, but when I restart my server, it answers but stops answering from the context. Only uses the system_prompt. I tried lots of stuff but still don't know what can be the issue that the storage_context doesn't full work after the restart. It seems to load index correctly.

def initialize_confluence_chat_engine(self, team_id):
try:
team_document = user_collection.find_one({'team_id': team_id})
if not team_document or 'confluence_index_id' not in team_document:
raise ValueError("Confluence settings have not been configured for this team.")
confluence_index_id = team_document['confluence_index_id']
storage_context = storage_context_manager.get_storage_context(team_id, mongo_uri, mongo_db_name)
confluence_space_index_from_storage = load_index_from_storage(storage_context, index_id=confluence_index_id)
space_names = team_document.get('space_names', '')

chat_engine = confluence_space_index_from_storage.as_chat_engine(
chat_mode="context",
service_context=service_context,
refine_template=DEFAULT_REFINE_PROMPT,
system_prompt=f"""Your name is Tiko. You're set up to assist with the Confluence spaces: {space_names}...""",
response_synthesizer=response_synthesizer,
similarity_top_k=5
)
return chat_engine
except Exception as e:
logging.error(f"An error occurred while initializing the Confluence chat engine: {e}")
traceback.print_exc()
L
T
3 comments
you can quickly test that the index is loading properly by running something like this

Plain Text
retriever = confluence_space_index_from_storage.as_retriever(similarity_top_k=5)
nodes = retriever.retrieve("query")
print(nodes)


If your index loaded correctly, then there should be 5 nodes retrieved
@Logan M Thanks for this! Indeed, it turns out that the index isn't loading properly, although I don't know why. I share some logs if it will help you, and ofc if you have time to look at them. Thanks! Appreciate the help!

LOGS:


INFO:root:Initializing Confluence data...

Storage CONTEXT 1:StorageContext(docstore=<llama_index.storage.docstore.mongo_docstore.MongoDocumentStore object at 0x13fc1eb90>, index_store=<llama_index.storage.index_store.mongo_index_store.MongoIndexStore object at 0x13fc0b710>, vector_stores={'default': <llama_index.vector_stores.simple.SimpleVectorStore object at 0x13fc09650>}, graph_store=<llama_index.graph_stores.simple.SimpleGraphStore object at 0x13fcabe90>)

INFO:httpx:HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 200 OK"

HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 200 OK"

Embedding Token Usage: 1274

INFO:root:Created Confluence Index ID: 590e74dd-47a0-43d3-89d9-3b306d3577a4

INFO:llama_index.indices.loading:Loading all indices.

Loading all indices.

INFO:httpx:HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 200 OK"

HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 200 OK"

Embedding Token Usage: 8

[SUCCESSFULLY RETRIEVED NODES]

INFO:root:initialize_confluence_data: Loaded Confluence Index ID from Storage: 590e74dd-47a0-43d3-89d9-3b306d3577a4

INFO:root:Confluence chat engine initialized successfully.
(FROM HERE IT DOESN'T RETRIEVE)

Confluence Index ID: 590e74dd-47a0-43d3-89d9-3b306d3577a4

Storage CONTEXT 2:StorageContext(docstore=<llama_index.storage.docstore.mongo_docstore.MongoDocumentStore object at 0x13d337ed0>, index_store=<llama_index.storage.index_store.mongo_index_store.MongoIndexStore object at 0x13fc09ad0>, vector_stores={'default': <llama_index.vector_stores.simple.SimpleVectorStore object at 0x13fc60950>}, graph_store=<llama_index.graph_stores.simple.SimpleGraphStore object at 0x105c5a710>)

INFO:llama_index.indices.loading:Loading all indices.

Loading all indices.

TEAM DOCUMENT INDEX ID: 590e74dd-47a0-43d3-89d9-3b306d3577a4

INFO:httpx:HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 200 OK"

HTTP Request: POST https://api.openai.com/v1/embeddings "HTTP/1.1 200 OK"

Embedding Token Usage: 8

[] #This is the empty retrieved nodes

INFO:root:(2) initialize_confluence_chat_engine: Loaded Confluence Index ID from Storage: 590e74dd-47a0-43d3-89d9-3b306d3577a4
Add a reply
Sign up and join the conversation on Discord