Skip to content

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