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

fix: respect provider choice from UI #188

Merged

Conversation

TommyHolmberg
Copy link

@TommyHolmberg TommyHolmberg commented Nov 6, 2024

This change ensures the streamText function respects the provider choice made in the UI.

I am unable to test this thoroughly because I don't have API keys for the providers, as I use local models.

Even locally, this still doesn't work, but it's a step in the right direction. The URL calls are correct, but they aren't reaching the local LiteLLM server for some reason.

…t so that it can be accessed in sendMessage.

Added provider to message queue in sendMessage.
Changed streamText to extract both model and provider.
@TommyHolmberg TommyHolmberg changed the title Respect provider choice fix: Respect provider choice from UI Nov 6, 2024
@TommyHolmberg TommyHolmberg changed the title fix: Respect provider choice from UI fix: respect provider choice from UI Nov 6, 2024
@nandan121
Copy link

nandan121 commented Nov 6, 2024

I merged this change into my fork, and it works as expected. Thanks Tommy

I have tested using same model name, gpt-4o-mini, and openAI vs OPENAI_LIKE...

@nandan121
Copy link

nandan121 commented Nov 6, 2024

This change ensures the streamText function respects the provider choice made in the UI.

I am unable to test this thoroughly because I don't have API keys for the providers, as I use local models.

Even locally, this still doesn't work, but it's a step in the right direction. The URL calls are correct, but they aren't reaching the local LiteLLM server for some reason.
Hello Tommy,
I could get it working for liteLLM. I used your https://github.com/TommyHolmberg/bolt.new-any-llm/tree/respect-provider-choice , my constants file was https://github.com/nandan121/bolt.new-any-llm/blob/417307bdb5edf2b4a5da92c9d1c6ec15b8f68923/app/utils/constants.ts

I tried one step at a time with the free API from Mistral to try. https://docs.litellm.ai/docs/providers/mistral It worked fine. The issue in many cases was that bolt uses about 3500 tokens each time, and so some free models came up with error.

@coleam00
Copy link
Collaborator

coleam00 commented Nov 6, 2024

This is great, thank you @TommyHolmberg! I'm going to test this myself this week and merge it in.

@TommyHolmberg
Copy link
Author

This change ensures the streamText function respects the provider choice made in the UI.
I am unable to test this thoroughly because I don't have API keys for the providers, as I use local models.
Even locally, this still doesn't work, but it's a step in the right direction. The URL calls are correct, but they aren't reaching the local LiteLLM server for some reason.
Hello Tommy,
I could get it working for liteLLM. I used your https://github.com/TommyHolmberg/bolt.new-any-llm/tree/respect-provider-choice , my constants file was https://github.com/nandan121/bolt.new-any-llm/blob/417307bdb5edf2b4a5da92c9d1c6ec15b8f68923/app/utils/constants.ts

I tried one step at a time with the free API from Mistral to try. https://docs.litellm.ai/docs/providers/mistral It worked fine. The issue in many cases was that bolt uses about 3500 tokens each time, and so some free models came up with error.

Great! Shortly after your comment I solved the problem on my setup too. It works fine with litellm now.

I hope it still works with all of the regular providers as well. I don't see a reason why it shouldn't, but you never know until it's been tested.

@nandan121
Copy link

image
It seems that the message has "Provider" in it, and it needs to be removed

Use regex defined in constants.ts instead of redefining.
@TommyHolmberg
Copy link
Author

TommyHolmberg commented Nov 6, 2024

It seems that the message has "Provider" in it, and it needs to be removed

I completely overlooked that. I found the sanitize method for it and could fix it rather easily. Try the PR now.

@nandan121
Copy link

nandan121 commented Nov 7, 2024

It seems that the message has "Provider" in it, and it needs to be removed

I completely overlooked that. I found the sanitize method for it and could fix it rather easily. Try the PR now.

Tried, and it works as expecms that the message has "Provider" in it, and it needs to be removed

I completely overlooked that. I found the sanitize method for it and could fix it rather easily. Try the PR now.

Tried, and it works as expected(no model name or provider name).

BUT, my suggestion would be to have it in the chat... It is nice and does not take space.

I would suggest that in https://github.com/coleam00/bolt.new-any-llm/pull/188/files#diff-dd246a18ac09a3e1a293988bf2f81b4f246f4c4aa03db23db48f79371c378981 I would probably have it in my version.

return content.replace(modificationsRegex, '').replace(MODEL_REGEX, '$1').replace(PROVIDER_REGEX, ' ($1)\n\n').trim();

could be better. I will allow the @coleam00 to make that decision.

image

@TommyHolmberg
Copy link
Author

It seems that the message has "Provider" in it, and it needs to be removed

I completely overlooked that. I found the sanitize method for it and could fix it rather easily. Try the PR now.

Tried, and it works as expecms that the message has "Provider" in it, and it needs to be removed

I completely overlooked that. I found the sanitize method for it and could fix it rather easily. Try the PR now.

Tried, and it works as expected(no model name or provider name).

BUT, my suggestion would be to have it in the chat... It is nice and does not take space.

I would suggest that in https://github.com/coleam00/bolt.new-any-llm/pull/188/files#diff-dd246a18ac09a3e1a293988bf2f81b4f246f4c4aa03db23db48f79371c378981 I would probably have it in my version.

return content.replace(modificationsRegex, '').replace(MODEL_REGEX, '$1').replace(PROVIDER_REGEX, ' ($1)\n\n').trim();

could be better. I will allow the @coleam00 to make that decision.

I think it looks great! And good catch with those line breaks. I was wondering why the message boxes looked off.

@coleam00
Copy link
Collaborator

coleam00 commented Nov 8, 2024

I appreciate the back and forth here @TommyHolmberg and @nandan121! Could you clarify if this is ready to merge now?

@TommyHolmberg
Copy link
Author

I added Using: before the model and provider to clarify what it's about. The best would be if we could get the model and provider into the response message, but that requires a bit of work and it doesnt belong in this PR.

@coleam00 In my opinion it is ready to merge.

@nandan121
Copy link

I appreciate the back and forth here @TommyHolmberg and @nandan121! Could you clarify if this is ready to merge now?

Thanks @coleam00 and @TommyHolmberg . I tested it once, it looks great. All is working and ready to merge.
image

@coleam00 coleam00 merged commit 936a9c0 into stackblitz-labs:main Nov 9, 2024
1 check passed
@coleam00
Copy link
Collaborator

coleam00 commented Nov 9, 2024

Fantastic, thank you @TommyHolmberg and @nandan121!

arsenikstiger pushed a commit to arsenikstiger/bolt.new-any-llm that referenced this pull request Nov 12, 2024
commit a081f8b
Merge: f1c5fbf 8c6e420
Author: Chris Mahoney <[email protected]>
Date:   Tue Nov 12 12:41:58 2024 -0600

    Merge pull request stackblitz-labs#213 from thecodacus/code-streaming

    feat(code-streaming): added code streaming to editor while AI is writing files

commit 8c6e420
Author: Anirban Kar <[email protected]>
Date:   Wed Nov 13 00:04:41 2024 +0530

    type fix

commit 32699fd
Author: Anirban Kar <[email protected]>
Date:   Wed Nov 13 00:03:33 2024 +0530

    made types optional and, workbench get repo fix

commit 5f46a18
Author: Anirban Kar <[email protected]>
Date:   Tue Nov 12 23:49:34 2024 +0530

    recreated the lock file

commit 6b37859
Author: Anirban Kar <[email protected]>
Date:   Tue Nov 12 23:47:27 2024 +0530

    temporary removed lock file

commit 58d95bd
Author: Anirban Kar <[email protected]>
Date:   Tue Nov 12 23:44:40 2024 +0530

    chore: recreated the lock file

commit a50945e
Author: Anirban Kar <[email protected]>
Date:   Tue Nov 12 23:39:44 2024 +0530

    chore: reverted pnpm lock

commit cc43f06
Author: Anirban Kar <[email protected]>
Date:   Tue Nov 12 23:36:18 2024 +0530

    chore: reverted pnpm package version to match ghaction

