Skip to content

feat: Add Groq and Chutes API providers #3034

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

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

Conversation

shariqriazz
Copy link

@shariqriazz shariqriazz commented Apr 29, 2025

Context

This PR introduces support for two new API providers, Groq and Chutes AI. It also fixes a UI bug where the settings labels for these new providers were displaying raw translation keys instead of the intended user-friendly text.

Implementation

  1. Provider Implementation:
    • Added new provider classes (groq.ts, chutes.ts) in src/api/providers/ implementing the necessary logic to interact with their respective APIs.
    • Included corresponding unit tests (groq.test.ts, chutes.test.ts) to ensure provider functionality.
  2. Integration:
    • Updated src/api/index.ts to register the new providers.
    • Modified src/exports/api.ts, src/exports/types.ts, src/exports/roo-code.d.ts, src/schemas/index.ts, and src/shared/api.ts to include types, schemas, and constants related to Groq and Chutes.
  3. UI Updates:
    • Modified webview-ui/src/components/settings/ApiOptions.tsx to render the appropriate settings fields (API key input, model selection dropdown) when Groq or Chutes AI is selected.
    • Updated related constants and hooks (constants.ts, useSelectedModel.ts) in the webview-ui directory.
  4. Translation Fix:
    • Identified that the UI bug was caused by missing translation keys in webview-ui/src/i18n/locales/en/settings.json.
    • Added the necessary keys (providers.groqApiKey, providers.getGroqApiKey, providers.chutesApiKey) to the English settings file.
    • Synchronized these new keys by adding translations to the settings.json files for all other supported languages (ca, de, es, fr, hi, it, ja, ko, pl, pt-BR, ru, tr, vi, zh-CN, zh-TW) within webview-ui/src/i18n/locales/.
    • Removed redundant Groq translation keys found in src/i18n/locales/en/common.json to maintain consistency.
    • Verified translation completeness using the find-missing-translations.js script.

How to Test

  1. Build and run the extension from the add-groq-chutes-provider branch.
  2. Open the Roo Code extension view.
  3. Navigate to the Settings panel.
  4. In the "Providers" section, select "Groq" from the "API Provider" dropdown.
  5. Verify: The label for the API key input field reads "Groq API Key" and the button below it reads "Get Groq API Key".
  6. Select "Chutes AI" from the "API Provider" dropdown.
  7. Verify: The label for the API key input field reads "Chutes API Key".
  8. (Optional) Change the VS Code display language to another supported language (e.g., Spanish, French).
  9. Re-open the Roo Code settings panel and check the labels for Groq and Chutes AI again to ensure they are correctly translated.

Get in Touch

gawdofai on Discord.


Important

This PR adds support for Groq and Chutes API providers, updates UI components, and fixes translation key issues.

  • API Providers:
    • Added GroqHandler in groq.ts and ChutesHandler in chutes.ts to support Groq and Chutes APIs.
    • Updated index.ts to register new providers.
    • Added unit tests in groq.test.ts and chutes.test.ts.
  • Integration:
    • Updated api.ts, types.ts, roo-code.d.ts, schemas/index.ts, and shared/api.ts for new provider types and schemas.
  • UI Updates:
    • Modified ApiOptions.tsx to include settings for Groq and Chutes.
    • Updated constants.ts and useSelectedModel.ts for new providers.
  • Translation Fix:
    • Added missing translation keys for Groq and Chutes in settings.json across multiple languages.
    • Removed redundant keys from common.json.
    • Verified translations with find-missing-translations.js.

This description was created by Ellipsis for 181e070. You can customize this summary. It will automatically update as commits are pushed.

- Implemented provider logic for Groq and Chutes in `src/api/providers/`.
- Added corresponding unit tests.
- Integrated providers into the API index, exports, schemas, and types.
- Updated `ApiOptions.tsx` and related constants/hooks in `webview-ui` to display settings for Groq and Chutes.
- Added missing translation keys for Groq and Chutes settings labels to `webview-ui/src/i18n/locales/en/settings.json`.
- Synchronized new translation keys across all other supported languages in `webview-ui`.
- Removed redundant Groq translation keys from `src/i18n/locales/en/common.json`.

Fixes UI bug where raw translation keys were displayed for Groq/Chutes settings.
Copy link

changeset-bot bot commented Apr 29, 2025

⚠️ No Changeset found

Latest commit: 4686a83

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. bug Something isn't working enhancement New feature or request labels Apr 29, 2025
const GROQ_DEFAULT_TEMPERATURE = 0.5 // Adjusted default temperature for Groq (common default)

// Renamed class to GroqHandler
export class GroqHandler extends BaseProvider implements SingleCompletionHandler {
Copy link

Choose a reason for hiding this comment

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

This handler is functionally identical to ChutesHandler. Consider creating a shared base class for OpenAI-compatible providers to avoid duplication.

This comment was generated because it violated the following rules: mrule_fYE6mUdYYxZL58YF and mrule_htmKIslKUiIk1Afo.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is a great suggestion; let's do this. Check out what I did with https://github.com/RooVetGit/Roo-Code/blob/main/src/api/providers/router-provider.ts.

"deepSeekApiKey": "DeepSeek API 密钥",
"getDeepSeekApiKey": "获取 DeepSeek API 密钥",
"geminiApiKey": "Gemini API 密钥",
"getGroqApiKey": "获取 Groq API 密钥",
Copy link

Choose a reason for hiding this comment

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

For consistency with other API providers (e.g., Gemini, Anthropic, DeepSeek), the key order for Groq API should mirror that pattern. Swap 'getGroqApiKey' and 'groqApiKey' so that 'groqApiKey' appears before 'getGroqApiKey'.

Copy link

ellipsis-dev bot commented Apr 29, 2025

The pull request introduces Groq and Chutes API providers, with changes across multiple files including API handlers, tests, localization, and UI components. Given the size and scope of the changes (44 files changed, 1390 lines added), it might be beneficial to split the pull request into smaller, more focused ones.

Consider splitting the changes as follows:

  1. API Integration: Separate the addition of Groq and Chutes handlers and related API configurations into one pull request.
  2. Testing: Create a separate pull request for the unit tests related to Groq and Chutes handlers.
  3. Localization: Group all localization changes into another pull request.
  4. UI Components: Separate the UI updates related to Groq and Chutes API options into a distinct pull request.

This approach can help in reviewing and testing the changes more effectively. Let me know if you have any questions or need further assistance!

@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
Status: PR [Pre Approval Review]
Development

Successfully merging this pull request may close these issues.

2 participants