azure-search-openai-demo icon indicating copy to clipboard operation
azure-search-openai-demo copied to clipboard

Adding support for OpenAI instance

Open carlotta94c opened this issue 1 year ago • 2 comments

Purpose

This PR adds OpenAI API support for users who don't have access to Azure OpenAI. Additions:

  • Calling OpenAI endpoint if env variable OPENAI_API_TYPE is set to openai (default models used: text-davinci-003 and gpt-3.5-turbo)
  • Making bicep configuration conditional (Azure OpenAI resource is created only if param openAiType is set to 'azure')
  • Adding instruction to switch from an Azure OpenAI endpoint (default) to a non-azure OpenAI instance
  • ...

Does this introduce a breaking change?

[ ] Yes
[x] No

Pull Request Type

What kind of change does this Pull Request introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[x] Documentation content changes
[ ] Other... Please describe:

How to Test

  • Get the code
git clone https://github.com/carlotta94c/azure-search-openai-demo
cd azure-search-openai-demo
git checkout openai_support_PR
npm install
  • Test the code

Test deployment and app running in the cloud:

  1. Navigate to the main.bicep file in the infra folder
  2. Look for the openAiType parameter at line 16
  3. Change its value to openai (instead of azure)
  4. Configure the following app settings at line 135-136:
  • OPENAI_API_ORGANIZATION={Your OpenAI organization}
  • OPENAI_API_KEY={Your OpenAI API key}
  1. Run azd up

To configure the local environment to use an existing OpenAI instance and test the app locally:

Run azd env set OPENAI_API_TYPE openai Run azd env set OPENAI_API_ORGANIZATION {Your OpenAI organization} Run azd env set OPENAI_API_KEY {Your OpenAI API key}

What to Check

Verify that the following are valid

  • Running 'azd up' without applying the changes to bicep file and env variables described above will ensure the same behavior of provisioning and deployment as before this PR (using Azure OpenAI resource is the default).

Other Information

Completion is not supported by OpenAI 'gpt-3.5-turbo'. For non-azure OpenAI instance the /chat endpoint is used.

carlotta94c avatar Jun 23 '23 13:06 carlotta94c

Thanks for the PR @carlotta94c this looks like a really useful feature. I've added some nitpick comments in the review, but the most important one is the use of parameters to set the OpenAI type instead of editing bicep files.

tonybaloney avatar Jun 26 '23 04:06 tonybaloney

Thanks for the PR @carlotta94c this looks like a really useful feature. I've added some nitpick comments in the review, but the most important one is the use of parameters to set the OpenAI type instead of editing bicep files.

Hi @tonybaloney, huge thanks for your prompt review! I believe I've addressed the requested changes with my last commit.

carlotta94c avatar Jun 27 '23 08:06 carlotta94c

closing this outdated PR as I opened a new one https://github.com/Azure-Samples/azure-search-openai-demo/pull/507

carlotta94c avatar Aug 08 '23 09:08 carlotta94c