openui icon indicating copy to clipboard operation
openui copied to clipboard

Using openui with AzureOpenai

Open NikitaRawat2003 opened this issue 9 months ago • 5 comments

I have Azureopenai Credentials and i was wondering if the openui can be used with Azureopenai

NikitaRawat2003 avatar May 16 '24 05:05 NikitaRawat2003

I'm using the native OpenAI client which I imagine supports it. You can just change the code here.

vanpelt avatar May 16 '24 13:05 vanpelt

i tried changing the code as you mentioned ,but still facing a lot of errors

NikitaRawat2003 avatar May 17 '24 04:05 NikitaRawat2003

Thanks @vanpelt works perfectly for me with gpt-4o. @NikitaRawat2003 the fastest way to try it, is to create on your azure instance a deployment that as the same name as the model name in openai ("gpt-3.5-turbo", "gpt-4o", "gpt-4-turbo") and then import AsyncAzureOpenAI from openai and replace:

# openai = AsyncOpenAI(
#     base_url=config.OPENAI_BASE_URL,
#     api_key=config.OPENAI_API_KEY)

openai = AsyncAzureOpenAI(
    api_key=config.OPENAI_API_KEY,  
    api_version="2024-02-01",
    azure_endpoint=config.OPENAI_BASE_URL)

bxav avatar May 28 '24 07:05 bxav

Thanks @vanpelt works perfectly for me with gpt-4o. @NikitaRawat2003 the fastest way to try it, is to create on your azure instance a deployment that as the same name as the model name in openai ("gpt-3.5-turbo", "gpt-4o", "gpt-4-turbo") and then import AsyncAzureOpenAI from openai and replace:

# openai = AsyncOpenAI(
#     base_url=config.OPENAI_BASE_URL,
#     api_key=config.OPENAI_API_KEY)

openai = AsyncAzureOpenAI(
    api_key=config.OPENAI_API_KEY,  
    api_version="2024-02-01",
    azure_endpoint=config.OPENAI_BASE_URL)

did you add your endpoint and key in the config.py file? can you show me how you did it?

gyxter avatar May 28 '24 11:05 gyxter

did you add your endpoint and key in the config.py file? can you show me how you did it?

@gyxter No need to change anything in the config.py, I reuse the variables. You can do as in the doc, you can export your variable in the terminal:

export OPENAI_API_KEY=*****
export OPENAI_BASE_URL=https://{your-instance}.openai.azure.com/
cd backend
python -m openui

bxav avatar May 28 '24 13:05 bxav