mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-16 23:41:43 +00:00
refactor(ui): move key rate limit fields into KeyRateLimitFields
key_edit_view.tsx crossed the 800 line eslint max-lines ceiling once the tpd_limit field landed. Move the tpm/rpm/tpd fields into a shared KeyRateLimitFields control so the edit view stays under the limit Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
df5e193645
commit
ea6314492f
2 changed files with 46 additions and 40 deletions
|
|
@ -7,6 +7,7 @@ import { CircleHelp } from "lucide-react";
|
|||
import { FormField } from "@/components/shared/form/FormField";
|
||||
import { toast } from "@/lib/toast";
|
||||
import AgentSelector from "../agent_management/AgentSelector";
|
||||
import RateLimitTypeFormItem from "../common_components/RateLimitTypeFormItem";
|
||||
import NumericalInput from "../shared/numerical_input";
|
||||
import SkillSelector from "../skills/SkillSelector";
|
||||
import { moveTagsOutOfMetadataJson } from "./keyEditFieldNormalizers";
|
||||
|
|
@ -61,9 +62,51 @@ export const KeyTypeSelect = ({
|
|||
const SKILLS_HINT =
|
||||
"Enabled skills are visible to every key. Grant disabled (private) Claude Code plugins to this key here.";
|
||||
|
||||
export const TPD_HINT =
|
||||
const TPD_HINT =
|
||||
"Daily token budget for batch submissions (/v1/batches). When set, batch input files are charged against this 24h window instead of the key's TPM/RPM limits. Online requests keep using TPM/RPM.";
|
||||
|
||||
export const KeyRateLimitFields = ({ control }: { control: Control<KeyEditFormValues> }) => (
|
||||
<>
|
||||
<FormField control={control} name="tpm_limit" label="TPM Limit">
|
||||
{({ ref: _ref, ...field }) => <NumericalInput {...field} value={field.value ?? ""} min={0} />}
|
||||
</FormField>
|
||||
|
||||
<FormField control={control} name="tpm_limit_type">
|
||||
{({ value, onChange, id }) => (
|
||||
<RateLimitTypeFormItem
|
||||
id={id}
|
||||
type="tpm"
|
||||
name="tpm_limit_type"
|
||||
showDetailedDescriptions={false}
|
||||
value={value as string | null}
|
||||
onChange={onChange}
|
||||
/>
|
||||
)}
|
||||
</FormField>
|
||||
|
||||
<FormField control={control} name="rpm_limit" label="RPM Limit">
|
||||
{({ ref: _ref, ...field }) => <NumericalInput {...field} value={field.value ?? ""} min={0} />}
|
||||
</FormField>
|
||||
|
||||
<FormField control={control} name="rpm_limit_type">
|
||||
{({ value, onChange, id }) => (
|
||||
<RateLimitTypeFormItem
|
||||
id={id}
|
||||
type="rpm"
|
||||
name="rpm_limit_type"
|
||||
showDetailedDescriptions={false}
|
||||
value={value as string | null}
|
||||
onChange={onChange}
|
||||
/>
|
||||
)}
|
||||
</FormField>
|
||||
|
||||
<FormField control={control} name="tpd_limit" label={labelWithHint("TPD Limit (batch)", TPD_HINT)}>
|
||||
{({ ref: _ref, ...field }) => <NumericalInput {...field} value={field.value ?? ""} min={0} />}
|
||||
</FormField>
|
||||
</>
|
||||
);
|
||||
|
||||
export const KeyAgentAndSkillFields = ({
|
||||
control,
|
||||
accessToken,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import BudgetDurationDropdown from "../common_components/budget_duration_dropdow
|
|||
import { mapInternalToDisplayNames } from "../callback_info_helpers";
|
||||
import KeyLifecycleSettings from "../common_components/KeyLifecycleSettings";
|
||||
import PassThroughRoutesSelector from "../common_components/PassThroughRoutesSelector";
|
||||
import RateLimitTypeFormItem from "../common_components/RateLimitTypeFormItem";
|
||||
import OrganizationDropdown from "../common_components/OrganizationDropdown";
|
||||
import RouterSettingsAccordion, { RouterSettingsAccordionRef } from "../common_components/RouterSettingsAccordion";
|
||||
import { routerSettingsEditorValue, routerSettingsUpdate } from "../common_components/routerSettingsPayload";
|
||||
|
|
@ -35,10 +34,10 @@ import {
|
|||
KeyAgentAndSkillFields,
|
||||
KeyBudgetNumberField,
|
||||
KeyMetadataField,
|
||||
KeyRateLimitFields,
|
||||
KeyTypeSelect,
|
||||
labelWithHint,
|
||||
moveMetadataTagsToTagsField,
|
||||
TPD_HINT,
|
||||
} from "./KeyEditViewControls";
|
||||
import {
|
||||
KeyEditFormValues,
|
||||
|
|
@ -485,43 +484,7 @@ export function KeyEditView({
|
|||
/>
|
||||
</Field>
|
||||
|
||||
<FormField control={form.control} name="tpm_limit" label="TPM Limit">
|
||||
{({ ref: _ref, ...field }) => <NumericalInput {...field} value={field.value ?? ""} min={0} />}
|
||||
</FormField>
|
||||
|
||||
<FormField control={form.control} name="tpm_limit_type">
|
||||
{({ value, onChange, id }) => (
|
||||
<RateLimitTypeFormItem
|
||||
id={id}
|
||||
type="tpm"
|
||||
name="tpm_limit_type"
|
||||
showDetailedDescriptions={false}
|
||||
value={value as string | null}
|
||||
onChange={onChange}
|
||||
/>
|
||||
)}
|
||||
</FormField>
|
||||
|
||||
<FormField control={form.control} name="rpm_limit" label="RPM Limit">
|
||||
{({ ref: _ref, ...field }) => <NumericalInput {...field} value={field.value ?? ""} min={0} />}
|
||||
</FormField>
|
||||
|
||||
<FormField control={form.control} name="rpm_limit_type">
|
||||
{({ value, onChange, id }) => (
|
||||
<RateLimitTypeFormItem
|
||||
id={id}
|
||||
type="rpm"
|
||||
name="rpm_limit_type"
|
||||
showDetailedDescriptions={false}
|
||||
value={value as string | null}
|
||||
onChange={onChange}
|
||||
/>
|
||||
)}
|
||||
</FormField>
|
||||
|
||||
<FormField control={form.control} name="tpd_limit" label={labelWithHint("TPD Limit (batch)", TPD_HINT)}>
|
||||
{({ ref: _ref, ...field }) => <NumericalInput {...field} value={field.value ?? ""} min={0} />}
|
||||
</FormField>
|
||||
<KeyRateLimitFields control={form.control} />
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue