ChatDev
ChatDev copied to clipboard
Feat: Allow Azure ChatGPT usage
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.
Hi! Thanks for this. It helped me find the error for my system and I can now use Azure! 🥳
Hi, do you have any idea how Azure can be used with the docker version?
@AkivaAK Apply my diff, and it should work I think.
@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.