From 8f920f478ff39ecfac9bc9ff61a7679d82da7af7 Mon Sep 17 00:00:00 2001 From: NovaOSS Admins Date: Tue, 7 Nov 2023 00:12:07 +0000 Subject: [PATCH] Handle TypeError in message content retrieval --- api/handler.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/handler.py b/api/handler.py index 8102e97..47b8fd5 100644 --- a/api/handler.py +++ b/api/handler.py @@ -118,7 +118,10 @@ async def handle(incoming_request: fastapi.Request): for message in payload.get('messages', []): if message.get('role') == 'user': - inp += message.get('content', '') + '\n' + try: + inp += message.get('content', '') + '\n' + except TypeError: + inp += message['content'][0]['text'] + '\n' if 'functions' in payload: inp += '\n'.join([function.get('description', '') for function in payload.get('functions', [])])