From 239c0bea15ae25669bd04259e9c57d3e9e95841f Mon Sep 17 00:00:00 2001 From: atthar2 <28339345+atthar2@users.noreply.github.com> Date: Mon, 6 Jan 2025 21:22:49 -0500 Subject: [PATCH] Update getting-started.md Add embeddingFunction parameter to getOrCreateCollection function --- .../content/docs/overview/getting-started.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/docs.trychroma.com/markdoc/content/docs/overview/getting-started.md b/docs/docs.trychroma.com/markdoc/content/docs/overview/getting-started.md index 1885977df38..81848b3f029 100644 --- a/docs/docs.trychroma.com/markdoc/content/docs/overview/getting-started.md +++ b/docs/docs.trychroma.com/markdoc/content/docs/overview/getting-started.md @@ -278,12 +278,25 @@ print(results) {% Tab label="typescript" %} ```typescript -import { ChromaClient } from "chromadb"; +import { ChromaClient, OpenAIEmbeddingFunction, OllamaEmbeddingFunction } from "chromadb"; + +// using OpenAI mmbedding +const embedder = new OpenAIEmbeddingFunction({ + openai_api_key: "your_api_key", +}); + +// using ollama embedding +const embedder = new OllamaEmbeddingFunction({ + url: "http://127.0.0.1:11434/api/embeddings", + model: "llama2" +}) + const client = new ChromaClient(); // switch `createCollection` to `getOrCreateCollection` to avoid creating a new collection every time const collection = await client.getOrCreateCollection({ name: "my_collection", + embeddingFunction: embedder, }); // switch `addRecords` to `upsertRecords` to avoid adding the same documents every time