Skip to content

feat Api Config manager#240

Closed
samhvw8 wants to merge 12 commits intoRooCodeInc:mainfrom
samhvw8:feat/keep-multiple-config
Closed

feat Api Config manager#240
samhvw8 wants to merge 12 commits intoRooCodeInc:mainfrom
samhvw8:feat/keep-multiple-config

Conversation

@samhvw8
Copy link
Contributor

@samhvw8 samhvw8 commented Dec 29, 2024

Description

New Feature that can make user can able to create and use multiple Api configuration

image

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Checklist:

  • My code follows the patterns of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Additional context

Related Issues

Reviewers


Important

Adds multi-API configuration management with UI support and tests.

  • Behavior:
    • Introduces ConfigManager class in ConfigManager.ts for managing multiple API configurations.
    • Supports creating, renaming, deleting, and selecting API configurations.
    • Updates ClineProvider.ts to handle new API configuration messages and manage state.
  • UI:
    • Adds ApiConfigManager.tsx for managing API configurations in the UI.
    • Updates SettingsView.tsx to integrate ApiConfigManager and handle configuration changes.
  • Tests:
    • Adds tests in ConfigManager.test.ts for ConfigManager functionalities.
    • Updates SettingsView.test.tsx to test new UI components and interactions.
  • Misc:
    • Adds checkExistApiConfig.ts utility for checking existing API keys.

This description was created by Ellipsis for fbdbd39a2c3538c8c4075f5038e877eea03108f0. It will automatically update as commits are pushed.

@changeset-bot
Copy link

changeset-bot bot commented Dec 29, 2024

🦋 Changeset detected

Latest commit: 7431e42

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
roo-cline Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using async/await instead of .then() for better readability and maintainability, as per our Development Standards: https://www.notion.so/Development-Standards-59febcf8ead647fd9c2ec3f60c22f3df?pvs=4#11869ad2d581809f9af3fdba09412ef6

@samhvw8 samhvw8 changed the title feat Api Configmanager feat Api Config manager Dec 29, 2024
@samhvw8 samhvw8 force-pushed the feat/keep-multiple-config branch 2 times, most recently from 1361179 to fcc1c6f Compare January 1, 2025 11:00
@samhvw8
Copy link
Contributor Author

samhvw8 commented Jan 1, 2025

Hi @mrubens! I'd value your review feedback. Let me know if you need any clarification, additional tests, or documentation updates to help move this forward. Thanks!"

@mrubens
Copy link
Collaborator

mrubens commented Jan 1, 2025

Hi @mrubens! I'd value your review feedback. Let me know if you need any clarification, additional tests, or documentation updates to help move this forward. Thanks!"

Thanks - sorry for the delay! Will try to look today or tomorrow.

@vamshiaruru
Copy link

Just chiming here to say that this would be so incredibly useful to me. I frequently want to switch between deepseek and gemini and claude based on the problems I'm solving and right now it is so cumbersome that I use aider for it instead. Thanks a lot for implementing this.

@samhvw8 samhvw8 force-pushed the feat/keep-multiple-config branch from fcc1c6f to 895fbc8 Compare January 2, 2025 03:09
@mrubens
Copy link
Collaborator

mrubens commented Jan 2, 2025

Hey @samhvw8 and @vamshiaruru, I want to make sure that I'm clearly understanding the problem that this is solving for you, versus just using the existing API Provider dropdown to switch between providers. Is it that you have multiple keys for a specific provider? Or that you want to switch between multiple different OpenAI compatible providers for instance?

@samhvw8 one thing on the implementation - I don't love storing the keys in plaintext in the config file. Would there be a way to continue to use the SecretStorage for this?

And only somewhat related to this PR - I've been thinking about how we might get more flexible on the API configuration to support chat modes with different models like aider does. I don't think it's exactly the same problem this is solving, but would be curious to hear your perpectives if you are aider users.

