Anush008 / chromadb-rs

Rust client library for ChromaDB
https://www.trychroma.com/
MIT License
21 stars 3 forks source link

Is the example ok? #8

Open akmitrich opened 1 month ago

akmitrich commented 1 month ago

I'm in doubt. This code:

let client = chromadb::v1::ChromaClient::new(Default::default());
    let collection = client.get_or_create_collection("docs", None).unwrap();
    println!("Collection id: {:?}", collection.id());
    let collection_entries = chromadb::v1::collection::CollectionEntries {
        ids: vec!["demo-id-1", "demo-id-2"],
        embeddings: Some(vec![vec![0.0_f32; 768], vec![0.0_f32; 768]]),
        metadatas: None,
        documents: Some(vec![
            "Some document about 9 octopus recipies",
            "Some other document about DCEU Superman Vs CW Superman",
        ]),
    };

    let _result = collection.upsert(collection_entries, None).unwrap();

    let where_document = serde_json::json!({
       "$contains": "Superman"
    });

    let get_options = chromadb::v1::collection::GetOptions {
        ids: vec![],
        where_metadata: None,
        limit: Some(1),
        offset: None,
        where_document: Some(where_document),
        include: Some(vec!["documents".into(), "embeddings".into()]),
    };
    let result = collection.get(get_options).unwrap();

gets to the end successfully without any runtime errors but the result is perfectly empty:

GetResult { ids: [], metadatas: None, documents: Some([]), embeddings: Some([]) }

Is result supposed to be this? What did i do the wrong way?

Anush008 commented 1 month ago

Hi @akmitrich. I will take a look soon.