From dcb724f90206799b11bd7cf154caa6d3e4bb122a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20M=C3=BCller=20=28ChaoticByte=29?= Date: Mon, 13 Mar 2023 10:59:49 +0100 Subject: [PATCH] Strip trailing and leading newlines from Bing Chatbot answers --- chatgpt_pyapi/bing.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chatgpt_pyapi/bing.py b/chatgpt_pyapi/bing.py index bae39ee..94629fb 100644 --- a/chatgpt_pyapi/bing.py +++ b/chatgpt_pyapi/bing.py @@ -25,8 +25,9 @@ class Message: def from_api(cls, api_msg: dict): '''Create a Message object from API format''' assert type(api_msg) == dict + text = api_msg["item"]["messages"][1]["adaptiveCards"][0]["body"][0]["text"].strip("\n") return cls( - api_msg["item"]["messages"][1]["adaptiveCards"][0]["body"][0]["text"], + text, _role=_Roles.ASSISTANT) def to_api(self):