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

Bump up openai version to >=1.0 & use get_conn #36014

Merged
merged 3 commits into from
Dec 6, 2023

Conversation

pankajkoti
Copy link
Member


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@pankajkoti pankajkoti requested a review from Lee-W December 3, 2023 07:41
@pankajkoti pankajkoti added the use public runners Makes sure that Public runners are used even if commiters creates the PR (useful for testing) label Dec 3, 2023
@pankajkoti pankajkoti closed this Dec 3, 2023
@pankajkoti pankajkoti reopened this Dec 3, 2023
Comment on lines 72 to 78
return OpenAI(
api_key=password,
base_url=url,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Accepting those as extras kawrgs so that we don't have to keep updating the kwargs as the client changes across versions.

Updated the connections doc with an example for the same.

conn = self.get_connection(self.conn_id)
return conn.host
extras = conn.extra_dejson
openai_client_kwargs = extras.get("openai_client_kwargs", {})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means they have to do {"openai_client_kwargs":{"arg1":2,"arg2": ["2","6"], "arg3": '{"a":5}'} which I think is a lot. My preference is to have them list out the args without openai_client_kwargs. That's more popular in the hooks here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did consider the alternative of listing out the arguments directly. The reason for using the flexible nested dict openai_client_kwargs is mainly driven by the rapidly evolving nature of the OpenAI library. With each update, the client may introduce changes such as renaming existing arguments, adding new ones, or dropping some altogether. By encapsulating the arguments within a nested dict, our hook becomes less prone to immediate disruptions caused by such changes and avoids higher maintenance overhead as it offers adaptability to changes in the OpenAI library without requiring immediate updates on our end.

Since fields under extra already go in a dict and are not direct fields in the UI form, I don't think having another nested key opeai_client_kwargs would be a lot.
It's just that instead of
extra={"arg1":2,"arg2": ["2","6"], "arg3": '{"a":5}'},
it goes one level deep
extra={"openai_client_kwargs":{"arg1":2,"arg2": ["2","6"], "arg3": '{"a":5}'}}
and offers low maintenance.

@pankajkoti pankajkoti merged commit d2514b4 into apache:main Dec 6, 2023
@pankajkoti pankajkoti deleted the openai-get-conn branch December 6, 2023 10:27
potiuk pushed a commit that referenced this pull request Dec 15, 2023
@ephraimbuddy ephraimbuddy added type:misc/internal Changelog: Misc changes that should appear in change log changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) and removed type:misc/internal Changelog: Misc changes that should appear in change log labels Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) provider:openai use public runners Makes sure that Public runners are used even if commiters creates the PR (useful for testing)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants