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:
parent
4d7fddaf7e
commit
c547907193
|
@ -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 = ""
|
||||||
|
|
Loading…
Reference in New Issue