Skip to content
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

Adding support for OpenAI instance #361

Closed
wants to merge 17 commits into from

Conversation

carlotta94c
Copy link
Contributor

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.

app/backend/approaches/retrievethenread.py Outdated Show resolved Hide resolved
app/backend/approaches/retrievethenread.py Outdated Show resolved Hide resolved
app/backend/approaches/readretrieveread.py Outdated Show resolved Hide resolved
app/backend/approaches/readretrieveread.py Outdated Show resolved Hide resolved
app/backend/approaches/readretrieveread.py Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
infra/main.bicep Outdated Show resolved Hide resolved
notebooks/chat-read-retrieve-read.ipynb Outdated Show resolved Hide resolved
notebooks/chat-read-retrieve-read.ipynb Outdated Show resolved Hide resolved
notebooks/chat-read-retrieve-read.ipynb Outdated Show resolved Hide resolved
@tonybaloney
Copy link
Contributor

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.

@carlotta94c
Copy link
Contributor Author

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.

app/backend/app.py Outdated Show resolved Hide resolved
@carlotta94c
Copy link
Contributor Author

closing this outdated PR as I opened a new one #507

@carlotta94c carlotta94c closed this Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants