async-openai
async-openai copied to clipboard
Responses API streaming response.function_call_arguments.done event missing function name
Current version: async-openai = "0.31.0-alpha.6"
I am trying out function calling with the responses API and the library throws this error:
Caused by:
failed to deserialize api response: error:missing field `name` content:{"type":"response.function_call_arguments.done","sequence_number":540,"item_id":"fc_0406f266c8104f0a0069149fe6cdd0819b8d61947a29216e55","output_index":1,"arguments":"{\"language\":\"English\"}"}
This looks very similar to the issue in the Python library. According to fix PR, The raw event from the API doesn't include the name field - it must be taken from the accumulated snapshot. That's a bit odd as this conflicts with OpenAI event spec.
I guess we should make name optional until OpenAI fixes this on their end?
Thats a bummer, lets wait for openai to fix the bug? if it lasts longer we can make it optional?
(or alternative in such cases in byot feature)
Its a shame that I can't use the types because of this issue.
Using create_stream_byot with the following event worked for me
"response.output_item.done" => {
let item_json = event_json["item"].clone();
if let Some("function_call") = item_json["type"].as_str() {
if let (Some(name), Some(call_id), Some(arguments)) = (
item_json["name"].as_str(),
item_json["call_id"].as_str(),
item_json["arguments"].as_str(),
) {
// do something
}
}
}
Its not ideal - but to make the types useful - making Optional for now makes sense. PR is welcome!