64bit / async-openai

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

CreateAssistantToolResources fields must be optional? #251

Closed vrurg closed 2 months ago

vrurg commented 3 months ago

I was working on code that creates an assistant with attached pre-existing vector store. Unfortunately, it doesn't seem to be possible. Since both fields are currently non-Option, the only possible way to create an instance is something like:

        let tool_resources = Some(CreateAssistantToolResources {
            file_search: Some(CreateAssistantToolFileSearchResources {
                vector_store_ids,
                vector_stores: vec![],
            }),
            code_interpreter: None,
        });

The point is that one has to specify both vector_store_ids and vector_stores. Unfortunately, the API doesn't accept this kind of request:

Can't create assistant '{aname}': ApiError(ApiError { message: "file_search tool configuration is invalid. Only one of vector_store_ids or vector_stores should be provided.", type: Some("invalid_request_error"), param: Some("tool_resources.file_search"), code: None })

From the error message I conclude that the right way is to make both fields optional.

Now I wonder how do I attach the vector store to a new assistant...