Skip to content

Conversation

@mrubens
Copy link
Collaborator

@mrubens mrubens commented Apr 30, 2025

Screenshot 2025-04-30 at 9 19 11 AM

Screenshot 2025-04-30 at 9 19 27 AM


Important

This PR adds customizable headers for the OpenAI-compatible provider, allowing users to specify additional headers for API requests, with updates to configuration, UI, and localization.

  • Behavior:
    • Adds support for customizable headers in openai.ts by allowing users to specify additional headers for OpenAI API requests.
    • Updates getOpenAiModels() to accept openAiHeaders instead of hostHeader.
  • Configuration:
    • Ensures openAiHeaders is always an object in ContextProxy.ts for proper serialization.
    • Adds migration for openAiHeaders in ProviderSettingsManager.ts to handle legacy openAiHostHeader.
  • UI:
    • Updates ApiOptions.tsx to allow users to add, edit, and remove custom headers.
    • Adds localization for custom headers in multiple language files.
  • Misc:
    • Removes openAiHostHeader from types.ts and roo-code.d.ts.

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

@mrubens
Copy link
Collaborator Author

mrubens commented Apr 30, 2025

@ellipsis-agent please review

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to 38aeaa48871a08596f968124afd8347d1ba988e4 in 1 minute and 37 seconds. Click for details.
  • Reviewed 515 lines of code in 9 files
  • Skipped 0 files when reviewing.
  • Skipped posting 11 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. webview-ui/src/i18n/locales/en/settings.json:468
  • Draft comment:
    Good comprehensive localization file. The new keys for customizable headers (e.g. 'add', 'remove', 'headerName', and 'headerValue') are clear. Please double-check consistency in naming: for example, the pricing placeholder key is 'cacheWritePrice' (line 489) while the schema uses 'cacheWritesPrice'. Consistent naming will avoid confusion when integrating these values.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
2. webview-ui/src/i18n/locales/en/settings.json:8
  • Draft comment:
    The addition of the 'add' and 'remove' keys under 'common' is clear and consistent with other UI labels. Nice job updating these for custom header functionality.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 70% None
3. webview-ui/src/i18n/locales/en/settings.json:488
  • Draft comment:
    In the 'placeholders' > 'numbers' section, 'cacheWritePrice' is used while elsewhere 'cacheWritesPrice' is used. Consider renaming for consistency.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
4. webview-ui/src/i18n/locales/en/settings.json:152
  • Draft comment:
    The documentation instructions for 'googleCloudSetup' and provider routing under 'openRouter' are clear and user-friendly. Ensure consistency in punctuation and capitalization.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 70% None
5. src/api/providers/openai.ts:211
  • Draft comment:
    Typo: In the comment, "doesnt" should be "doesn't" to maintain correct English punctuation.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
6. src/exports/roo-code.d.ts:43
  • Draft comment:
    Typo: Consider renaming 'awspromptCacheId' to 'awsPromptCacheId' for consistency with camelCase style.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
7. src/exports/roo-code.d.ts:114
  • Draft comment:
    Typo: The property 'mistralCodestralUrl' appears unusual. Please verify if it should be renamed (e.g., 'mistralApiUrl' or another intended name) to maintain naming consistency.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
8. src/exports/roo-code.d.ts:300
  • Draft comment:
    Typo: The type 'ClineMessage' might be a misspelling. If the intended name is 'ClientMessage', please update it for clarity.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
9. src/exports/types.ts:115
  • Draft comment:
    The property name 'mistralCodestralUrl' at line 115 may contain a typographical error. Please double-check if it is meant to be something like 'mistralCustomUrl' or similar.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
10. src/exports/types.ts:305
  • Draft comment:
    The type name 'ClineMessage' on line 305 looks like it might be a typographical error. Consider renaming it to 'ClientMessage' if that is what was intended.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
11. src/schemas/index.ts:1
  • Draft comment:
    Typo: The word 'propgate' in the header comment should be corrected to 'propagate'.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_B2NJthDOTPxCgTUs

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@mrubens mrubens force-pushed the open_ai_compatible_custom_headers branch 2 times, most recently from a5cd77f to 1d2c804 Compare April 30, 2025 15:27
@changeset-bot
Copy link

