Skip to content
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: issue-1028, fetch models when user enters api key #3251

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

normunds-wipo
Copy link
Contributor

@normunds-wipo normunds-wipo commented Jul 3, 2024

Summary

Solution is intended only for custom configurations. Each time the user enters api key from frontend, it reloads models, including from the endpoint using the new key.

Relevant changes:

  • in frontend api layer, update of user key invalidates models, causing to re-load them when next used
  • in modelscontroller, get method does not serve from cache anymore, but each time called, retrieves the models
  • in loadConfigModels, if api_key is defined as user_provided, check if user has a valid key and use it to fetch models

It might be working also for default endpoints, as now each time key has been entered, the models get refreshed, but this is not tested.

Change Type

Testing

Tested just by running code. We are only using custom configuration

Checklist

Please delete any irrelevant options.

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have commented in any complex areas of my code
  • Local unit tests pass with my changes (well tests related to tokenSplit fail with or without my code)

@normunds-wipo normunds-wipo marked this pull request as ready for review July 3, 2024 11:44
@mkagit
Copy link

mkagit commented Sep 12, 2024

Is it working without issues @normunds-wipo ?

@normunds-wipo
Copy link
Contributor Author

Yes. I just merged the main branch and had to adjust for encryption/decryption utility return value change (from string to Promise), but else we are using this code for a couple of months without problems.

@mkagit
Copy link

mkagit commented Sep 12, 2024

Yes. I just merged the main branch and had to adjust for encryption/decryption utility return value change (from string to Promise), but else we are using this code for a couple of months without problems.

I'll try it. What's your case for the reloading fetch?
I was looking for to, fetch through custom "user_provided" key, models from the LiteLLM virtual keys proxy server.

@normunds-wipo
Copy link
Contributor Author

The same, query models from LiteLLM. Different users have different keys and potentially different set of models. So we cannot cache all models and need to query models by user. Also once the user enters the key we need to reload models corresponding to the new key. It seems it is doing it correctly.

@dansavu
Copy link

dansavu commented Sep 16, 2024

This is a useful feature, looking forward to see the PR approved and merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants