Skip to content

Commit

Permalink
Merge pull request #3 from voyage-ai/voyage_2_model
Browse files Browse the repository at this point in the history
community: model attribute is required, set default batch size
  • Loading branch information
thomas0809 authored Feb 16, 2024
2 parents 1113700 + 4de3553 commit 6e53bf9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/docs/integrations/text_embedding/voyageai.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"id": "137cfde9-b88c-409a-9394-a9e31a6bf30d",
"metadata": {},
"source": [
"Voyage AI utilizes API keys to monitor usage and manage permissions. To obtain your key, create an account on our [homepage](https://www.voyageai.com). Then, create a VoyageEmbeddings model with your API key."
"Voyage AI utilizes API keys to monitor usage and manage permissions. To obtain your key, create an account on our [homepage](https://www.voyageai.com). Then, create a VoyageEmbeddings model with your API key. Please refer to the documentation for further details on the available models: https://docs.voyageai.com/embeddings/"
]
},
{
Expand All @@ -37,7 +37,7 @@
"metadata": {},
"outputs": [],
"source": [
"embeddings = VoyageEmbeddings(voyage_api_key=\"[ Your Voyage API key ]\")"
"embeddings = VoyageEmbeddings(voyage_api_key=\"[ Your Voyage API key ]\", model=\"voyage-2\")"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions libs/community/langchain_community/embeddings/voyageai.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ class VoyageEmbeddings(BaseModel, Embeddings):
from langchain_community.embeddings import VoyageEmbeddings
voyage = VoyageEmbeddings(voyage_api_key="your-api-key")
voyage = VoyageEmbeddings(voyage_api_key="your-api-key", model="voyage-2")
text = "This is a test query."
query_result = voyage.embed_query(text)
"""

model: str = "voyage-01"
model: str
voyage_api_base: str = "https://api.voyageai.com/v1/embeddings"
voyage_api_key: Optional[SecretStr] = None
batch_size: int = 8
batch_size: Optional[int] = None
"""Maximum number of texts to embed in each API request."""
max_retries: int = 6
"""Maximum number of retries to make when generating."""
Expand Down Expand Up @@ -121,7 +121,7 @@ def _get_embeddings(
embeddings: List[List[float]] = []

if batch_size is None:
batch_size = self.batch_size
batch_size = 72 if self.model in ["voyage-2", "voyage-02"] else 7

if self.show_progress_bar:
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from langchain_community.embeddings.voyageai import VoyageEmbeddings

# Please set VOYAGE_API_KEY in the environment variables
MODEL = "voyage-01"
MODEL = "voyage-2"


def test_voyagi_embedding_documents() -> None:
Expand Down

0 comments on commit 6e53bf9

Please sign in to comment.