-
Notifications
You must be signed in to change notification settings - Fork 779
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
[Azure] Introduce AzureOpenAI client #718
Conversation
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.
@athyuttamre @kristapratico WDYT?
Thank you for putting this up @deyaaeldeen ! We're discussing internally as well. |
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.
Looks good :)
@rattrayalex I need your help in exporting the Azure client. The |
We'll take a look at that soon @deyaaeldeen. It may have to wait til next week. |
@rattrayalex Thanks for taking a look! I wonder if there is anything that I can clarify or help with to move this forward? |
thanks for the bump, this slipped through the cracks. I've poked internally. |
Hi! I will take a look and test on my side, but in the interim can you elaborate on the change you are proposing regarding the modules design? (for instance, what are the tradeoffs and alternatives?) |
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.
Is it possible to leave index.ts
largely untouched, instead of moving code into openai.ts
?
@rattrayalex done. Could you please take another look? hopefully we can merge it ASAP 😊 |
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.
Thanks for the iteration here! I think its moving in a good direction. Just a few comments from a quick skim, but we need to discuss internally a bit on Monday.
Hopefully @RobertCraigie can provide a more thorough review soon.
src/lib/azure/azure.ts
Outdated
apiVersion = Core.readEnv('OPENAI_API_VERSION'), | ||
endpoint, | ||
deployment, | ||
microsoftEntraTokenProvider, |
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.
In the Python client, do we use the term Entra
?
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.
No, but it is a recent rebrand: https://www.microsoft.com/security/business/identity-access/microsoft-entra-id
Hey we've moved the |
this subtly broke some setups that we didn't have tests for
@RobertCraigie Awesome! I updated the client in 780ddbb. |
Unfortunately we just had to revert the I tried putting the azure exports at the bottom of the what would you think about this being the main import? import { AzureOpenAI } from 'openai/azure'; Note that we tried a bunch of different ways of structuring the separate |
Actually, you could define the azure client class at the bottom of the |
@RobertCraigie Thanks for the feedback! I updated the PR accordingly. |
d0e806e
to
074b330
Compare
src/index.ts
Outdated
/** | ||
* A function that returns a Microsoft Entra (formerly known as Azure Active Directory) access token, will be invoked on every request. | ||
*/ | ||
microsoftEntraTokenProvider?: (() => string) | undefined; |
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.
is not supporting the equivalent azure_ad_token
as well like in the Python client an intentional mismatch? (I haven't read all the context)
in other words, would people be suprised they can't set the AZURE_OPENAI_AD_TOKEN
environment variable and have it picked up here?
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.
@deyaaeldeen in addition to Robert's comments, in the Python client I believe we call this azure_ad
not microsoft_entra
– is that correct? Can we keep the naming consistent and call it Azure Active Directory instead?
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.
is not supporting the equivalent azure_ad_token as well like in the Python client an intentional mismatch?
Yes, I would like our customers to use the token provider first because it takes care of token refreshing. I can add azureAdToken
in the future if it turns out to be needed.
Can we keep the naming consistent and call it Azure Active Directory instead?
Ok I made the update in 670165f and we can plan the switch to the Entra name in the next major version.
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.
Code changes look good to me. We'll also want to update the README.md docs.
Let me know when the docs have been updated & I'll port these changes over to our side before merging.
tests/azure.test.ts
Outdated
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.
nit: would be ideal for this to be in tests/lib/azure.test.ts
, these are good tests though :)
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.
I moved it in 670165f.
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.
Thanks for your patience here!
Few things outstanding:
- Entra -> AD, as noted elsewhere
- Need to update the Azure section of the README (or add one, similar to Python)
Ah sorry, @deyaaeldeen my mistake – we actually don't need the README updated, we've done that part on our end. Just the Entra -> Azure AD change would be great. |
## Linked issues closes: #1497 (issue number) ## Details **BREAKING CHANGE** * Updated AssistantPlanner to use `@azure/openai-assistants` as the underlying client. This supports both OpenAI and Azure OpenAI assistants v1 endpoints. * Updated math bot to use Azure OpenAI Assistants API by default. *Note*: Should migrate to official `openai-node` library once azure support is checked in. Here's the [PR](openai/openai-node#718 ## Attestation Checklist - [x] My code follows the style guidelines of this project - I have checked for/fixed spelling, linting, and other errors - I have commented my code for clarity - I have made corresponding changes to the documentation (updating the doc strings in the code is sufficient) - My changes generate no new warnings - I have added tests that validates my changes, and provides sufficient test coverage. I have tested with: - Local testing - E2E testing in Teams - New and existing unit tests pass locally with my changes --------- Co-authored-by: Corina <[email protected]>
Changes being requested
Add an Azure client similar to Python's.
To-dos:
Add support for Azure-specific modelsAdditional context & links