Vector Stores
ChromaDB
Chroma gives you the tools to store embeddings and their metadata.
Chroma is a AI-native open-source vector database focused on developer productivity and happiness. Chroma is licensed under Apache 2.0.
Setup
- Install Langtrace’s SDK and initialize the SDK in your code.
Install Chroma with:
Usage
Here’s a quick example of how to use Langtrace with LlamaIndex:
Typescript SDK
import * as Langtrace from "@langtrase/typescript-sdk";
import { ChromaClient, OpenAIEmbeddingFunction } from "chromadb";
Langtrace.init({ write_spans_to_console: true });
export async function run(): Promise<void> {
await Langtrace.withLangTraceRootSpan(async () => {
const client = new ChromaClient();
const embedder = new OpenAIEmbeddingFunction({
openai_api_key: process.env.OPENAI_API_KEY as string,
});
console.info("Creating collection");
const collection = await client.getOrCreateCollection({
name: "test_collection",
embeddingFunction: embedder,
});
console.info("Adding documents");
await collection.add({
ids: ["id1", "id2"],
metadatas: [{ source: "my_source" }, { source: "my_source" }],
documents: ["This is a document", "This is another document"],
});
console.info("Querying documents");
const results = await collection.query({
nResults: 2,
queryTexts: ["This is a query document"],
});
console.info(results);
});
}
void run().then(() => console.log("done"));
That’s it! ✨ 🧙♂️ Enjoy debugging your Chroma applications using Langtrace.