diff --git a/chat/src/handlers/chat_sync.py b/chat/src/handlers/chat_sync.py index dd3d88c..cb679f5 100644 --- a/chat/src/handlers/chat_sync.py +++ b/chat/src/handlers/chat_sync.py @@ -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"] } diff --git a/chat/src/helpers/http_response.py b/chat/src/helpers/http_response.py index fc6abc6..11ba296 100644 --- a/chat/src/helpers/http_response.py +++ b/chat/src/helpers/http_response.py @@ -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, @@ -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,