Skip to content

Conversation

@PeterDaveHello
Copy link
Contributor

@PeterDaveHello PeterDaveHello commented Apr 4, 2025

Context

Improve the logic for Gemini free request limits by moving the configuration from the UI to the centralized API. Previously, the limits (15 for flash models, 2 for others) were hardcoded in ModelInfoView, which reduced flexibility.

Implementation

  • Added a new freeRequestsRPM property to the ModelInfo schema.
  • Updated the geminiModels in src/shared/api.ts to include the appropriate freeRequestsRPM values (15 for flash models, 2 for others).
  • Modified ModelInfoView to read and display the freeRequestsRPM value from modelInfo.
  • This change centralizes the configuration logic, supporting easier updates and better handling of multiple Gemini models.

How to Test

I encountered issues running npm run build even for the main branch and could not test the changes. Please review and test the modifications.

My npm run build log:


> [email protected] build
> npm run vsix


> [email protected] vsix
> rimraf bin && mkdirp bin && npx vsce package --out bin

Executing prepublish script 'npm run vscode:prepublish'...

> [email protected] vscode:prepublish
> npm run package


> [email protected] package
> npm-run-all -l -p build:webview build:esbuild check-types lint

[check-types  ] 
[check-types  ] > [email protected] check-types
[check-types  ] > npm-run-all -l -p check-types:*
[check-types  ] 
[build:esbuild] 
[build:esbuild] > [email protected] build:esbuild
[build:esbuild] > node esbuild.js --production
[build:esbuild] 
[build:webview] 
[build:webview] > [email protected] build:webview
[build:webview] > cd webview-ui && npm run build
[build:webview] 
[lint         ] 
[lint         ] > [email protected] lint
[lint         ] > npm-run-all -l -p lint:*
[lint         ] 
[build:esbuild] [watch] build started
[build:webview] 
[build:webview] > [email protected] build
[build:webview] > npm-run-all -p tsc vite-build
[build:webview] 
[check-types  ] [check-types:webview  ] 
[check-types  ] [check-types:webview  ] > [email protected] check-types:webview
[check-types  ] [check-types:webview  ] > cd webview-ui && npm run check-types
[check-types  ] [check-types:webview  ] 
[lint         ] [lint:extension] 
[lint         ] [lint:extension] > [email protected] lint:extension
[lint         ] [lint:extension] > eslint src --ext ts
[lint         ] [lint:extension] 
[check-types  ] [check-types:extension] 
[check-types  ] [check-types:extension] > [email protected] check-types:extension
[check-types  ] [check-types:extension] > tsc --noEmit
[check-types  ] [check-types:extension] 
[lint         ] [lint:webview  ] 
[lint         ] [lint:webview  ] > [email protected] lint:webview
[lint         ] [lint:webview  ] > cd webview-ui && npm run lint
[lint         ] [lint:webview  ] 
[lint         ] [lint:e2e      ] 
[lint         ] [lint:e2e      ] > [email protected] lint:e2e
[lint         ] [lint:e2e      ] > cd e2e && npm run lint
[lint         ] [lint:e2e      ] 
[check-types  ] [check-types:e2e      ] 
[check-types  ] [check-types:e2e      ] > [email protected] check-types:e2e
[check-types  ] [check-types:e2e      ] > cd e2e && npm run check-types
[check-types  ] [check-types:e2e      ] 
[build:webview] 
[build:webview] > [email protected] vite-build
[build:webview] > vite build
[build:webview] 
[lint         ] [lint:e2e      ] 
[lint         ] [lint:e2e      ] > [email protected] lint
[lint         ] [lint:e2e      ] > eslint src --ext ts
[lint         ] [lint:e2e      ] 
[build:webview] 
[build:webview] > [email protected] tsc
[build:webview] > tsc -b
[build:webview] 
[lint         ] [lint:webview  ] 
[lint         ] [lint:webview  ] > [email protected] lint
[lint         ] [lint:webview  ] > eslint src --ext ts,tsx
[lint         ] [lint:webview  ] 
[check-types  ] [check-types:webview  ] 
[check-types  ] [check-types:webview  ] > [email protected] check-types
[check-types  ] [check-types:webview  ] > tsc
[check-types  ] [check-types:webview  ] 
[check-types  ] [check-types:e2e      ] 
[check-types  ] [check-types:e2e      ] > [email protected] check-types
[check-types  ] [check-types:e2e      ] > tsc --noEmit
[check-types  ] [check-types:e2e      ] 
[build:esbuild] Copied locale files to dist/i18n/locales
[build:esbuild] Copied locale files to out/i18n/locales
[build:esbuild] ✘ [ERROR] Could not resolve "./util"
[build:esbuild]     node_modules/bluebird/js/release/debuggability.js:6:19:
[build:esbuild] ✘ [ERROR] Could not resolve "./util"
[build:esbuild]     node_modules/bluebird/js/release/errors.js:4:19:
[build:esbuild] ✘ [ERROR] Could not resolve "./util"
[build:esbuild]     node_modules/bluebird/js/release/finally.js:3:19:
[build:esbuild] ✘ [ERROR] Could not resolve "./util"
[build:esbuild]     node_modules/bluebird/js/release/generators.js:10:19:
[build:esbuild] ✘ [ERROR] Could not resolve "./util"
[build:esbuild]     node_modules/bluebird/js/release/join.js:5:19:
[build:esbuild] ✘ [ERROR] Could not resolve "./util"
[build:esbuild]     node_modules/bluebird/js/release/method.js:4:19:
[build:esbuild] ✘ [ERROR] Could not resolve "./util"
[build:esbuild]     node_modules/bluebird/js/release/nodeback.js:2:19:
[build:esbuild] ✘ [ERROR] Could not resolve "./util"
[build:esbuild]     node_modules/bluebird/js/release/nodeify.js:3:19:
[build:esbuild] ✘ [ERROR] Could not resolve "./util"
[build:esbuild]     node_modules/bluebird/js/release/promise.js:14:19:
[build:esbuild] ✘ [ERROR] Could not resolve "./async"
[build:esbuild]     node_modules/bluebird/js/release/promise.js:31:20:
[build:esbuild] ✘ [ERROR] Could not resolve "./thenables"
[build:esbuild]     node_modules/bluebird/js/release/promise.js:45:34:
[build:esbuild] ✘ [ERROR] Could not resolve "./context"
[build:esbuild]     node_modules/bluebird/js/release/promise.js:49:22:
[build:esbuild] ✘ [ERROR] Could not resolve "./catch_filter"
[build:esbuild]     node_modules/bluebird/js/release/promise.js:56:26:
[build:esbuild] ✘ [ERROR] Could not resolve "./bind"
[build:esbuild]     node_modules/bluebird/js/release/promise.js:727:8:
[build:esbuild] ✘ [ERROR] Could not resolve "./cancel"
[build:esbuild]     node_modules/bluebird/js/release/promise.js:728:8:
[build:esbuild] ✘ [ERROR] Could not resolve "./synchronous_inspection"
[build:esbuild]     node_modules/bluebird/js/release/promise.js:730:8:
[build:esbuild] ✘ [ERROR] Could not resolve "./map.js"
[build:esbuild]     node_modules/bluebird/js/release/promise.js:735:8:
[build:esbuild] ✘ [ERROR] Could not resolve "./call_get.js"
[build:esbuild]     node_modules/bluebird/js/release/promise.js:736:8:
[build:esbuild] ✘ [ERROR] Could not resolve "./using.js"
[build:esbuild]     node_modules/bluebird/js/release/promise.js:737:8:
[build:esbuild] ✘ [ERROR] Could not resolve "./timers.js"
[build:esbuild]     node_modules/bluebird/js/release/promise.js:738:8:
[build:esbuild] ✘ [ERROR] Could not resolve "./settle.js"
[build:esbuild]     node_modules/bluebird/js/release/promise.js:745:8:
[build:esbuild] ✘ [ERROR] Could not resolve "./some.js"
[build:esbuild]     node_modules/bluebird/js/release/promise.js:746:8:
[build:esbuild] ✘ [ERROR] Could not resolve "./util"
[build:esbuild]     node_modules/bluebird/js/release/promise_array.js:4:19:
[build:esbuild] ✘ [ERROR] Could not resolve "./util"
[build:esbuild]     node_modules/bluebird/js/release/promisify.js:4:19:
[build:esbuild] ✘ [ERROR] Could not resolve "./util"
[build:esbuild]     node_modules/bluebird/js/release/props.js:4:19:
[build:esbuild] ✘ [ERROR] Could not resolve "./util"
[build:esbuild]     node_modules/bluebird/js/release/race.js:4:19:
[build:esbuild] ✘ [ERROR] Could not resolve "./pdf.worker.js"
[build:esbuild]     node_modules/pdf-parse/lib/pdf.js/v1.10.100/build/pdf.js:3345:23:
[build:esbuild] [watch] build finished
[build:esbuild] Error: Build failed with 27 errors:
[build:esbuild] node_modules/bluebird/js/release/debuggability.js:6:19: ERROR: Could not resolve "./util"
[build:esbuild] node_modules/bluebird/js/release/errors.js:4:19: ERROR: Could not resolve "./util"
[build:esbuild] node_modules/bluebird/js/release/finally.js:3:19: ERROR: Could not resolve "./util"
[build:esbuild] node_modules/bluebird/js/release/generators.js:10:19: ERROR: Could not resolve "./util"
[build:esbuild] node_modules/bluebird/js/release/join.js:5:19: ERROR: Could not resolve "./util"
[build:esbuild] ...
[build:esbuild]     at failureErrorWithLog (/home/peter/repos/Roo-Code/node_modules/esbuild/lib/main.js:1476:15)
[build:esbuild]     at /home/peter/repos/Roo-Code/node_modules/esbuild/lib/main.js:945:25
[build:esbuild]     at /home/peter/repos/Roo-Code/node_modules/esbuild/lib/main.js:1354:9
[build:esbuild]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
[build:esbuild]   errors: [Getter/Setter],
[build:esbuild]   warnings: [Getter/Setter]
[build:esbuild] }
[build:webview] vite v6.0.11 building for production...
ERROR: "build:esbuild" exited with 1.
 ERROR  npm failed with exit code 1
