Skip to content

Conversation

@mrubens
Copy link
Collaborator

@mrubens mrubens commented Mar 11, 2025

Context

Per #1549, we don't currently have a way for users to configure prompt caching for OpenAI-compatible providers.

Implementation

This PR adds a checkbox to enable prompt caching and input fields for the cache read/write prices.

Screenshots

before after
Screenshot 2025-03-11 at 12 47 17 AM Screenshot 2025-03-11 at 12 45 40 AM

How to Test

That I'm not sure about... @dleen would you be up for helping me figure out how to test this out?


Important

Adds prompt caching configuration for OpenAI-compatible models in ApiOptions.tsx, including UI elements for enabling caching and setting cache pricing.

  • Behavior:
    • Adds prompt caching configuration for OpenAI-compatible models in ApiOptions.tsx.
    • Introduces a checkbox to enable prompt caching and input fields for cache read/write prices.
  • UI Changes:
    • Updates ApiOptions.tsx to include new UI elements for prompt caching settings.
    • Adds tooltips for new fields to guide users on caching benefits and costs.

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

@changeset-bot
Copy link

changeset-bot bot commented Mar 11, 2025

🦋 Changeset detected

Latest commit: 4e6655b

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

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Mar 11, 2025
style={{ fontSize: "12px" }}
/>
</div>
<div className="text-sm text-vscode-descriptionForeground [pt">
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo detected in the className: "[pt" appears to be incomplete. Please correct it to the intended class (e.g., 'pt-...').

Suggested change
<div className="text-sm text-vscode-descriptionForeground [pt">
<div className="text-sm text-vscode-descriptionForeground pt-2">

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice catch!

}
type="text"
style={{
borderColor: (() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider extracting the repeated inline borderColor styling logic into a helper function to improve readability and maintainability.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@ellipsis-dev Show us the equivalent of this logic using cn instead of an inline style object.

Copy link
Contributor

Choose a reason for hiding this comment

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

@cte, I have addressed your comments in pull request #1563


You can configure Ellipsis to address comments with a direct commit or a side PR, see docs.

Copy link
Collaborator

@cte cte Mar 11, 2025

Choose a reason for hiding this comment

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

@mrubens - For reference, it (sort of) produced:

className={cn("w-full", {
  "border-vscode-input-border": !apiConfiguration?.openAiCustomModelInfo?.cacheWritesPrice && apiConfiguration?.openAiCustomModelInfo?.cacheWritesPrice !== 0,
  "border-vscode-charts-green": apiConfiguration?.openAiCustomModelInfo?.cacheWritesPrice >= 0,
  "border-vscode-errorForeground": apiConfiguration?.openAiCustomModelInfo?.cacheWritesPrice < 0,
})}

This is spot on, but pretty verbose. Might want to extract apiConfiguration?.openAiCustomModelInfo?.cacheWritesPrice into a local var.


return value >= 0
? "var(--vscode-charts-green)"
: "var(--vscode-errorForeground)"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this handling the case when cacheWritesPrice is negative? Do we need to handle this case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah... I basically just copied the inputs for the uncached inputs and outputs. Not sure it's necessary in either.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 11, 2025
@mrubens mrubens force-pushed the add_caching_to_open_ai_custom_model_info branch from e72aba6 to 4e6655b Compare March 11, 2025 04:59
ellipsis-dev bot added a commit that referenced this pull request Mar 11, 2025
}
type="text"
style={{
borderColor: (() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is repeated logic for computing the borderColor and for parsing numeric values in the cache price fields. Please consider extracting these into a helper function to reduce duplication and improve maintainability.

: "var(--vscode-errorForeground)"
})(),
}}
onChange={handleInputChange("openAiCustomModelInfo", (e) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Notice that the cache price text fields are using the onChange event, while other similar text inputs in the form use onInput. For consistency and predictable behavior across the form, please review whether onInput should be used instead.

Suggested change
onChange={handleInputChange("openAiCustomModelInfo", (e) => {
onInput={handleInputChange("openAiCustomModelInfo", (e) => {

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Pretty sure there was some reason we don't - based on them truncating decimal points too early or something.

@mrubens
Copy link
Collaborator Author

mrubens commented Mar 12, 2025

Covered by #1587, thanks @dleen!

@mrubens mrubens closed this Mar 12, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Mar 12, 2025
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.

3 participants