Skip to content

Proof of concept on how to simplify using openai on azure #1

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

johanste
Copy link
Owner

@johanste johanste commented Mar 6, 2023

Prototyping integrating azure credentials with the openai library. Many things need to be improved; caching of tokens being one, picking up "default" session settings from openai being another.

This also only covers the sync code path/requests.

Example usage:

import openai
import openai.easyaz

openai.easyaz.init('https://achand-openai-0.openai.azure.com/')

embedding = openai.Embedding.create(deployment_id='embed', input="Azure identity is easier to use for AOAI this way...")
print(embedding)


# Fill in a token
new_request = request.copy()
access_token = self.credential.get_token(*self.scopes) # TODO: sniff out claims from response

Choose a reason for hiding this comment

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

As we discussed, we need caching.

openai.requestssession.set(session)


class AzHttpAdapter(HTTPAdapter):

Choose a reason for hiding this comment

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

If we want to support more functionality (e.g. auxiliary header), do we want to extend the adapter? Or we want to make those stuff plug-ins so user can choose what they want?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants