Skip to content

Commit

Permalink
Add Role Check to Prevent Validation Error
Browse files Browse the repository at this point in the history
  • Loading branch information
YunZLu committed Sep 23, 2024
1 parent 3c2db50 commit 81c2c3c
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 81c2c3c

Please sign in to comment.