coleam00 / bolt.new-any-llm

Prompt, run, edit, and deploy full-stack web applications using any LLM you want!
https://bolt.new
MIT License
3.92k stars 1.61k forks source link

feat: refactor/standardise model providers code + add "get provider key" #251

Closed wonderwhy-er closed 1 week ago

wonderwhy-er commented 1 week ago

Goal

Goal was to provide link to get API key for first time users To achieve that I standardised provider list to include name, static and dynamic model lists and API key url and label. For LM Studio link and label are about downloading LM Studio, for Ollama too

PR Summary

  1. Constants Update:

    • Introduces ProviderInfo and PROVIDER_LIST, organizing providers with models and API key links.
    • Refactors model fetching to be dynamic for supported providers.
  2. Base Chat Component Update:

    • Uses PROVIDER_LIST dynamically for provider selection, removing hardcoded options.
  3. API Key Management Component Update:

    • Added link to get API keys if providers has the link
    1. Added Dynamic Model list for OpenRouter

    2. Made server use API keys from cookies instead of request body - there were issues with them not being actual in request body

    3. Fixed Google API keys provider - API key was passed as argument while options with it as property was expected

wonderwhy-er commented 1 week ago

I merged in dynamic model list for OpenRouter into this PR. Also fixed bunch of things. Added list to description.

Would be good to merge.

chrismahoney commented 1 week ago

Edit: Moving to a review comment

chrismahoney commented 1 week ago

Created #276 to capture any additional issues/PRs that should adapt into this refactor after the merge.

wonderwhy-er commented 1 week ago

Pushed in fix for type check error

wonderwhy-er commented 1 week ago

Added additional type fix for ProviderInfo import. Should work with dev command now too.

chrismahoney commented 1 week ago

Alright! Looks good based on your changes @wonderwhy-er

TheDevelolper commented 5 days ago

Oh, I was doing a code review on this but it seems you already merged it. I was too slow.

Seems to work though the second box populates a bit slow, I was going to see what might be the cause, perhaps it's Ollama taking time to return all the models

Then I saw this: image

!! bunny ears to check if something is null or not and turning it into a boolean at the same time. This is clever but wouldn't it be better to just check for null / undefined for code simplicity?

Anyway it doesn't matter now it's merged and it does seem to work well.