commit 2d270e7
Merge: 54351cd f1c5fbf
Author: Anirban Kar <[email protected]>
Date:   Tue Nov 12 23:20:30 2024 +0530

    Merge branch 'main' into code-streaming

commit f1c5fbf
Merge: 0203cf9 d7b1edc
Author: Chris Mahoney <[email protected]>
Date:   Tue Nov 12 10:46:30 2024 -0600

    Merge pull request stackblitz-labs#261 from chrismahoney/fix/remove-ghaction-titlecheck

    Temporarily removing semantic-pr.yaml

commit d7b1edc
Author: Chris Mahoney <[email protected]>
Date:   Tue Nov 12 10:34:51 2024 -0600

    Temporarily removing semantic-pr.yaml in order to verify otherwise ready for review PRs.

commit 0203cf9
Merge: 1630d80 f28f7f0
Author: Chris Mahoney <[email protected]>
Date:   Tue Nov 12 09:30:21 2024 -0600

    Merge pull request stackblitz-labs#228 from thecodacus/feature--bolt-shell

    feat(bolt terminal): added dedicated bolt terminal, and attached to workbench

commit 1630d80
Merge: 0b75051 b240344
Author: Cole Medin <[email protected]>
Date:   Mon Nov 11 18:40:30 2024 -0600

    Merge pull request stackblitz-labs#247 from JNN5/main

    fix: adds missing -t for dockerbuild:prod command in package.json

commit 0b75051
Merge: 4b492b9 9c84880
Author: Cole Medin <[email protected]>
Date:   Mon Nov 11 18:39:48 2024 -0600

    Merge pull request stackblitz-labs#254 from ali00209/new_bolt5

    fix: bug  stackblitz-labs#245

commit 9c84880
Author: ali00209 <[email protected]>
Date:   Tue Nov 12 05:10:54 2024 +0500

    fix: bug  stackblitz-labs#245

commit b240344
Author: Jonas Neumann <[email protected]>
Date:   Mon Nov 11 17:41:15 2024 +0800

    fix: adds missing -t for dockerbuild:prod command in package.json

commit 4b492b9
Merge: c968948 32ae66a
Author: Eduard Ruzga <[email protected]>
Date:   Mon Nov 11 09:58:05 2024 +0200

    Merge pull request stackblitz-labs#104 from karrot0/main

    feat: lm studio integration

commit 32ae66a
Merge: dff340e 6f8001a
Author: Karrot0 <[email protected]>
Date:   Sun Nov 10 21:08:06 2024 -0500

    Merge branch 'main' of https://github.com/karrot0/bolt.new-any-llm

commit dff340e
Author: Karrot0 <[email protected]>
Date:   Sun Nov 10 21:08:01 2024 -0500

    @wonderwhy-er suggestion fix pr

commit 6f8001a
Merge: 9a7d28a c968948
Author: Karrot <[email protected]>
Date:   Sun Nov 10 21:04:29 2024 -0500

    Merge branch 'coleam00:main' into main

commit c968948
Merge: 848c697 93ff797
Author: Chris Mahoney <[email protected]>
Date:   Sun Nov 10 17:16:10 2024 -0600

    Merge pull request stackblitz-labs#242 from aaronbolton/main

    removing GitHub action workflow github-build-push.yml

commit 93ff797
Merge: 1b44a0b 848c697
Author: Aaron Bolton <[email protected]>
Date:   Sun Nov 10 20:24:42 2024 +0000

    Merge branch 'main' of https://github.com/aaronbolton/bolt.new-any-llm

commit 1b44a0b
Author: Aaron Bolton <[email protected]>
Date:   Sun Nov 10 20:24:32 2024 +0000

    Delete github-build-push.yml

commit 848c697
Author: Cole Medin <[email protected]>
Date:   Sun Nov 10 13:43:28 2024 -0600

    Update README.md

commit 52ae333
Merge: ce6b65e c35211f
Author: Eduard Ruzga <[email protected]>
Date:   Sun Nov 10 15:06:51 2024 +0200

    Merge pull request stackblitz-labs#205 from milutinke/claude-new-sonnet-and-haiku

    feat: added the latest Sonnet 3.5 and Haiku 3.5

