Skip to content

Commit

Permalink
Return source documents for context in chat sync for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
kdid committed Sep 9, 2024
1 parent 1222f95 commit ecd692e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions chat/src/handlers/chat_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
logging.getLogger('honeybadger').addHandler(logging.StreamHandler())

RESPONSE_TYPES = {
"base": ["answer", "ref"],
"debug": ["answer", "attributes", "azure_endpoint", "deployment_name", "is_superuser", "k", "openai_api_version", "prompt", "question", "ref", "temperature", "text_key", "token_counts"],
"base": ["answer", "ref", "context"],
"debug": ["answer", "attributes", "azure_endpoint", "deployment_name", "is_superuser", "k", "openai_api_version", "prompt", "question", "ref", "temperature", "text_key", "token_counts", "context"],
"log": ["answer", "deployment_name", "is_superuser", "k", "openai_api_version", "prompt", "question", "ref", "size", "source_documents", "temperature", "token_counts"],
"error": ["question", "error", "source_documents"]
}
Expand Down
3 changes: 3 additions & 0 deletions chat/src/helpers/http_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def get_and_send_original_question(docs):
source_document["content"] = doc.page_content
source_documents.append(source_document)

self.context = source_documents

original_question = {
"question": self.config.question,
"source_documents": source_documents,
Expand All @@ -49,6 +51,7 @@ def prepare_response(self):
| self.debug_response_passthrough()
)
response = chain.invoke(self.config.question)
response["context"] = self.context
except Exception as err:
response = {
"question": self.config.question,
Expand Down

0 comments on commit ecd692e

Please sign in to comment.