Skip to content

Commit 16c40ef

Browse files
authored
Merge pull request #2849 from Ralph-Abejuela/RateLimitMinorFix
Minor fix: Respect rate limit specified in the kilo code settings
2 parents e645f41 + 038ddbd commit 16c40ef

File tree

27 files changed

+144
-0
lines changed

27 files changed

+144
-0
lines changed

.changeset/gentle-kangaroos-do.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"kilo-code": patch
3+
---
4+
5+
Added option to start rate limiting after the API stream ends

packages/types/src/provider-settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ const baseProviderSettingsSchema = z.object({
187187
fuzzyMatchThreshold: z.number().optional(),
188188
modelTemperature: z.number().nullish(),
189189
rateLimitSeconds: z.number().optional(),
190+
rateLimitAfter: z.boolean().optional(), // kilocode_change
190191
consecutiveMistakeLimit: z.number().min(0).optional(),
191192

192193
// Model reasoning.

src/core/task/Task.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3145,6 +3145,12 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
31453145
// effectively passes along all subsequent chunks from the original
31463146
// stream.
31473147
yield* iterator
3148+
3149+
// kilocode_change start
3150+
if (apiConfiguration?.rateLimitAfter) {
3151+
Task.lastGlobalApiRequestTime = performance.now()
3152+
}
3153+
// kilocode_change end
31483154
}
31493155

31503156
// Checkpoints

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ import { BedrockCustomArn } from "./providers/BedrockCustomArn"
126126
import { KiloCode } from "../kilocode/settings/providers/KiloCode" // kilocode_change
127127
import { buildDocLink } from "@src/utils/docLinks"
128128
import { KiloProviderRouting, KiloProviderRoutingManagedByOrganization } from "./providers/KiloProviderRouting"
129+
import { RateLimitAfterControl } from "./RateLimitAfterSettings" // kilocode_change
129130

130131
export interface ApiOptionsProps {
131132
uriScheme: string | undefined
@@ -920,6 +921,14 @@ const ApiOptions = ({
920921
maxValue={2}
921922
/>
922923
)}
924+
{
925+
// kilocode_change start
926+
<RateLimitAfterControl
927+
rateLimitAfterEnabled={apiConfiguration.rateLimitAfter}
928+
onChange={(field, value) => setApiConfigurationField(field, value)}
929+
/>
930+
// kilocode_change end
931+
}
923932
<RateLimitSecondsControl
924933
value={apiConfiguration.rateLimitSeconds || 0}
925934
onChange={(value) => setApiConfigurationField("rateLimitSeconds", value)}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// kilocode_change - file added
2+
import { useAppTranslation } from "@/i18n/TranslationContext"
3+
import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react"
4+
import { useCallback } from "react"
5+
6+
interface RateLimitAfterControlProps {
7+
rateLimitAfterEnabled?: boolean
8+
onChange: (field: "rateLimitAfter", value: any) => void
9+
}
10+
11+
export const RateLimitAfterControl: React.FC<RateLimitAfterControlProps> = ({
12+
rateLimitAfterEnabled = false,
13+
onChange,
14+
}) => {
15+
const { t } = useAppTranslation()
16+
17+
const handleTodoListEnabledChange = useCallback(
18+
(e: any) => {
19+
onChange("rateLimitAfter", e.target.checked)
20+
},
21+
[onChange],
22+
)
23+
return (
24+
<div className="flex flex-col gap-1">
25+
<div>
26+
<VSCodeCheckbox checked={rateLimitAfterEnabled} onChange={handleTodoListEnabledChange}>
27+
<span className="font-medium">{t("settings:providers.rateLimitAfter.label")}</span>
28+
</VSCodeCheckbox>
29+
<div className="text-vscode-descriptionForeground text-sm">
30+
{t("settings:providers.rateLimitAfter.description")}
31+
</div>
32+
</div>
33+
</div>
34+
)
35+
}

webview-ui/src/i18n/locales/ar/settings.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/ca/settings.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/cs/settings.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/de/settings.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/en/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,10 @@
469469
},
470470
"resetDefaults": "Reset to Defaults"
471471
},
472+
"rateLimitAfter": {
473+
"label": "Rate limit on end",
474+
"description": "Start rate limiting after the API stream ends."
475+
},
472476
"rateLimitSeconds": {
473477
"label": "Rate limit",
474478
"description": "Minimum time between API requests."

0 commit comments

Comments
 (0)