mirror of
https://github.com/placeholder-soft/chroma.git
synced 2026-01-12 17:02:54 +08:00
update client usage in example (#724)
## Description of changes *Summarize the changes made by this PR.* - Improvements & Bug fixes - changes the client usage in example
This commit is contained in:
@@ -5,27 +5,33 @@ window.onload = async () => {
|
||||
const chroma = new ChromaClient("http://localhost:8000");
|
||||
await chroma.reset();
|
||||
|
||||
const collection = await chroma.createCollection("test-from-js");
|
||||
const collection = await chroma.createCollection({
|
||||
name: "test-collection",
|
||||
});
|
||||
console.log("collection", collection);
|
||||
|
||||
// first generate some data
|
||||
var ids: string[] = [];
|
||||
var embeddings: Array<any> = [];
|
||||
var metadata: Array<any> = [];
|
||||
var metadatas: Array<any> = [];
|
||||
for (let i = 0; i < 100; i++) {
|
||||
ids.push("test-id-" + i.toString());
|
||||
embeddings.push([1, 2, 3, 4, 5]);
|
||||
metadata.push({ test: "test" });
|
||||
metadatas.push({ test: "test" });
|
||||
}
|
||||
|
||||
let add = await collection.add(ids, embeddings, metadata);
|
||||
let add = await collection.add({ ids, embeddings, metadatas });
|
||||
console.log("add", add);
|
||||
|
||||
let count = await collection.count();
|
||||
console.log("count", count);
|
||||
|
||||
const queryData = await collection.query([1, 2, 3, 4, 5], 5, {
|
||||
test: "test",
|
||||
const queryData = await collection.query({
|
||||
queryEmbeddings: [1, 2, 3, 4, 5],
|
||||
nResults: 5,
|
||||
whereDocument: {
|
||||
$contains: "test",
|
||||
},
|
||||
});
|
||||
|
||||
console.log("queryData", queryData);
|
||||
|
||||
Reference in New Issue
Block a user