changeset-bot bot commented Apr 30, 2025

⚠️ No Changeset found

Latest commit: c760373

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

@mrubens mrubens marked this pull request as ready for review April 30, 2025 21:28
@mrubens mrubens requested a review from cte as a code owner April 30, 2025 21:28
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Apr 30, 2025
@ellipsis-dev
Copy link
Contributor

ellipsis-dev bot commented Apr 30, 2025

The pull request includes a variety of changes, such as enabling customizable headers for the OpenAI provider and updating translations in multiple locales. To make the review process more efficient, consider splitting the localization updates into a separate pull request, as they are likely independent of the core feature changes. This will help reviewers focus on the specific changes related to the OpenAI provider without being distracted by unrelated localization updates.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 30, 2025
@mrubens mrubens force-pushed the open_ai_compatible_custom_headers branch 4 times, most recently from 6756c46 to 8d1f0f0 Compare April 30, 2025 21:59
@sachasayan
Copy link
Contributor

Key values brittle.

Using a key-value store for this seems a bit... brittle? Lines ~880 reads a new value, checks for changes, destructures the old key out, spreads the rest, and adds the new key with the old value back in – all within the onInput handler, and within the template.

  • Could/should an array of tuples (or object-as-tuple) be used instead, so rocket surgery isn't be done on objects in-template?
  • Could/should the logic be broken out of the template? Feels like a function could handle this better, perhaps a unified one for making updates to keys/values.

Weirdness when keys are unset / overlap

This isn't a huge deal, but things get weird if you unset a key then change the value, or try to add a new value, since you no longer have a key. Things also get weird if you have a key called, say, "cache" and try to add another called "cacheExpiry" — halfway through, the two will overlap on key names and one will nuke the other.

Just OpenAI-compatible?

Should this show up for OpenAI as well? Or just OpenAI-compatible? (I'm assuming this is just because some OAI-compatible APIs have extended/custom header options?)

General notes

I'll run a design review and refactor on ApiOptions.tsx once this is merged. This file is unwieldy and could be split up, namely the providers should each be their own file (or perhaps composable blocks).

It also could use a Shadcn migration and a pull away from direct references to cssv ars and style tags. Again, I'll handle this. Let's get the PR in first.

@mrubens
Copy link
Collaborator Author

mrubens commented May 1, 2025

Ahh good catch on the overlap! Will fix

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 a properly typed event (e.g. React.ChangeEvent<HTMLInputElement>) instead of any in the onInput handlers. This improves type safety and adheres to best practices.

Suggested change
onInput={(e: any) => handleUpdateHeaderKey(index, e.target.value)}
onInput={(e: React.ChangeEvent<HTMLInputElement>) => handleUpdateHeaderKey(index, e.target.value)}

This comment was generated because it violated a code review rule: mrule_QkEwsCio7v34DaCF.

@mrubens mrubens force-pushed the open_ai_compatible_custom_headers branch from 0801398 to e5ad879 Compare May 1, 2025 03:04
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap May 1, 2025
@mrubens mrubens merged commit a356d70 into main May 2, 2025
12 checks passed
@mrubens mrubens deleted the open_ai_compatible_custom_headers branch May 2, 2025 03:30
@github-project-automation github-project-automation bot moved this from PR [Pre Approval Review] to Done in Roo Code Roadmap May 2, 2025
@mark-bradshaw
Copy link

Thanks for the quick turn around Matt. It's working great.

@mark-bradshaw
Copy link

Spoke too soon I guess. I just now realized the custom headers aren't being saved. I added them and saved, but it didn't actually store them. When I go back in they are missing and they aren't taking effect it appears.

@mrubens
Copy link
Collaborator Author

mrubens commented May 9, 2025

Ugh, sorry about this - looking into it now.

@mrubens
Copy link
Collaborator Author

mrubens commented May 9, 2025

#3415

mehmetsunkur pushed a commit to mehmetsunkur/Roo-Code that referenced this pull request May 16, 2025
)

* Customizable headers for the OpenAI-compatible provider

* PR feedback

* Fix migration

* Update webview-ui/src/components/settings/ApiOptions.tsx

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants