mirror of
https://github.com/RockChinQ/QChatGPT.git
synced 2024-11-15 19:22:24 +08:00
Add Role Check to Prevent Validation Error
This commit is contained in:
parent
3c2db5097a
commit
81c2c3c0e5
|
@ -55,6 +55,10 @@ class OpenAIChatCompletions(api.LLMAPIRequester):
|
|||
) -> llm_entities.Message:
|
||||
chatcmpl_message = chat_completion.choices[0].message.dict()
|
||||
|
||||
# 确保 role 字段存在且不为 None
|
||||
if 'role' not in chatcmpl_message or chatcmpl_message['role'] is None:
|
||||
chatcmpl_message['role'] = 'assistant'
|
||||
|
||||
message = llm_entities.Message(**chatcmpl_message)
|
||||
|
||||
return message
|
||||
|
|
Loading…
Reference in New Issue
Block a user