@samhvw8
Copy link
Contributor Author

samhvw8 commented Jan 2, 2025

Hi @mrubens, thanks for your reply

Hey @samhvw8 and @vamshiaruru, I want to make sure that I'm clearly understanding the problem that this is solving for you, versus just using the existing API Provider dropdown to switch between providers.
Is it that you have multiple keys for a specific provider?
Or that you want to switch between multiple different OpenAI compatible providers for instance?

Yes, my use case can be both scenarios. Since I currently don't have a company, I cannot upgrade my tier in Anthropic and am limited to tier 1. This is why I need to create 2 keys for that provider.

Additionally, some providers aren't yet supported in cline & roo-cline, so I need to switch between them. It's quite tedious to switch manually by copying URLs and API keys.

@samhvw8 one thing on the implementation - I don't love storing the keys in plaintext in the config file. Would there be a way to continue to use the SecretStorage for this?

Regarding the implementation - I understand your concern about storing keys in plaintext in the config file. I will look for a way to implement it with SecretStorage. In my case, since I want to sync configs across development environments, we could use encrypted text files with the secret key stored in SecretStorage.

And only somewhat related to this PR - I've been thinking about how we might get more flexible on the API configuration to support chat modes with different models like aider does. I don't think it's exactly the same problem this is solving, but would be curious to hear your perpectives if you are aider users.

Yes, I share the same idea on making it more flexible to support chat modes with different models like aider does. If we store configurations this way, we can have multiple AI agents, each with its separate API handler, similar to aider's approach

@CaiJingLong
Copy link

CaiJingLong commented Jan 2, 2025

@mrubens
Due to cost and regional reasons, I am currently using several different APIs, each with its unique API response structure. In most cases, it's not feasible to create distinct providers for every API vendor individually. Fortunately, almost all of them offer extra OpenAI-compatible options.

This has led to the following situation: other providers can work with dedicated integrations, but OpenAI-compatible providers are insufficient. I would prefer not to have to modify the base API URL and API key every time I want to use a different model.

Currently, my approach is that Cline uses one setup, while Roo-Cline uses another.

For example, I am currently using x.ai, deepseek, GitHub models, and Zhipu in Lobehub, all of which provide OpenAI v1-compatible structures. I am currently using Lobehub, which offers dozens of OpenAI-compatible model providers.
However, since we already know it is OpenAI API compatible, there is no need to provide so many dropdown options like it does. Instead, we only need to allow users to customize multiple OpenAI-compatible models.

I believe the content of this PR is exactly what I need.

@mrubens
Copy link
Collaborator

mrubens commented Jan 2, 2025

Thanks for explaining! What I'm mulling over is the alternative approach of:

  1. Allowing for multiple saved/named OpenAI-compatible providers
  2. Allowing for multiple keys to be added to each provider, and automatically rotated on rate limiting errors

I'm wondering if supporting these two scenarios more directly will be more intuitive to people and potentially doable with more localized code changes to avoid too much drift from mainline Cline. I think I need to sleep on it though. Feedback welcome in the meantime!

@vamshiaruru
Copy link

@mrubens In my case, I had multiple open ai compatible providers. I had gemini and deepseek both under open ai compatile providers, so switching was hard. Now however both gemini and deepseek have their own support, so I can switch between them easily enough :D

@mrubens
Copy link
Collaborator

mrubens commented Jan 4, 2025

Hi @mrubens, thanks for your reply

Hey @samhvw8 and @vamshiaruru, I want to make sure that I'm clearly understanding the problem that this is solving for you, versus just using the existing API Provider dropdown to switch between providers.
Is it that you have multiple keys for a specific provider?
Or that you want to switch between multiple different OpenAI compatible providers for instance?

Yes, my use case can be both scenarios. Since I currently don't have a company, I cannot upgrade my tier in Anthropic and am limited to tier 1. This is why I need to create 2 keys for that provider.

