mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-17 16:39:52 +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
|
texts, engine=self.document_model_name, chunk_size=chunk_size
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
responses = [
|
results = []
|
||||||
self._embedding_func(text, engine=self.document_model_name)
|
for i in range(0, len(texts), chunk_size):
|
||||||
for text in texts
|
response = self.client.create(
|
||||||
]
|
input=texts[i : i + chunk_size], engine=self.document_model_name
|
||||||
return responses
|
)
|
||||||
|
results += [r["embedding"] for r in response["data"]]
|
||||||
|
return results
|
||||||
|
|
||||||
def embed_query(self, text: str) -> List[float]:
|
def embed_query(self, text: str) -> List[float]:
|
||||||
"""Call out to OpenAI's embedding endpoint for embedding query text.
|
"""Call out to OpenAI's embedding endpoint for embedding query text.
|
||||||
|
Loading…
Reference in New Issue
Block a user