-
Notifications
You must be signed in to change notification settings - Fork 15.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: interfaces for async embeddings, implement async openai #6111
Conversation
This change adds support to the base `Embeddings` class for two methods, `aembed_query` and `aembed_documents`, those two methods supporting async equivalents of `embed_query` and `embed_documents` respectively. This ever so slightly rounds out async support within langchain, with an initial implementation of this functionality being implemented for openai. Implements langchain-ai#6109
CC @hwchase17 @dev2049 for review. the |
Let me know if there is anything I can do to help push this along. I know you're all busy, but just want to make sure there isn't anything on my end holding this up. Also:
Thanks! |
@@ -53,6 +54,38 @@ def _create_retry_decorator(embeddings: OpenAIEmbeddings) -> Callable[[Any], Any | |||
) | |||
|
|||
|
|||
def _async_retry_decorator(embeddings: OpenAIEmbeddings) -> Any: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this is mirroring the sync decorator which is also taking embeddings as an argument (should be taking retry parameters not embeddings), but OK as it's mirroring existing functionality
Hi @tyree731 , code looks good -- let's remove the abstractmethod to reduce scope and avoid breaking changes and then code is good to merge. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Updated based on your comments. Let me know if there's anything I need to do for the vercel failure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can add these methods to the base class, but lets just do something like
async def aembed_documents(
self, texts: List[str], chunk_size: Optional[int] = 0
) -> List[List[float]]:
raise NotImplementedError
In the base class (rather than mark as abstract and have each subclass have to implement that)
Sorry for the delay in responding @hwchase17 , currently on vacation in Germany for the next couple of weeks, so I'll get to your comments when I get back. |
Since it seems like #6111 will be blocked for a bit, I've forked @tyree731's fork and implemented the requested changes. This change adds support to the base Embeddings class for two methods, aembed_query and aembed_documents, those two methods supporting async equivalents of embed_query and embed_documents respectively. This ever so slightly rounds out async support within langchain, with an initial implementation of this functionality being implemented for openai. Implements #6109 --------- Co-authored-by: Stephen Tyree <tyree731@gmail.com>
This change adds support to the base
Embeddings
class for two methods,aembed_query
andaembed_documents
, those two methods supporting async equivalents ofembed_query
andembed_documents
respectively. This ever so slightly rounds out async support within langchain, with an initial implementation of this functionality being implemented for openai.Implements #6109