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

Feat: Allow Azure ChatGPT usage #192

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Feat: Allow Azure ChatGPT usage #192

wants to merge 2 commits into from

Conversation

dnhkng
Copy link

@dnhkng dnhkng commented Oct 17, 2023

Adds access to the environment variable "OPENAI_API_ENGINE", which is needed for the Azure API.

The Azure API requires the use of the 'engine' parameter in the ChatCompletion and not the 'model' parameter. ie, from the documentation, here are the needed parameters:

response = openai.ChatCompletion.create(
    engine="gpt-35-turbo", # Here we use 'engine', not 'model'
    messages=[
        {"role": "system", "content": "Assistant is a large language model trained by OpenAI."},
        {"role": "user", "content": "Who were the founders of Microsoft?"}
    ]
)

This patch lets you use your Azure ChatGPT account by defining the engine and other required variables as environment variables, without affecting the standard OpenAI API use. Azure API access is used like this:

OPENAI_API_BASE="https://your_deployment_name.openai.azure.com/" OPENAI_API_TYPE=azure OPENAI_API_ENGINE=your_model_name OPENAI_API_VERSION=2023-05-15 OPENAI_API_KEY=your_secret_key python3 run.py --task "Snake game in pure html" --name "WebSnake"

This has been tested with Azure and OpenAI APIs successfully.

Adds variable "OPENAI_API_ENGINE", which is needed for the Azure API
@Alphamasterliu Alphamasterliu added the enhancement New feature or request label Oct 23, 2023
@OhNotWilliam
Copy link

Hi! Thanks for this. It helped me find the error for my system and I can now use Azure! 🥳

@AkivaAK
Copy link

AkivaAK commented Nov 5, 2023

Hi, do you have any idea how Azure can be used with the docker version?

@dnhkng
Copy link
Author

dnhkng commented Nov 14, 2023

@AkivaAK Apply my diff, and it should work I think.

@kirinzer
Copy link

kirinzer commented Feb 5, 2024

@cryptictech Maybe I can use the same way to implement the function I want, I will use a third-party api, they will have the same api capabilities as open ai, just the base url is different.

Copy link
Collaborator

@XiaoDu-flying XiaoDu-flying left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR, there are some conflicts and could you please resolve them : ) .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants