-
-
Notifications
You must be signed in to change notification settings - Fork 636
Open
Labels
Non-OpenAI ModelNot an OpenAI Model.Not an OpenAI Model.
Description
When using using the Azure OpenAI API, if content filtering is kicked off an error is returned Undefined array key "content"
as there is no content parameter in the array within CreateResponseMessage.php
/**
* @param array{role: string, content: ?string, function_call: ?array{name: string, arguments: string}} $attributes
*/
public static function from(array $attributes): self
{
return new self(
$attributes['role'],
$attributes['content'],
isset($attributes['function_call']) ? CreateResponseFunctionCall::from($attributes['function_call']) : null,
);
}
The choices array looks something like this,
"choices": [
{
"index": 0,
"finish_reason": "content_filter",
"message": {
"role": "assistant"
},
"content_filter_results": {
"hate": {
"filtered": false,
"severity": "safe"
},
"self_harm": {
"filtered": false,
"severity": "safe"
},
"sexual": {
"filtered": true,
"severity": "medium"
},
"violence": {
"filtered": false,
"severity": "safe"
}
}
}
],
That example above has the "sexual" filter triggered, hence why there is no content back from the assistant.
It would be great if this lib handled the content filtering issues (e.g. threw an exception with a message etc)
Metadata
Metadata
Assignees
Labels
Non-OpenAI ModelNot an OpenAI Model.Not an OpenAI Model.