From 32da0a4d712fe1dbdc5791d5cb7af7cc697f8479 Mon Sep 17 00:00:00 2001 From: Devin Dahoon Kim Date: Sat, 2 Dec 2023 03:47:07 +0900 Subject: [PATCH] langchain[patch]: use async_embed_with_retry in _aget_len_safe_embeddings (#14110) **Description** `embed_with_retry` is for sync operations and not for async operations. Use `async_embed_with_retry` for appropriate async operations. I'm using `OpenAIEmbedding(http_client=httpx.AsyncClient())` with only async operations. However, I got an error when I use `embedding.aembed_documents` because `embed_with_retry` uses sync OpenAI client with async http client. --- libs/langchain/langchain/embeddings/openai.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/langchain/langchain/embeddings/openai.py b/libs/langchain/langchain/embeddings/openai.py index d10da4b4e97..c478b036d21 100644 --- a/libs/langchain/langchain/embeddings/openai.py +++ b/libs/langchain/langchain/embeddings/openai.py @@ -523,7 +523,7 @@ class OpenAIEmbeddings(BaseModel, Embeddings): for i in range(len(texts)): _result = results[i] if len(_result) == 0: - average_embedded = embed_with_retry( + average_embedded = await async_embed_with_retry( self, input="", **self._invocation_params,