-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: configure dynamic providers via .env #1108
feat: configure dynamic providers via .env #1108
Conversation
# Conflicts: # app/components/chat/BaseChat.tsx
I have added my comments, I didn't want to add another api endpoint but I guess thats the only way to have both apikeys from UI and from env since we should not expose apikeys set on env to UI. the only change i think is needed is passing the UI data from cookies so that it works for every scenarios env/UI |
Thanks for the catch with the override, @thecodacus ! I re-enabled the provisioning of apiKeys from the UI. In the video, you can see the api-key being loaded from the env, then overridden with an invalid api-key (the models-list becomes blank as earlier), then override the api key with the valid one from the UI. Hope this is fine now. |
but i believe in this case its not using the |
e3997e4
to
4799300
Compare
While doing this, introduce a simple helper function for cookies
I now transport all the apikeys and settings via cookies. It still makes me shiver to have an unencrypted textfile with credentials transported as plain text, but ... maybe I have been too corporate all my dev life ;) you asked
I verified manually on the dev tools: When changing the apiKey on the ui, a new request to |
all looks good to me. I will just run it once then can merge it |
@thecodacus please let me merge it if it looks ok for you. I want to make sure I pushed the latest changes, but I'm afk now Edit: all good, it was just the mobile GitHub app not refreshing 🤦 |
* Use backend API route to fetch dynamic models # Conflicts: # app/components/chat/BaseChat.tsx * Override ApiKeys if provided in frontend * Remove obsolete artifact * Transport api keys from client to server in header * Cache static provider information * Restore reading provider settings from cookie * Reload only a single provider on api key change * Transport apiKeys and providerSettings via cookies. While doing this, introduce a simple helper function for cookies
Motivation
Up to now, some providers couldn't be configured via the environment properly. The list of models remained empty
What this PR contains
Previously, the list of models was retrieved from the front-end. If the list wasn't hard coded (like for many providers), the system tried to retrieve the models via the
/models
route of the provider.As the environment configuration which includes the API keys is intentionally not shared with the client, this request couldn't complete and failed silently on the client.
This affected
openai like
andopenrouter
once they required api keys.This PR implements a more robust and flexible approach to retrieving model lists by moving the initialization logic to the backend, enabling dynamic model discovery and configuration across different providers.
Key Changes
Replaced static MODEL_LIST with dynamic backend-driven model fetching
Created a new /api/models endpoint to serve model information
Implemented useModels hook for frontend model access
Refactored model initialization to use LLMManager
Added more flexible provider and model configuration
Improved handling of API keys and provider settings
Technical Details
LLMManager
Key implementation details:
API Endpoints
/api/models
now returns:Related
#1035