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.86k stars 1.47k forks source link

How to change OpenAI's baseURL #91

Closed zsychn closed 1 month ago

zsychn commented 1 month ago

I've tried to directly modify the baseURL in openai.ts several times, but without success. I would appreciate any help, thank you.

mmuyakwa commented 1 month ago

File server.py in the folder backend/openui - line 68

Set the base_url to whatever you wish.

openai = AsyncOpenAI(
    base_url="https://YOUR-URL/v1"
)  # AsyncOpenAI(base_url="http://127.0.0.1:11434/v1")
ollama = AsyncClient()
router = APIRouter()
session_store = DBSessionStore()
github_sso = GithubSSO(
    config.GITHUB_CLIENT_ID, config.GITHUB_CLIENT_SECRET, f"{config.HOST}/v1/callback"
)
zsychn commented 1 month ago

Thank you so much. I will try it right away. Thank you.

vanpelt commented 1 month ago

Love this! Thanks @mmuyakwa. I'll look into making this configurable / extensible.

zhjygit commented 1 month ago

File server.py in the folder backend/openui - line 68

Set the base_url to whatever you wish.

openai = AsyncOpenAI(
    base_url="https://YOUR-URL/v1"
)  # AsyncOpenAI(base_url="http://127.0.0.1:11434/v1")
ollama = AsyncClient()
router = APIRouter()
session_store = DBSessionStore()
github_sso = GithubSSO(
    config.GITHUB_CLIENT_ID, config.GITHUB_CLIENT_SECRET, f"{config.HOST}/v1/callback"
)

NO no no, it can not work after change the base_url in the server.py at AsyncOpenAI(base_url="http://192.168.1.103:11434/v1"), when i run python -m openui, the error is as follows: the api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable.

mmuyakwa commented 1 month ago

@zhjygit Unfortunately the app always requires the "OPENAI_API_KEY" to be set, whether you use it or not. If you don't require it, then set it with something. Anything. It just has to be present.

In my case I used it for Groq. I entered the Groq-API-Key and changed the base_url to the url of Groq's API.

Otherwise take a look at the following: https://github.com/wandb/openui/issues/73#issuecomment-2099840072