Skip to content

feat: Implement document-aware chat API#223

Open
SaravanakumarR2018 wants to merge 1 commit into
mainfrom
feature/document-aware-chat
Open

feat: Implement document-aware chat API#223
SaravanakumarR2018 wants to merge 1 commit into
mainfrom
feature/document-aware-chat

Conversation

@SaravanakumarR2018
Copy link
Copy Markdown
Owner

Introduces document-aware responses into the Chat API by integrating retrieval augmented generation (RAG).

Key changes:

  • Modified LLMService.get_response to:
    1. Rewrite your query using the LLM based on conversation history to make it suitable for vector search.
    2. Search for relevant document chunks with the rewritten query.
    3. Inject the search results (as-is) and conversation history into a new prompt for the LLM.
    4. Instruct the LLM to use the provided documents if relevant, or answer from general knowledge (and state so if documents were not helpful).
  • Ensured that only your original query and the final assistant response are saved to the database, excluding intermediate data like rewritten queries or search results.
  • Added unit tests for LLMService.get_response in test/UnitTests/chat_service/test_llm_service.py covering various RAG scenarios. (Note: I wrote tests but didn't execute them due to temporary environment limitations regarding disk space for heavy dependencies like torch/sentence-transformers).

This enhancement allows the chat service to provide more contextual and accurate answers by leveraging a document knowledge base.

Introduces document-aware responses into the Chat API by integrating
retrieval augmented generation (RAG).

Key changes:
- Modified `LLMService.get_response` to:
  1. Rewrite your query using the LLM based on conversation
     history to make it suitable for vector search.
  2. Search for relevant document chunks with the rewritten query.
  3. Inject the search results (as-is) and conversation history
     into a new prompt for the LLM.
  4. Instruct the LLM to use the provided documents if relevant,
     or answer from general knowledge (and state so if documents
     were not helpful).
- Ensured that only your original query and the final assistant
  response are saved to the database, excluding intermediate data
  like rewritten queries or search results.
- Added unit tests for `LLMService.get_response` in
  `test/UnitTests/chat_service/test_llm_service.py` covering
  various RAG scenarios. (Note: I wrote tests but didn't execute them
  due to temporary environment limitations regarding disk space
  for heavy dependencies like torch/sentence-transformers).

This enhancement allows the chat service to provide more contextual
and accurate answers by leveraging a document knowledge base.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant