Skip to content

Commit

Permalink
Merge pull request #182 from Nitewriter/resolve-unknown-message-role-…
Browse files Browse the repository at this point in the history
…exception

Resolve unknown message role exceptions
  • Loading branch information
MadcowD authored Sep 19, 2024
2 parents 63d4de3 + 96de551 commit d9ee4ea
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ell/providers/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ def process_response(
)
)
)

# Determine the role for streaming responses, defaulting to 'assistant' if not provided
streamed_role = next((choice.delta.role for choice in choice_deltas if choice.delta.role), 'assistant')
else:
choice = choice_deltas[0].message
if choice.refusal:
Expand Down Expand Up @@ -229,7 +232,7 @@ def process_response(
role=(
choice.role
if not call_result.actual_streaming
else choice_deltas[0].delta.role
else streamed_role
),
content=content,
)
Expand Down

0 comments on commit d9ee4ea

Please sign in to comment.