Skip to content

Commit b876f70

Browse files
authored
Merge pull request #2 from voyage-ai/voyageai
VoyageAI vectorizer and reranker
2 parents 9524edc + 09efff5 commit b876f70

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

redisvl/utils/vectorize/text/voyageai.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ class VoyageAITextVectorizer(BaseVectorizer):
4747
_client: Any = PrivateAttr()
4848
_aclient: Any = PrivateAttr()
4949

50-
def __init__(
51-
self, model: str, api_config: Optional[Dict] = None
52-
):
50+
def __init__(self, model: str, api_config: Optional[Dict] = None):
5351
"""Initialize the VoyageAI vectorizer.
5452
5553
Visit https://docs.voyageai.com/docs/embeddings to learn about embeddings and check the available models.
@@ -144,10 +142,7 @@ def embed(
144142
TypeError: In an invalid input_type is provided.
145143
"""
146144
return self.embed_many(
147-
texts=[text],
148-
preprocess=preprocess,
149-
as_buffer=as_buffer,
150-
**kwargs
145+
texts=[text], preprocess=preprocess, as_buffer=as_buffer, **kwargs
151146
)[0]
152147

153148
@retry(
@@ -202,7 +197,7 @@ def embed_many(
202197
raise TypeError("Must pass in a list of str values to embed.")
203198
if len(texts) > 0 and not isinstance(texts[0], str):
204199
raise TypeError("Must pass in a list of str values to embed.")
205-
if input_type is not None and input_type not in ['document', 'query']:
200+
if input_type is not None and input_type not in ["document", "query"]:
206201
raise TypeError(
207202
"Must pass in a allowed value for voyageai embedding input_type. \
208203
See https://docs.voyageai.com/docs/embeddings."
@@ -229,7 +224,7 @@ async def aembed_many(
229224
self,
230225
texts: List[str],
231226
preprocess: Optional[Callable] = None,
232-
batch_size: int = None,
227+
batch_size: Optional[int] = None,
233228
as_buffer: bool = False,
234229
**kwargs,
235230
) -> List[List[float]]:
@@ -272,7 +267,7 @@ async def aembed_many(
272267
raise TypeError("Must pass in a list of str values to embed.")
273268
if len(texts) > 0 and not isinstance(texts[0], str):
274269
raise TypeError("Must pass in a list of str values to embed.")
275-
if input_type is not None and input_type not in ['document', 'query']:
270+
if input_type is not None and input_type not in ["document", "query"]:
276271
raise TypeError(
277272
"Must pass in a allowed value for voyageai embedding input_type. \
278273
See https://docs.voyageai.com/docs/embeddings."
@@ -333,9 +328,6 @@ async def aembed(
333328
"""
334329

335330
result = await self.aembed_many(
336-
texts=[text],
337-
preprocess=preprocess,
338-
as_buffer=as_buffer,
339-
**kwargs
331+
texts=[text], preprocess=preprocess, as_buffer=as_buffer, **kwargs
340332
)
341333
return result[0]

0 commit comments

Comments
 (0)