Skip to content
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

Add AsyncOpenAI and update OpenAILLM accordingly #381

Merged
merged 15 commits into from
Mar 5, 2024

Conversation

alvarobartt
Copy link
Member

@alvarobartt alvarobartt commented Mar 5, 2024

Description

This PR adds AsyncLLM adding a new abstract method to implement in its subclasses named agenerate that expects a single input instead of a list of inputs in order to be able to parallelize the requests to the async-compatible LLM subclasses i.e. OpenAILLM. Also the generate method is implemented within AsyncLLM so that the logic is handled already, meaning that only the async agenerate needs to be implemented for each subclass.

Besides that, this PR updates the OpenAILLM to use AsyncOpenAI instead of the synchronous OpenAI client.

Finally, some docstrings have been included to both AsyncLLM and OpenAILLM, as well as unit tests for OpenAILLM.

Closes #380

Update

Additionally, this PR also solves a bug with the field_validator of OpenAILLM.api_key, read more about it at https://docs.pydantic.dev/latest/concepts/validators/#validation-of-default-values. And this PR also fixes the GlobalStep since it was inheriting from _Step instead of Step, so it was breaking.

@alvarobartt alvarobartt added this to the 1.0.0 milestone Mar 5, 2024
@alvarobartt alvarobartt self-assigned this Mar 5, 2024
Needs to be placed within each test i.e. `Task`, `LLM`, ...instead of all of those combined within the same file, which was done initially as the first approach, but now needs to be properly done.
@alvarobartt alvarobartt linked an issue Mar 5, 2024 that may be closed by this pull request
@alvarobartt alvarobartt merged commit 8514a72 into core-refactor Mar 5, 2024
4 checks passed
@alvarobartt alvarobartt deleted the async-openai branch March 5, 2024 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add AsyncLLM and update OpenAILLM accordingly
3 participants