Skip to content

Commit

Permalink
fix: pass api key to voyageai API
Browse files Browse the repository at this point in the history
  • Loading branch information
smoya committed Nov 30, 2024
1 parent c36c8de commit 5113516
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions projects/pgai/pgai/vectorizer/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ def _max_chunks_per_batch(self) -> int:
return 128

async def call_embed_api(self, documents: list[str]) -> EmbeddingResponse:
response = await voyageai.AsyncClient().embed(
response = await voyageai.AsyncClient(api_key=self._api_key).embed(
documents,
model=self.model,
input_type=self.input_type,
Expand Down Expand Up @@ -759,7 +759,7 @@ async def _filter_by_length_and_embed(
"""
valid_document_idxs: list[int] = []
invalid_documents_idxs: list[int] = []
tokenizer = voyageai.Client().tokenizer(self.model)
tokenizer = voyageai.Client(api_key=self._api_key).tokenizer(self.model)
tokenized_docs = tokenizer.encode_batch(documents)
for i, doc in enumerate(tokenized_docs):
if len(doc.tokens) > model_token_length:
Expand Down

0 comments on commit 5113516

Please sign in to comment.