@@ -13,6 +13,7 @@ class OpenAITextVectorizer(BaseVectorizer):
1313 API key to be passed in the api_config dictionary. The API key can be obtained from
1414 https://api.openai.com/.
1515 """
16+
1617 def __init__ (self , model : str , api_config : Optional [Dict ] = None ):
1718 """Initialize the OpenAI vectorizer.
1819
@@ -45,14 +46,13 @@ def __init__(self, model: str, api_config: Optional[Dict] = None):
4546 def _set_model_dims (self ) -> int :
4647 try :
4748 embedding = self ._model_client .create (
48- input = ["dimension test" ],
49- engine = self ._model
49+ input = ["dimension test" ], engine = self ._model
5050 )["data" ][0 ]["embedding" ]
5151 except (KeyError , IndexError ) as ke :
5252 raise ValueError (f"Unexpected response from the OpenAI API: { str (ke )} " )
5353 except openai .error .AuthenticationError as ae :
5454 raise ValueError (f"Error authenticating with the OpenAI API: { str (ae )} " )
55- except Exception as e : # pylint: disable=broad-except
55+ except Exception as e : # pylint: disable=broad-except
5656 # fall back (TODO get more specific)
5757 raise ValueError (f"Error setting embedding model dimensions: { str (e )} " )
5858 return len (embedding )
@@ -87,9 +87,9 @@ def embed_many(
8787 TypeError: If the wrong input type is passed in for the test.
8888 """
8989 if not isinstance (texts , list ):
90- raise TypeError ("Must pass in a list of str values to embed." )
91- if len (texts ) > 0 and not isinstance (texts [0 ], str ):
92- raise TypeError ("Must pass in a list of str values to embed." )
90+ raise TypeError ("Must pass in a list of str values to embed." )
91+ if len (texts ) > 0 and not isinstance (texts [0 ], str ):
92+ raise TypeError ("Must pass in a list of str values to embed." )
9393
9494 embeddings : List = []
9595 for batch in self .batchify (texts , batch_size , preprocess ):
@@ -164,9 +164,9 @@ async def aembed_many(
164164 TypeError: If the wrong input type is passed in for the test.
165165 """
166166 if not isinstance (texts , list ):
167- raise TypeError ("Must pass in a list of str values to embed." )
168- if len (texts ) > 0 and not isinstance (texts [0 ], str ):
169- raise TypeError ("Must pass in a list of str values to embed." )
167+ raise TypeError ("Must pass in a list of str values to embed." )
168+ if len (texts ) > 0 and not isinstance (texts [0 ], str ):
169+ raise TypeError ("Must pass in a list of str values to embed." )
170170
171171 embeddings : List = []
172172 for batch in self .batchify (texts , batch_size , preprocess ):
0 commit comments