Azure OpenAI API Support
crypticatul opened this issue · comments
Hi,
I want to utilize my Azure OpenAI API for this, can you add and option for the same? GPT-3.5-Turbo, and GPT-4o will be enough as an option. I am deploying on Vercel.
Thanks.
Unfortunately, at this time, all providers are hardcoded. It would be nice to have them support this through a config file. I got Azure working but had to add it in a lot of places in both the backend and frontend. Basically, it's pretty much like OpenAI but you have to use a different llama_index client. example in chat.py --> get_llm
...
elif model == ChatModel.AZURE:
return AzureOpenAI(
api_version=os.environ["AZURE_OPENAI_API_VERSION"],
deployment_name=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT_NAME"],
model=os.environ["AZURE_OPENAI_MODEL"],
api_key=os.environ["AZURE_OPENAI_API_KEY"],
azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
)
...
Also you will have to implement your Instructor to support the related queries.
related_queries.py > instructor_client
...
elif model == ChatModel.AZURE:
return from_azureopenai(openai.AsyncAzureOpenAI(
api_version=os.environ["AZURE_OPENAI_API_VERSION"],
azure_deployment=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT_NAME"],
api_key=os.environ["AZURE_OPENAI_API_KEY"],
azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
))
...
Hey, I added support for azure! Let me know if you have any trouble setting it up!
Hi, thanks for adding the support for Azure. I just have a few silly queries;
In env vars
- On Azure, I have deployed gpt-35-turbo-16k (model name) with the deployment name "Better" so what should I use in AZURE_DEPLOYMENT_NAME
- What we need to put in AZURE_API_BASE? is it region name or Azure Endpoint Name? I have deployed this in eastus
- For Azure the OPENAI_MODE=azure, right?
- Apologies for silly queries, however, generally speaking, to use this deployment I just use Endpoint, API Key, Deployment Name and API Version, however, some fields in the env vars template are a bit confusing to me.
I'm using the below env vars and still getting error - OPENAI_API_KEY environment variable not found
![image](https://private-user-images.githubusercontent.com/88734298/344457293-d6785f81-dbd8-4fee-9482-dd69545d2b97.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA1MjYxMjIsIm5iZiI6MTcyMDUyNTgyMiwicGF0aCI6Ii84ODczNDI5OC8zNDQ0NTcyOTMtZDY3ODVmODEtZGJkOC00ZmVlLTk0ODItZGQ2OTU0NWQyYjk3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA5VDExNTAyMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM4NjU2ZTljMmY2YTUwMGYzYjliOWNmMTg5YTFkYTY5N2U5MTZiZTg4MzljNmI2MDQ0MTM5YzUwYzNkMjIyYzUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.MirMekUR1Yz2qnjUZWdvc0xdfUawErqrJS5bFpG7fmk)