New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to Retrieve Chat Responses from Multiple Indexes. #13125
Comments
To address the challenge of fetching chat responses from multiple indexes simultaneously while maintaining accuracy and enhancing user experience, consider the following approach:
Here's a simplified example of how to implement concurrent fetching using an advanced chat engine: import asyncio
from llama_index.packs.cohere_citation_chat.citations_context_chat_engine import CitationsContextChatEngine
async def fetch_and_process_chat_responses(queries):
chat_engine = CitationsContextChatEngine() # Advanced engine for enriched responses
tasks = []
for query in queries:
task = asyncio.create_task(chat_engine.chat(query))
tasks.append(task)
responses = await asyncio.gather(*tasks)
for response in responses:
print(f"Chat Response with Citations and Documents: {response}")
# Process and aggregate responses as needed
# Example usage
queries = ['Query 1', 'Query 2', 'Query 3']
asyncio.run(fetch_and_process_chat_responses(queries)) This approach leverages asynchronous programming to concurrently fetch and process data from multiple sources, enriching the chat responses with citations and related documents. Depending on your specific needs, you may choose a different chat engine provided by LlamaIndex to better suit your application's requirements.
|
A few notes
Also in a server setting like this, I wouldn't be saving to/from disk. This can be pretty slow (and also blocks the async event loop). I would use a remote vector db like qdrant, weaviate, etc. |
Question Validation
Question
Hello everyone,
I'm currently encountering an issue while attempting to retrieve chat responses from multiple indexes in my project. Here's a brief overview of the situation:
Problem: Despite conducting thorough research, I haven't found a suitable solution for fetching chat responses from multiple indexes simultaneously.
Objective: My goal is to efficiently collect chat responses from various indexes within my application to enhance the user experience.
Below is a snippet of the code I'm currently using to handle chat requests and create indexes:
Initially, I attempted to combine multiple documents into a single index to address this challenge. However, this approach led to accuracy issues in the response. Refactoring is necessary to overcome this obstacle. Below is the code snippet illustrating the initial approach:
I'm seeking advice on how to improve this approach and handle multiple indexes effectively. Any insights or suggestions would be greatly appreciated.
Thank you.
The text was updated successfully, but these errors were encountered: