Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOC] New functionality: Adding VoyageAI text embedding integration #3377

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions chromadb/test/ef/test_ef.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def test_get_builtins_holds() -> None:
expected_builtins = {
"AmazonBedrockEmbeddingFunction",
"CohereEmbeddingFunction",
"VoyageAIEmbeddingFunction",
"GoogleGenerativeAiEmbeddingFunction",
"GooglePalmEmbeddingFunction",
"GoogleVertexEmbeddingFunction",
Expand Down
27 changes: 27 additions & 0 deletions chromadb/utils/embedding_functions/voyageai_embedding_function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import logging

from chromadb.api.types import Documents, EmbeddingFunction, Embeddings

logger = logging.getLogger(__name__)


class VoyageAIEmbeddingFunction(EmbeddingFunction[Documents]):
def __init__(self, api_key: str, model_name: str):
try:
import voyageai
except ImportError:
raise ValueError(
"The voyageai python package is not installed. Please install it with `pip install voyageai`"
)

self._client = voyageai.Client(api_key=api_key)
self._model_name = model_name

def __call__(self, input: Documents) -> Embeddings:
# Call Cohere Embedding API for each document.
return [
embeddings
for embeddings in self._client.embed(
texts=input, model=self._model_name
)
]
8 changes: 6 additions & 2 deletions clients/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"@jest/globals": "^29.7.0",
"@jest/types": "^29.6.3",
"@openapi-generator-plus/typescript-fetch-client-generator": "^1.5.0",
"@types/bcrypt": "^5.0.2",
"@types/jest": "^29.5.0",
"@types/node": "^20.8.10",
"@types/bcrypt": "^5.0.2",
"bcrypt": "^5.1.1",
"jest": "^29.5.0",
"npm-run-all": "^4.1.5",
Expand Down Expand Up @@ -69,7 +69,8 @@
"peerDependencies": {
"@google/generative-ai": "^0.1.1",
"cohere-ai": "^5.0.0 || ^6.0.0 || ^7.0.0",
"openai": "^3.0.0 || ^4.0.0"
"openai": "^3.0.0 || ^4.0.0",
"voyageai": "^0.0.3-1"
},
"peerDependenciesMeta": {
"@google/generative-ai": {
Expand All @@ -80,6 +81,9 @@
},
"openai": {
"optional": true
},
"voyageai": {
"optional": true
}
}
}
Loading