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

Modify the openai model to conform to the new openai sdk v1.0.0 #364

Merged
merged 2 commits into from
Nov 15, 2023

Conversation

RobinPicard
Copy link
Contributor

This PR aims at solving this issue: #361

The new Python sdk of Openai allows us to instantiate a client that we can then use for API calls. I thought it would make sense to put the instantiation of the client (and the import of the openai library) in the __init__ of the OpenAIAPI class.

An issue I ran into was that the functions call_chat_completion_api and call_completion_api would then receive the client as an argument which would cause problems with the cache decorator. I'm not sure what's the best way to handle that. I created two intermediary functions cached_call_completion_api and cached_call_chat_completion_api in the __init__ of the OpenAIAPI class as it looked like the solution that required the fewest modifications to the existing logic.

The new sdk handles the retry logic itself so I removed the retry decorator (and added a max_retries argument to OpenAIAPI instead)

@rlouf
Copy link
Member

rlouf commented Nov 15, 2023

This works locally, thank you so much for this great contribution!

@rlouf rlouf merged commit 07bd334 into outlines-dev:main Nov 15, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants