Skip to content

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

Draft
johanste wants to merge 1 commit into
mainfrom
easyaz
Draft

Proof of concept on how to simplify using openai on azure#1
johanste wants to merge 1 commit into
mainfrom
easyaz

Conversation

@johanste

@johanste johanste commented Mar 6, 2023

Copy link
Copy Markdown
Owner

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)

Comment thread openai/easyaz.py

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

Copy link
Copy Markdown

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.

Comment thread openai/easyaz.py
openai.requestssession.set(session)


class AzHttpAdapter(HTTPAdapter):

Copy link
Copy Markdown

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