mirror of
https://github.com/RockChinQ/QChatGPT.git
synced 2024-11-15 19:22:24 +08:00
Merge pull request #889 from YunZLu/add-check-role
Fix: Add Role Check to Prevent Validation Error
This commit is contained in:
commit
47e308b99d
|
@ -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