openai-node
openai-node copied to clipboard
[Azure] Introduce AzureOpenAI client
- [x] I understand that this repository is auto-generated and my pull request may not be merged
Changes being requested
Add an Azure client similar to Python's.
To-dos:
- [x] Export it from the package
- [ ] ~Add support for Azure-specific models~
- [x] Add an example
- [x] Add tests
Additional context & links
Thank you for putting this up @deyaaeldeen ! We're discussing internally as well.
@rattrayalex I need your help in exporting the Azure client. The index.ts module has the definition of the OpenAI client but I think ideally, that definition may need to live in its own module so that index.ts can export both OpenAI and AzureOpenAI. What do you think?
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?)
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 😊
Hey we've moved the OpenAI class definition to a separate src/client.ts file so you can properly inherit from it now :)
@RobertCraigie Awesome! I updated the client in https://github.com/openai/openai-node/pull/718/commits/780ddbbbe45a068c045f24d8a6bfd62efa94cbde.
Unfortunately we just had to revert the client.ts file change because it broke in certain cases: https://github.com/openai/openai-node/issues/816
I tried putting the azure exports at the bottom of the index.ts file and that works in some environments but not all :/
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 index.ts / client.ts files and it does not seem possible to make that change in a compatible fashion so we'll be looking into splitting them up in the next major version.
Actually, you could define the azure client class at the bottom of the index.ts file instead, that'll result in the best end user experience
@RobertCraigie Thanks for the feedback! I updated the PR accordingly.
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.
This has been moved to https://github.com/openai/openai-node/pull/822, which merged, and will be released in https://github.com/openai/openai-node/pull/823.
Thank you very much for the contribution and partnership!