Skip to content

Commit

Permalink
Merge pull request #889 from YunZLu/add-check-role
Browse files Browse the repository at this point in the history
Fix: Add Role Check to Prevent Validation Error
  • Loading branch information
RockChinQ authored Sep 26, 2024
2 parents 3c2db50 + 81c2c3c commit 47e308b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/provider/modelmgr/apis/chatcmpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ async def _make_msg(
) -> 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
Expand Down

0 comments on commit 47e308b

Please sign in to comment.