Danswer assistant (#96)

Add helper!
This commit is contained in:
Chris Weaver
2023-06-11 17:54:41 -07:00
committed by GitHub
parent 2bfbf037ee
commit 8f5b9c0bcd
14 changed files with 468 additions and 193 deletions

View File

@@ -106,6 +106,9 @@ def json_chat_processor(question: str, documents: list[str]) -> list[dict[str, s
'Start by reading the following documents and responding with "Acknowledged".'
)
complete_answer_not_found_response = (
'{"answer": "' + UNCERTAINTY_PAT + '", "quotes": []}'
)
task_msg = (
"Now answer the next user query based on documents above and quote relevant sections.\n"
"Respond with a JSON containing the answer and up to three most relevant quotes from the documents.\n"
@@ -113,7 +116,7 @@ def json_chat_processor(question: str, documents: list[str]) -> list[dict[str, s
"Your responses should be informative and concise.\n"
"You MUST prioritize information from provided documents over internal knowledge.\n"
"If the query cannot be answered based on the documents, respond with "
'{"answer": "Information not found", "quotes": []}\n'
f"{complete_answer_not_found_response}\n"
"If the query requires aggregating whole documents, respond with "
'{"answer": "Aggregations not supported", "quotes": []}\n'
f"Sample response:\n{json.dumps(SAMPLE_JSON_RESPONSE)}"

View File

@@ -63,8 +63,8 @@ def extract_answer_quotes_freeform(
)
# If model just gives back the uncertainty pattern to signify answer isn't found or nothing at all
if null_answer_check == UNCERTAINTY_PAT or not null_answer_check:
return None, None
# if null_answer_check == UNCERTAINTY_PAT or not null_answer_check:
# return None, None
# If no answer section, don't care about the quote
if answer_raw.lower().strip().startswith(QUOTE_PAT.lower()):