commit c35211f
Merge: bb0546d ce6b65e
Author: Anon <[email protected]>
Date:   Sun Nov 10 13:58:34 2024 +0100

    Merge branch 'main' into claude-new-sonnet-and-haiku

commit 9a7d28a
Merge: f9e750d ce6b65e
Author: Eduard Ruzga <[email protected]>
Date:   Sun Nov 10 14:55:17 2024 +0200

    Merge branch 'main' into main

commit ce6b65e
Merge: 13b1321 435d6b4
Author: Chris Mahoney <[email protected]>
Date:   Sat Nov 9 20:53:00 2024 -0600

    Merge pull request stackblitz-labs#178 from albahrani/patch-1

    docs: update README.md changed .env to .env.local

commit 13b1321
Author: Cole Medin <[email protected]>
Date:   Sat Nov 9 07:59:06 2024 -0600

    Noting that API key will still work if set in .env file

commit b3fe207
Author: Cole Medin <[email protected]>
Date:   Sat Nov 9 07:56:43 2024 -0600

    Fixing merge conflicts in BaseChat.tsx

commit 936a9c0
Merge: d18517a f30612d
Author: Cole Medin <[email protected]>
Date:   Sat Nov 9 07:45:06 2024 -0600

    Merge pull request stackblitz-labs#188 from TommyHolmberg/respect-provider-choice

    fix: respect provider choice from UI

commit f30612d
Merge: 9b97837 d18517a
Author: Cole Medin <[email protected]>
Date:   Sat Nov 9 07:44:40 2024 -0600

    Merge branch 'main' into respect-provider-choice

commit f28f7f0
Author: Anirban Kar <[email protected]>
Date:   Sat Nov 9 14:23:29 2024 +0530

    chore: cleanup logging

commit d4c4fe1
Author: Anirban Kar <[email protected]>
Date:   Sat Nov 9 13:43:19 2024 +0530

    feat: hyperlinked on "Start application"  actionto switch to preview in workbench

commit 719384c
Author: Anirban Kar <[email protected]>
Date:   Sat Nov 9 12:59:42 2024 +0530

    feat(bolt-terminal) bolt terminal integrated with the system

commit d18517a
Merge: 1ba0606 52cd1ae
Author: Chris Mahoney <[email protected]>
Date:   Fri Nov 8 23:22:45 2024 -0600

    Merge pull request stackblitz-labs#101 from ali00209/new_bolt1

    feat: add ability to enter API keys in the UI

commit 52cd1ae
Merge: 73a07c9 1ba0606
Author: Ali <[email protected]>
Date:   Sat Nov 9 09:59:21 2024 +0500

    Merge branch 'main' into new_bolt1

commit 73a07c9
Author: ali00209 <[email protected]>
Date:   Sat Nov 9 09:55:40 2024 +0500

    fix: Resolved

commit f9e750d
Merge: 73505a3 1ba0606
Author: Karrot <[email protected]>
Date:   Fri Nov 8 17:10:40 2024 -0500

    Merge branch 'main' into main

commit d1f3e8c
Author: Anirban Kar <[email protected]>
Date:   Fri Nov 8 21:47:31 2024 +0530

    feat: added bolt dedicated shell

commit 9b97837
Author: Tommy <[email protected]>
Date:   Fri Nov 8 08:51:22 2024 +0100

    Show which model name and provider is used in user message.

commit 54351cd
Author: Anirban Kar <[email protected]>
Date:   Fri Nov 8 11:14:15 2024 +0530

    feature(code-streaming): added code streaming to editor while AI is writing code

commit 1ba0606
Merge: 775283e dec6513
Author: Cole Medin <[email protected]>
Date:   Thu Nov 7 18:12:27 2024 -0600

    Merge pull request stackblitz-labs#209 from patrykwegrzyn/main

    feat: set numCtx = 32768 for Ollama models

commit dec6513
Author: Patryk Wegrzyn <[email protected]>
Date:   Thu Nov 7 23:51:12 2024 +0000

    Set numCtx = 32768 for Ollama models

