Improve logic for Gemini free request limits#2303
Improve logic for Gemini free request limits#2303PeterDaveHello wants to merge 1 commit intoRooCodeInc:mainfrom
Conversation
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`.
|
| <VSCodeLink href="https://ai.google.dev/pricing" className="text-sm"> | ||
| {t("settings:modelInfo.gemini.pricingDetails")} | ||
| </VSCodeLink> | ||
| : modelInfo.freeRequestsRpm && modelInfo.freeRequestsRpm > 0 |
There was a problem hiding this comment.
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.
|
@mrubens Could you lend me a hand here, please? |
|
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. |
|
@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. |
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
freeRequestsRPMproperty to the ModelInfo schema.geminiModelsinsrc/shared/api.tsto include the appropriate freeRequestsRPM values (15 for flash models, 2 for others).How to Test
I encountered issues running
npm run buildeven for the main branch and could not test the changes. Please review and test the modifications.My
npm run buildlog:Important
Centralizes Gemini free request limits by adding
freeRequestsRpmto the API and updating the UI to use this centralized configuration.freeRequestsRpmtoModelInfoschema inindex.ts.geminiModelsinapi.tsto includefreeRequestsRpmvalues (15 for flash models, 2 for others).ModelInfoViewinModelInfoView.tsxto displayfreeRequestsRpmfrommodelInfo.freeRequestsRpmtoProviderSettingsinroo-code.d.tsandtypes.ts.This description was created by
for 59538d1. It will automatically update as commits are pushed.