64bit / async-openai

Rust library for OpenAI
https://docs.rs/async-openai
MIT License
1.09k stars 161 forks source link

Error when using assistant #234

Closed madchicken closed 2 months ago

madchicken commented 2 months ago

I am getting an error when trying to start a thread for an assistant:

Error: ApiError(ApiError { message: "Invalid type for 'parallel_tool_calls': expected a boolean, but got null instead.", type: Some("invalid_request_error"), param: Some("parallel_tool_calls"), code: Some("invalid_type") })

I think OpenAI changed something VERY recently, since yesterday this was not happening. The example under assistants is failing with the same error

64bit commented 2 months ago

Oh no, thats no good.

Thank you for reporting the issue.

From the error message you have provided, it seems that skipping serialization if parallel_tool_calls is None would prevent sending null to their API and fix it?

madchicken commented 2 months ago

The error happens when creating the thread:

        //create a thread for the conversation
        let thread_request = CreateThreadRequestArgs::default().build()?;
        let thread = client.threads().create(thread_request.clone()).await?;

but CreateThreadRequest does not have parallel_tool_calls property. I don't know if I an use something in the metadata hashmap...

madchicken commented 2 months ago

Please, disregard my previous message, the error is way below, when running the thread request:

        //create a run for the thread
        let run_request = CreateRunRequestArgs::default()
            .assistant_id(assistant_id)
            .build()?;

and I was able to fix it by doing what you said:

        //create a run for the thread
        let run_request = CreateRunRequestArgs::default()
            .assistant_id(assistant_id)
            .parallel_tool_calls(false)
            .build()?;
64bit commented 2 months ago

Thank you for the issue and PR, the fix is released in v0.23.3