Additionally, some providers aren't yet supported in cline & roo-cline, so I need to switch between them. It's quite tedious to switch manually by copying URLs and API keys.

@samhvw8 one thing on the implementation - I don't love storing the keys in plaintext in the config file. Would there be a way to continue to use the SecretStorage for this?

Regarding the implementation - I understand your concern about storing keys in plaintext in the config file. I will look for a way to implement it with SecretStorage. In my case, since I want to sync configs across development environments, we could use encrypted text files with the secret key stored in SecretStorage.

And only somewhat related to this PR - I've been thinking about how we might get more flexible on the API configuration to support chat modes with different models like aider does. I don't think it's exactly the same problem this is solving, but would be curious to hear your perpectives if you are aider users.

Yes, I share the same idea on making it more flexible to support chat modes with different models like aider does. If we store configurations this way, we can have multiple AI agents, each with its separate API handler, similar to aider's approach

Hi @samhvw8, the more I think about it the more I like this approach. Do you have any more thoughts on how we can make the secret store work?

@samhvw8
Copy link
Contributor Author

samhvw8 commented Jan 4, 2025

Hi @samhvw8, the more I think about it the more I like this approach. Do you have any more thoughts on how we can make the secret store work?

Hi @mrubens,
I have some ideas about how to do that with secret store. I will try to implement it and push it tomorrow.
Currently, I have a version that saves files using password encryption. (Link below)

samhvw8@6328a0b#diff-b1440b9122103144a2cbb75b7f08b0e9bf6c2542d8d91a60796bbf68076ba150

@samhvw8 samhvw8 force-pushed the feat/keep-multiple-config branch from 7d23530 to ad9d117 Compare January 4, 2025 17:44
@samhvw8
Copy link
Contributor Author

samhvw8 commented Jan 4, 2025

Hi @mrubens,

I have already pushed the config manager implementation using secrets. I implemented it faster than expected. Could you review it for me?.

Thanks

@samhvw8 samhvw8 force-pushed the feat/keep-multiple-config branch 2 times, most recently from 16349a0 to de2c782 Compare January 4, 2025 17:52
@mrubens
Copy link
Collaborator

mrubens commented Jan 4, 2025

Hi @mrubens,

I have already pushed the config manager implementation using secrets. I implemented it faster than expected. Could you review it for me?.

Thanks

Awesome! I’m traveling today but will review as soon as I can.

@samhvw8
Copy link
Contributor Author

samhvw8 commented Jan 4, 2025

Hi @mrubens,
I have already pushed the config manager implementation using secrets. I implemented it faster than expected. Could you review it for me?.
Thanks

Awesome! I’m traveling today but will review as soon as I can.

Thanks for letting me know! Safe travels, and take your time reviewing when you're back.

@samhvw8 samhvw8 force-pushed the feat/keep-multiple-config branch 4 times, most recently from 1ba6fb6 to 3be9e0e Compare January 7, 2025 17:34
samhvw8 and others added 8 commits January 7, 2025 20:09
Added useEffect hooks to GlamaModelPicker, OpenAiModelPicker, and OpenRouterModelPicker components to ensure the search term stays synchronized with the selected model ID from apiConfiguration. This prevents the search term from getting out of sync when the model is changed.
mrubens and others added 3 commits January 7, 2025 22:31
- Move handleSave to useCallback for better performance
- Add cleanup effect to save pending changes on unmount
- Improve new config UX by setting default copy name
- Fix code formatting
@samhvw8 samhvw8 force-pushed the feat/keep-multiple-config branch from 3e06c49 to 7431e42 Compare January 8, 2025 04:42
@mrubens
Copy link
Collaborator

mrubens commented Jan 9, 2025

Going to close this now that #297 was merged. Thank you for the contributions! 🙌

@mrubens mrubens closed this Jan 9, 2025
@samhvw8 samhvw8 deleted the feat/keep-multiple-config branch January 10, 2025 03:30
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