-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
d333745
commit 088e4cc
Showing
7 changed files
with
3,084 additions
and
5,406 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
chromadb/utils/embedding_functions/voyageai_embedding_function.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.