azure-search-openai-demo
azure-search-openai-demo copied to clipboard
Adding support for OpenAI instance
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:
- Navigate to the main.bicep file in the infra folder
- Look for the openAiType parameter at line 16
- Change its value to openai (instead of azure)
- Configure the following app settings at line 135-136:
- OPENAI_API_ORGANIZATION={Your OpenAI organization}
- OPENAI_API_KEY={Your OpenAI API key}
- 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.
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.
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.
closing this outdated PR as I opened a new one https://github.com/Azure-Samples/azure-search-openai-demo/pull/507