@@ -47,9 +47,7 @@ class VoyageAITextVectorizer(BaseVectorizer):
47
47
_client : Any = PrivateAttr ()
48
48
_aclient : Any = PrivateAttr ()
49
49
50
- def __init__ (
51
- self , model : str , api_config : Optional [Dict ] = None
52
- ):
50
+ def __init__ (self , model : str , api_config : Optional [Dict ] = None ):
53
51
"""Initialize the VoyageAI vectorizer.
54
52
55
53
Visit https://docs.voyageai.com/docs/embeddings to learn about embeddings and check the available models.
@@ -144,10 +142,7 @@ def embed(
144
142
TypeError: In an invalid input_type is provided.
145
143
"""
146
144
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
151
146
)[0 ]
152
147
153
148
@retry (
@@ -202,7 +197,7 @@ def embed_many(
202
197
raise TypeError ("Must pass in a list of str values to embed." )
203
198
if len (texts ) > 0 and not isinstance (texts [0 ], str ):
204
199
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" ]:
206
201
raise TypeError (
207
202
"Must pass in a allowed value for voyageai embedding input_type. \
208
203
See https://docs.voyageai.com/docs/embeddings."
@@ -229,7 +224,7 @@ async def aembed_many(
229
224
self ,
230
225
texts : List [str ],
231
226
preprocess : Optional [Callable ] = None ,
232
- batch_size : int = None ,
227
+ batch_size : Optional [ int ] = None ,
233
228
as_buffer : bool = False ,
234
229
** kwargs ,
235
230
) -> List [List [float ]]:
@@ -272,7 +267,7 @@ async def aembed_many(
272
267
raise TypeError ("Must pass in a list of str values to embed." )
273
268
if len (texts ) > 0 and not isinstance (texts [0 ], str ):
274
269
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" ]:
276
271
raise TypeError (
277
272
"Must pass in a allowed value for voyageai embedding input_type. \
278
273
See https://docs.voyageai.com/docs/embeddings."
@@ -333,9 +328,6 @@ async def aembed(
333
328
"""
334
329
335
330
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
340
332
)
341
333
return result [0 ]
0 commit comments