Handle TypeError in message content retrieval

This commit is contained in:
NovaOSS Admins 2023-11-07 00:12:07 +00:00
parent b79ebc05b8
commit 8f920f478f

View file

@ -118,7 +118,10 @@ async def handle(incoming_request: fastapi.Request):
for message in payload.get('messages', []): for message in payload.get('messages', []):
if message.get('role') == 'user': 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: if 'functions' in payload:
inp += '\n'.join([function.get('description', '') for function in payload.get('functions', [])]) inp += '\n'.join([function.get('description', '') for function in payload.get('functions', [])])