mirror of
https://github.com/MadcowD/ell.git
synced 2024-09-22 16:14:36 +03:00
Resolve unknown message role exceptions
- updates OpenAI `process_response` to extract `role` with default
This commit is contained in:
@@ -182,6 +182,9 @@ try:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# 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:
|
else:
|
||||||
choice = choice_deltas[0].message
|
choice = choice_deltas[0].message
|
||||||
if choice.refusal:
|
if choice.refusal:
|
||||||
@@ -229,7 +232,7 @@ try:
|
|||||||
role=(
|
role=(
|
||||||
choice.role
|
choice.role
|
||||||
if not call_result.actual_streaming
|
if not call_result.actual_streaming
|
||||||
else choice_deltas[0].delta.role
|
else streamed_role
|
||||||
),
|
),
|
||||||
content=content,
|
content=content,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user