Skip to content
Snippets Groups Projects
Commit 335e8b3f authored by Andréas Livet's avatar Andréas Livet
Browse files

chat : adapt to the new sofia chat format and handle empty docs

parent 457d3e30
No related branches found
No related tags found
No related merge requests found
...@@ -80,7 +80,9 @@ async def transform_sofia_chat_response( ...@@ -80,7 +80,9 @@ async def transform_sofia_chat_response(
async for line in sofia_chat_response: async for line in sofia_chat_response:
# Response is in json # Response is in json
res = json.loads(line) res = json.loads(line)
content_list, document_list_str, rephrased_query, year_list = res content_list = res["history"]
document_list_str = res["docs_html"]
rephrased_query = res["output_query"]
document_list = json.loads(document_list_str) document_list = json.loads(document_list_str)
if rephrased_query and not has_send_rephrased_query: if rephrased_query and not has_send_rephrased_query:
has_send_rephrased_query = True has_send_rephrased_query = True
...@@ -90,7 +92,11 @@ async def transform_sofia_chat_response( ...@@ -90,7 +92,11 @@ async def transform_sofia_chat_response(
"query": rephrased_query, "query": rephrased_query,
}, },
})}$$$\n""" })}$$$\n"""
if len(document_list) > 0 and not has_send_documents: # If there is no relevant document, document_list will be : ['No document to show.']
if len(document_list) == 1 and type(document_list[0]) is str:
has_send_documents = True
viewer_sources = []
elif len(document_list) > 0 and not has_send_documents:
viewer_sources = [ viewer_sources = [
{ {
"id": doc["document_id"] "id": doc["document_id"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment