Fix title_string is NoneType error

Some models return reasoning_content instead of content. In such a case, `title_string` ends None and further `find` method fails.
This commit is contained in:
xhejtman 2025-10-06 13:29:25 +02:00 committed by GitHub
parent 4d7fddaf7e
commit c547907193
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 6 deletions

View File

@ -1531,13 +1531,16 @@ async def process_chat_response(
) )
if res and isinstance(res, dict): if res and isinstance(res, dict):
if len(res.get("choices", [])) == 1: choices = res.get("choices", [])
if len(choices) == 1:
message_data = choices[0].get("message", {})
title_string = ( title_string = (
res.get("choices", [])[0] message_data.get("content")
.get("message", {}) or message_data.get("reasoning_content")
.get( or message.get("content")
"content", message.get("content", user_message) or message.get("reasoning_content")
) or user_message
or ""
) )
else: else:
title_string = "" title_string = ""