neferdata / allms

allms: One Rust Library to rule them aLLMs
https://crates.io/crates/allms
Other
44 stars 5 forks source link

Vector Store support #25

Closed kamillitman closed 5 months ago

kamillitman commented 5 months ago

This PR introduces support for OpenAI Vector Store with Assistant struct.

Main changes:

Example usage:

// You still need to first upload a file
let openai_file = OpenAIFile::new(&file_name, bytes, &api_key, true).await?;

// Create a Vector Store and assign the file to it
    let openai_vector_store = OpenAIVectorStore::new(None, "Concerts", &api_key)
        .debug()
        .upload(&[openai_file.id.clone()])
        .await?;

// Attach Vectore Store to an Assistant and use it for search
    let concert_info = OpenAIAssistant::new(OpenAIModels::Gpt4o, &api_key, true)
        .await?
        .version(OpenAIAssistantVersion::V2)
        .vector_store(openai_vector_store.clone())
        .await?
        .get_answer::<ConcertInfo>(
            "Extract the information requested in the response type from the attached concert information.
            The response should include the genre of the music the 'band' represents.
            The mapping of bands to genres was provided in 'bands_genres' list in a previous message.",
            &[], // No files attached to the message. Assistant will use the Vector Store
        )
        .await?;

    // Delete the Vector Store
    openai_vector_store.delete().await?;