Skip to content

Commit

Permalink
Merge pull request #264 from nulib/5205-context-for-testing
Browse files Browse the repository at this point in the history
Return source documents for context in chat sync for testing
  • Loading branch information
kdid authored Sep 9, 2024
2 parents 1222f95 + ecd692e commit d4b8bce
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 d4b8bce

Please sign in to comment.