mirror of
https://github.com/hwchase17/langchain
synced 2024-11-08 07:10:35 +00:00
https://github.com/hwchase17/langchain/issues/1100 When faiss data and doc.index are created in past versions, error occurs that say there was no attribute. So I put hasattr in the check as a simple solution. However, increasing the number of such checks is not good for conservatism, so I think there is a better solution. Also, the code for the batch process was left out, so I put it back in.
This commit is contained in:
parent
3f50feb280
commit
383c67c1b2
@ -147,11 +147,13 @@ class OpenAIEmbeddings(BaseModel, Embeddings):
|
||||
texts, engine=self.document_model_name, chunk_size=chunk_size
|
||||
)
|
||||
else:
|
||||
responses = [
|
||||
self._embedding_func(text, engine=self.document_model_name)
|
||||
for text in texts
|
||||
]
|
||||
return responses
|
||||
results = []
|
||||
for i in range(0, len(texts), chunk_size):
|
||||
response = self.client.create(
|
||||
input=texts[i : i + chunk_size], engine=self.document_model_name
|
||||
)
|
||||
results += [r["embedding"] for r in response["data"]]
|
||||
return results
|
||||
|
||||
def embed_query(self, text: str) -> List[float]:
|
||||
"""Call out to OpenAI's embedding endpoint for embedding query text.
|
||||
|
Loading…
Reference in New Issue
Block a user