peter@cleanup ~/repos/Roo-Code $ [04/0

Important

Centralizes Gemini free request limits by adding freeRequestsRpm to the API and updating the UI to use this centralized configuration.

  • Behavior:
    • Adds freeRequestsRpm to ModelInfo schema in index.ts.
    • Updates geminiModels in api.ts to include freeRequestsRpm values (15 for flash models, 2 for others).
    • Modifies ModelInfoView in ModelInfoView.tsx to display freeRequestsRpm from modelInfo.
  • Types:
    • Adds freeRequestsRpm to ProviderSettings in roo-code.d.ts and types.ts.
  • Misc:
    • Centralizes configuration logic for easier updates and better handling of multiple Gemini models.

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

Refactor the handling of Gemini free request limits (RPM) to be
data-driven instead of hardcoded in the UI. Limits are now defined
per-model within `geminiModels` in `src/shared/api.ts` using the new
`freeRequestsRpm` property in the `ModelInfo` schema.

This centralizes the configuration logic, enhancing maintainability and
flexibility to support varying limits across different Gemini models,
resolving the previous inflexibility where limits were determined by
string matching in `ModelInfoView`.
@changeset-bot
Copy link

changeset-bot bot commented Apr 4, 2025

⚠️ No Changeset found

Latest commit: 59538d1

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 the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 4, 2025
<VSCodeLink href="https://ai.google.dev/pricing" className="text-sm">
{t("settings:modelInfo.gemini.pricingDetails")}
</VSCodeLink>
: modelInfo.freeRequestsRpm && modelInfo.freeRequestsRpm > 0
Copy link
Contributor

Choose a reason for hiding this comment

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

The repeated condition modelInfo.freeRequestsRpm && modelInfo.freeRequestsRpm > 0 is used twice. Consider extracting it into a variable (e.g. const hasFreeRequests = modelInfo.freeRequestsRpm > 0) to improve readability and avoid potential repetition errors.

@dosubot dosubot bot added the enhancement New feature or request label Apr 4, 2025
@PeterDaveHello
Copy link
Contributor Author

@mrubens Could you lend me a hand here, please?

@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap Apr 6, 2025
@PeterDaveHello
Copy link
Contributor Author

Ping @cte @mrubens

@github-project-automation github-project-automation bot moved this from PR [Pre Approval Review] to Done in Roo Code Roadmap Apr 30, 2025
@mrubens
Copy link
Collaborator

mrubens commented Apr 30, 2025

Sorry I haven't gotten to this one yet - have been swamped with all things Gemini (particularly caching). Still on my list to take a look. As always, your contributions are greatly appreciated.

@PeterDaveHello
Copy link
Contributor Author

@mrubens, since the PR hasn't been reviewed for a while, there have been a few code base conflicts. If it's more convenient, I can update or rewrite the code once reviewers are available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants