-
Notifications
You must be signed in to change notification settings - Fork 23
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) allow setting base url for openai v1.0.0+ #32
base: main
Are you sure you want to change the base?
Conversation
py/autoevals/oai.py
Outdated
@@ -55,13 +55,14 @@ def prepare_openai_complete(is_async=False, api_key=None): | |||
|
|||
openai_obj = openai | |||
is_v1 = False | |||
base_url = os.environ.get("OPENAI_API_BASE", "https://api.openai.com/v1") |
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.
defaults to https://api.openai.com/v1
if none specified
can i get a review on this @ankrgyl |
If I'm researching correctly, |
updated this to pass |
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.
Can you add in JS too?
@@ -35,7 +35,8 @@ def open_cache(): | |||
CACHE_LOCK = threading.Lock() | |||
|
|||
|
|||
def prepare_openai_complete(is_async=False, api_key=None): | |||
def prepare_openai_complete(is_async=False, api_key=None, base_url="https://api.openai.com/v1"): |
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.
would rather not hardcode the API url here -- e.g. someone may monkey patch the library to override the default, and this would override that. Is there any issue with passing None
into the OpenAI
object by default?
@ishaan-jaff I think #33 supersedes this change (it allows you to optionally override the base url and supports JS). Feel free to take a look, and happy to either rebase/scope this PR or just close it out. |
this allows users to specify a custom
openai api base
I tried
export OPENAI_API_BASE
but it looks like the latest version of openai does not read the base url from the .env