-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
AsyncLM #2004
base: main
Are you sure you want to change the base?
AsyncLM #2004
Conversation
from dspy.utils import with_callbacks | ||
|
||
|
||
class AsyncLM(LM): |
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.
Perhaps add ABC and decorate?
|
||
class AsyncLM(LM): | ||
@with_callbacks | ||
def __call__(self, prompt=None, messages=None, **kwargs) -> Awaitable: |
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.
This should be async to allow for the caller to use this in an async fashion, no?
async def __call__(...)
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.
Yup, and callbacks should be handled async. Check out #1734 if you need something that works for you in the meantime
Hey @okhat, thanks for this repository its really super.
One step towards proper async functionality is having an
AsyncLM
, similar to how OpenAI has their Client and AsyncClient.I know this PR has some code duplication issues, however I think its better to have a separate async LM rather than handling both sync and async in the
LM
's__call__
.This PR complements #1988 and lays a foundation for async modules to use async lm client