Skip to content

Commit

Permalink
[ENH] Voyage Integration (#3404)
Browse files Browse the repository at this point in the history
Resolving merge conflicts for:
#3377

---------

Co-authored-by: fzowl <zoltan@voyageai.com>
Co-authored-by: fzowl <160063452+fzowl@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 6, 2025
1 parent d333745 commit 088e4cc
Show file tree
Hide file tree
Showing 7 changed files with 3,084 additions and 5,406 deletions.
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
)
]
6 changes: 5 additions & 1 deletion clients/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,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 @@ -81,6 +82,9 @@
},
"openai": {
"optional": true
},
"voyageai": {
"optional": true
}
}
}
Loading

0 comments on commit 088e4cc

Please sign in to comment.