Strip trailing and leading newlines from Bing Chatbot answers

This commit is contained in:
Julian Müller (ChaoticByte) 2023-03-13 10:59:49 +01:00
parent e4f0e17347
commit dcb724f902

View file

@ -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):