From c91254c9d35a5aebbf7608fc62d7ea9b3e19e908 Mon Sep 17 00:00:00 2001 From: Sarah Widder Date: Wed, 24 May 2023 18:17:16 -0700 Subject: [PATCH] update without data api --- app.py | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/app.py b/app.py index b0c79f70fc..9164764ea3 100644 --- a/app.py +++ b/app.py @@ -92,8 +92,8 @@ def prepare_body_headers_without_data(request): for message in request_messages: body_messages.append({ - "role": "assistant" if message["role"] == "bot" else "user", - "content": message["content"]["parts"][0] + "role": message["role"] , + "content": message["content"] }) body = { @@ -138,19 +138,10 @@ def conversation(): if not use_data and status_code == 200: # convert to the same format as the data version - r = { - "message_id": r["id"], - "parent_message_id": "", - "role": "bot", - "content": { - "content_type": "text", - "parts": [ - r["choices"][0]["message"]["content"] - ], - "top_docs": [], - "intent": "" - }, - } + r["choices"][0]["messages"] = [{ + "content": r["choices"][0]["message"]["content"], + "role": "assistant" + }] return jsonify(r), status_code except Exception as e: