openai-node icon indicating copy to clipboard operation
openai-node copied to clipboard

[Azure] Introduce AzureOpenAI client

Open deyaaeldeen opened this issue 1 year ago • 13 comments

  • [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

deyaaeldeen avatar Mar 14 '24 20:03 deyaaeldeen

Thank you for putting this up @deyaaeldeen ! We're discussing internally as well.

rattrayalex avatar Mar 15 '24 11:03 rattrayalex

@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?

deyaaeldeen avatar Mar 18 '24 23:03 deyaaeldeen

We'll take a look at that soon @deyaaeldeen. It may have to wait til next week.

rattrayalex avatar Mar 21 '24 01:03 rattrayalex

@rattrayalex Thanks for taking a look! I wonder if there is anything that I can clarify or help with to move this forward?

deyaaeldeen avatar Apr 03 '24 06:04 deyaaeldeen

thanks for the bump, this slipped through the cracks. I've poked internally.

rattrayalex avatar Apr 03 '24 21:04 rattrayalex

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?)

pstern-sl avatar Apr 08 '24 21:04 pstern-sl

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 😊

deyaaeldeen avatar Apr 25 '24 21:04 deyaaeldeen

Hey we've moved the OpenAI class definition to a separate src/client.ts file so you can properly inherit from it now :)

RobertCraigie avatar May 03 '24 11:05 RobertCraigie

@RobertCraigie Awesome! I updated the client in https://github.com/openai/openai-node/pull/718/commits/780ddbbbe45a068c045f24d8a6bfd62efa94cbde.

deyaaeldeen avatar May 03 '24 13:05 deyaaeldeen

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.

RobertCraigie avatar May 03 '24 13:05 RobertCraigie

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 avatar May 03 '24 14:05 RobertCraigie

@RobertCraigie Thanks for the feedback! I updated the PR accordingly.

deyaaeldeen avatar May 03 '24 14:05 deyaaeldeen

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.

rattrayalex avatar May 03 '24 22:05 rattrayalex

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!

rattrayalex avatar May 05 '24 16:05 rattrayalex