wandb / openui

OpenUI let's you describe UI using your imagination, then see it rendered live.
https://openui.fly.dev
Apache License 2.0
16.81k stars 1.47k forks source link

Using openui with AzureOpenai #128

Open NikitaRawat2003 opened 1 month ago

NikitaRawat2003 commented 1 month ago

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

vanpelt commented 1 month ago

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

NikitaRawat2003 commented 1 month ago

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

bxav commented 1 month ago

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)
gyxter commented 1 month ago

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?

bxav commented 1 month ago

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