commit bb0546d
Author: Anon <[email protected]>
Date:   Thu Nov 7 14:38:22 2024 +0100

    Added the latest Sonnet 3.5 and Haiku 3.5

commit 775283e
Merge: a6d81b1 8d7f108
Author: Cole Medin <[email protected]>
Date:   Thu Nov 7 06:29:01 2024 -0600

    Merge pull request stackblitz-labs#196 from milutinke/x-ai

    feat: added support for xAI Grok Beta

commit 8d7f108
Author: Anon <[email protected]>
Date:   Thu Nov 7 01:14:27 2024 +0100

    Added the XAI_API_KEY variable to the .env.example

commit 9a2fc92
Author: Anon <[email protected]>
Date:   Thu Nov 7 01:03:37 2024 +0100

    Added support for xAI Grok Beta

commit 73505a3
Merge: 27b6684 a6d81b1
Author: Karrot <[email protected]>
Date:   Wed Nov 6 15:52:24 2024 -0500

    Merge branch 'coleam00:main' into main

commit 2a362b9
Author: Tommy <[email protected]>
Date:   Wed Nov 6 21:35:54 2024 +0100

    Added sanitization for user messages.
    Use regex defined in constants.ts instead of redefining.

commit 074e2f3
Author: Tommy <[email protected]>
Date:   Wed Nov 6 11:10:08 2024 +0100

    Moved provider and setProvider variables to the higher level component so that it can be accessed in sendMessage.
    Added provider to message queue in sendMessage.
    Changed streamText to extract both model and provider.

commit 435d6b4
Author: Alexander Al-Bahrani <[email protected]>
Date:   Tue Nov 5 12:41:58 2024 +0100

    Update README.md changed .env to .env.local

    The installation description stated to create an .env file out of the .env.example
    This leads to an error when executing docker compose up since the docker-compose.yml expects the environment file being called .env.local

commit 27b6684
Merge: 449d0a3 e7ce257
Author: Karrot <[email protected]>
Date:   Sun Nov 3 16:21:16 2024 -0500

    Merge branch 'coleam00:main' into main

commit 449d0a3
Merge: 8dfc4f7 065be0f
Author: Karrot <[email protected]>
Date:   Wed Oct 30 14:52:23 2024 -0400

    Merge branch 'coleam00:main' into main

commit 8dfc4f7
Author: Karrot <[email protected]>
Date:   Wed Oct 30 13:05:57 2024 -0400

    Changed mode.ts to add BaseURL. Thanks @alumbs

commit 748e0d6
Author: Karrot <[email protected]>
Date:   Sun Oct 27 23:26:54 2024 -0400

    Remove Package-lock.json

commit 4edcc5e
Author: Karrot0 <[email protected]>
Date:   Sun Oct 27 23:16:07 2024 -0400

    LM Studio Integration
@mehmetsahin06
Copy link

mehmetsahin06 commented Nov 25, 2024

It seems that the message has "Provider" in it, and it needs to be removed

I completely overlooked that. I found the sanitize method for it and could fix it rather easily. Try the PR now.

Tried, and it works as expecms that the message has "Provider" in it, and it needs to be removed

I completely overlooked that. I found the sanitize method for it and could fix it rather easily. Try the PR now.

Tried, and it works as expected(no model name or provider name).

BUT, my suggestion would be to have it in the chat... It is nice and does not take space.

I would suggest that in https://github.com/coleam00/bolt.new-any-llm/pull/188/files#diff-dd246a18ac09a3e1a293988bf2f81b4f246f4c4aa03db23db48f79371c378981 I would probably have it in my version.

return content.replace(modificationsRegex, '').replace(MODEL_REGEX, '$1').replace(PROVIDER_REGEX, ' ($1)\n\n').trim();

could be better. I will allow the @coleam00 to make that decision.

image

how to use openai-like gpt-4o mini

@nandan-dhamma
Copy link

@mehmetsahin06 , it will be good if you can explain what you want to do, or are trying to do? And a copy of your constants.ts. Make sure you have the latest pull from github

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.

5 participants