mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-02 14:04:50 +00:00
fix(webui): make model list in provider dialog scrollable
This commit is contained in:
@@ -673,230 +673,234 @@ function ProviderFormDialog({
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="space-y-6">
|
<ScrollArea className="max-h-[500px] pr-4">
|
||||||
{modelsField.state.value.map((_, index) => (
|
<div className="space-y-6">
|
||||||
<div
|
{modelsField.state.value.map((_, index) => (
|
||||||
key={index}
|
<div
|
||||||
className="group relative p-6 bg-transparent rounded-2xl border shadow-sm animate-in fade-in zoom-in-95 duration-300"
|
key={index}
|
||||||
>
|
className="group relative p-6 bg-transparent rounded-2xl border shadow-sm animate-in fade-in zoom-in-95 duration-300"
|
||||||
{/* Row 1: ID and Name */}
|
>
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
{/* Row 1: ID and Name */}
|
||||||
<form.Field
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||||
name={`models[${index}].modelId`}
|
<form.Field
|
||||||
children={(field) => {
|
name={`models[${index}].modelId`}
|
||||||
const isInvalid =
|
children={(field) => {
|
||||||
!!field.state.meta.errors.length && field.state.meta.isTouched
|
const isInvalid =
|
||||||
return (
|
!!field.state.meta.errors.length && field.state.meta.isTouched
|
||||||
<Field data-invalid={isInvalid}>
|
return (
|
||||||
<FieldLabel htmlFor={field.name}>Model ID</FieldLabel>
|
<Field data-invalid={isInvalid}>
|
||||||
<Input
|
<FieldLabel htmlFor={field.name}>Model ID</FieldLabel>
|
||||||
id={field.name}
|
<Input
|
||||||
name={field.name}
|
id={field.name}
|
||||||
value={field.state.value}
|
name={field.name}
|
||||||
onBlur={field.handleBlur}
|
value={field.state.value}
|
||||||
onChange={(e) => field.handleChange(e.target.value)}
|
onBlur={field.handleBlur}
|
||||||
placeholder="gpt-4o"
|
onChange={(e) => field.handleChange(e.target.value)}
|
||||||
aria-invalid={isInvalid}
|
placeholder="gpt-4o"
|
||||||
/>
|
aria-invalid={isInvalid}
|
||||||
{isInvalid && (
|
/>
|
||||||
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
{isInvalid && (
|
||||||
)}
|
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
||||||
</Field>
|
)}
|
||||||
)
|
</Field>
|
||||||
}}
|
)
|
||||||
/>
|
}}
|
||||||
<form.Field
|
/>
|
||||||
name={`models[${index}].name`}
|
<form.Field
|
||||||
children={(field) => {
|
name={`models[${index}].name`}
|
||||||
const isInvalid =
|
children={(field) => {
|
||||||
!!field.state.meta.errors.length && field.state.meta.isTouched
|
const isInvalid =
|
||||||
return (
|
!!field.state.meta.errors.length && field.state.meta.isTouched
|
||||||
<Field data-invalid={isInvalid}>
|
return (
|
||||||
|
<Field data-invalid={isInvalid}>
|
||||||
|
<FieldLabel htmlFor={field.name}>
|
||||||
|
Display Name (Optional)
|
||||||
|
</FieldLabel>
|
||||||
|
<Input
|
||||||
|
id={field.name}
|
||||||
|
name={field.name}
|
||||||
|
value={field.state.value}
|
||||||
|
onBlur={field.handleBlur}
|
||||||
|
onChange={(e) => field.handleChange(e.target.value)}
|
||||||
|
placeholder="e.g., GPT-4o"
|
||||||
|
aria-invalid={isInvalid}
|
||||||
|
disabled={isBuiltin}
|
||||||
|
/>
|
||||||
|
{isInvalid && (
|
||||||
|
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Row 2: Reasoning and Context Window */}
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 mt-6">
|
||||||
|
<form.Field
|
||||||
|
name={`models[${index}].config.reasoning`}
|
||||||
|
children={(field) => (
|
||||||
|
<Field
|
||||||
|
orientation="horizontal"
|
||||||
|
className="rounded-lg border border-border p-3 shadow-sm bg-muted/50 justify-between"
|
||||||
|
>
|
||||||
<FieldLabel htmlFor={field.name}>
|
<FieldLabel htmlFor={field.name}>
|
||||||
Display Name (Optional)
|
Reasoning Support
|
||||||
</FieldLabel>
|
</FieldLabel>
|
||||||
<Input
|
<Switch
|
||||||
id={field.name}
|
id={field.name}
|
||||||
name={field.name}
|
checked={field.state.value}
|
||||||
value={field.state.value}
|
onCheckedChange={field.handleChange}
|
||||||
onBlur={field.handleBlur}
|
|
||||||
onChange={(e) => field.handleChange(e.target.value)}
|
|
||||||
placeholder="e.g., GPT-4o"
|
|
||||||
aria-invalid={isInvalid}
|
|
||||||
disabled={isBuiltin}
|
disabled={isBuiltin}
|
||||||
/>
|
/>
|
||||||
{isInvalid && (
|
|
||||||
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
|
||||||
)}
|
|
||||||
</Field>
|
</Field>
|
||||||
)
|
)}
|
||||||
}}
|
/>
|
||||||
/>
|
<form.Field
|
||||||
</div>
|
name={`models[${index}].config.contextWindow`}
|
||||||
|
children={(field) => {
|
||||||
|
const isInvalid =
|
||||||
|
!!field.state.meta.errors.length && field.state.meta.isTouched
|
||||||
|
return (
|
||||||
|
<Field data-invalid={isInvalid}>
|
||||||
|
<FieldLabel htmlFor={field.name} className="text-xs">
|
||||||
|
Context Window (tokens)
|
||||||
|
</FieldLabel>
|
||||||
|
<Input
|
||||||
|
id={field.name}
|
||||||
|
name={field.name}
|
||||||
|
type="number"
|
||||||
|
value={field.state.value}
|
||||||
|
onBlur={field.handleBlur}
|
||||||
|
onChange={(e) =>
|
||||||
|
field.handleChange(parseInt(e.target.value) || 0)
|
||||||
|
}
|
||||||
|
aria-invalid={isInvalid}
|
||||||
|
disabled={isBuiltin}
|
||||||
|
/>
|
||||||
|
{isInvalid && (
|
||||||
|
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Row 2: Reasoning and Context Window */}
|
{/* Row 3: Constraints and Cost */}
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 mt-6">
|
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 mt-6">
|
||||||
<form.Field
|
<form.Field
|
||||||
name={`models[${index}].config.reasoning`}
|
name={`models[${index}].config.maxTokens`}
|
||||||
children={(field) => (
|
children={(field) => {
|
||||||
<Field
|
const isInvalid =
|
||||||
orientation="horizontal"
|
!!field.state.meta.errors.length && field.state.meta.isTouched
|
||||||
className="rounded-lg border border-border p-3 shadow-sm bg-muted/50 justify-between"
|
return (
|
||||||
>
|
<Field data-invalid={isInvalid}>
|
||||||
<FieldLabel htmlFor={field.name}>Reasoning Support</FieldLabel>
|
<FieldLabel htmlFor={field.name} className="text-xs">
|
||||||
<Switch
|
Max Output Tokens
|
||||||
id={field.name}
|
</FieldLabel>
|
||||||
checked={field.state.value}
|
<Input
|
||||||
onCheckedChange={field.handleChange}
|
id={field.name}
|
||||||
disabled={isBuiltin}
|
name={field.name}
|
||||||
/>
|
type="number"
|
||||||
</Field>
|
value={field.state.value}
|
||||||
)}
|
onBlur={field.handleBlur}
|
||||||
/>
|
onChange={(e) =>
|
||||||
<form.Field
|
field.handleChange(parseInt(e.target.value) || 0)
|
||||||
name={`models[${index}].config.contextWindow`}
|
}
|
||||||
children={(field) => {
|
aria-invalid={isInvalid}
|
||||||
const isInvalid =
|
disabled={isBuiltin}
|
||||||
!!field.state.meta.errors.length && field.state.meta.isTouched
|
/>
|
||||||
return (
|
{isInvalid && (
|
||||||
<Field data-invalid={isInvalid}>
|
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
||||||
<FieldLabel htmlFor={field.name} className="text-xs">
|
)}
|
||||||
Context Window (tokens)
|
</Field>
|
||||||
</FieldLabel>
|
)
|
||||||
<Input
|
}}
|
||||||
id={field.name}
|
/>
|
||||||
name={field.name}
|
<form.Field
|
||||||
type="number"
|
name={`models[${index}].config.cost.input`}
|
||||||
value={field.state.value}
|
children={(field) => {
|
||||||
onBlur={field.handleBlur}
|
const isInvalid =
|
||||||
onChange={(e) =>
|
!!field.state.meta.errors.length && field.state.meta.isTouched
|
||||||
field.handleChange(parseInt(e.target.value) || 0)
|
return (
|
||||||
}
|
<Field data-invalid={isInvalid}>
|
||||||
aria-invalid={isInvalid}
|
<FieldLabel
|
||||||
disabled={isBuiltin}
|
htmlFor={field.name}
|
||||||
/>
|
className="text-xs flex items-center gap-1"
|
||||||
{isInvalid && (
|
>
|
||||||
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
<DollarSign className="w-3 h-3" /> Input Cost (1M)
|
||||||
)}
|
</FieldLabel>
|
||||||
</Field>
|
<Input
|
||||||
)
|
id={field.name}
|
||||||
}}
|
name={field.name}
|
||||||
/>
|
type="number"
|
||||||
</div>
|
step="0.01"
|
||||||
|
value={field.state.value}
|
||||||
|
onBlur={field.handleBlur}
|
||||||
|
onChange={(e) =>
|
||||||
|
field.handleChange(parseFloat(e.target.value) || 0)
|
||||||
|
}
|
||||||
|
aria-invalid={isInvalid}
|
||||||
|
disabled={isBuiltin}
|
||||||
|
/>
|
||||||
|
{isInvalid && (
|
||||||
|
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<form.Field
|
||||||
|
name={`models[${index}].config.cost.output`}
|
||||||
|
children={(field) => {
|
||||||
|
const isInvalid =
|
||||||
|
!!field.state.meta.errors.length && field.state.meta.isTouched
|
||||||
|
return (
|
||||||
|
<Field data-invalid={isInvalid}>
|
||||||
|
<FieldLabel
|
||||||
|
htmlFor={field.name}
|
||||||
|
className="text-xs flex items-center gap-1"
|
||||||
|
>
|
||||||
|
<DollarSign className="w-3 h-3" /> Output Cost (1M)
|
||||||
|
</FieldLabel>
|
||||||
|
<Input
|
||||||
|
id={field.name}
|
||||||
|
name={field.name}
|
||||||
|
type="number"
|
||||||
|
step="0.01"
|
||||||
|
value={field.state.value}
|
||||||
|
onBlur={field.handleBlur}
|
||||||
|
onChange={(e) =>
|
||||||
|
field.handleChange(parseFloat(e.target.value) || 0)
|
||||||
|
}
|
||||||
|
aria-invalid={isInvalid}
|
||||||
|
disabled={isBuiltin}
|
||||||
|
/>
|
||||||
|
{isInvalid && (
|
||||||
|
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Row 3: Constraints and Cost */}
|
{!isBuiltin && (
|
||||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 mt-6">
|
<Button
|
||||||
<form.Field
|
type="button"
|
||||||
name={`models[${index}].config.maxTokens`}
|
variant="ghost"
|
||||||
children={(field) => {
|
size="icon"
|
||||||
const isInvalid =
|
className="absolute -top-2 -right-2 h-8 w-8 rounded-full bg-background border border-border text-muted-foreground hover:text-destructive transition-colors shadow-sm"
|
||||||
!!field.state.meta.errors.length && field.state.meta.isTouched
|
onClick={() => modelsField.removeValue(index)}
|
||||||
return (
|
>
|
||||||
<Field data-invalid={isInvalid}>
|
<Trash2 className="h-4 w-4" />
|
||||||
<FieldLabel htmlFor={field.name} className="text-xs">
|
</Button>
|
||||||
Max Output Tokens
|
)}
|
||||||
</FieldLabel>
|
|
||||||
<Input
|
|
||||||
id={field.name}
|
|
||||||
name={field.name}
|
|
||||||
type="number"
|
|
||||||
value={field.state.value}
|
|
||||||
onBlur={field.handleBlur}
|
|
||||||
onChange={(e) =>
|
|
||||||
field.handleChange(parseInt(e.target.value) || 0)
|
|
||||||
}
|
|
||||||
aria-invalid={isInvalid}
|
|
||||||
disabled={isBuiltin}
|
|
||||||
/>
|
|
||||||
{isInvalid && (
|
|
||||||
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
|
||||||
)}
|
|
||||||
</Field>
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<form.Field
|
|
||||||
name={`models[${index}].config.cost.input`}
|
|
||||||
children={(field) => {
|
|
||||||
const isInvalid =
|
|
||||||
!!field.state.meta.errors.length && field.state.meta.isTouched
|
|
||||||
return (
|
|
||||||
<Field data-invalid={isInvalid}>
|
|
||||||
<FieldLabel
|
|
||||||
htmlFor={field.name}
|
|
||||||
className="text-xs flex items-center gap-1"
|
|
||||||
>
|
|
||||||
<DollarSign className="w-3 h-3" /> Input Cost (1M)
|
|
||||||
</FieldLabel>
|
|
||||||
<Input
|
|
||||||
id={field.name}
|
|
||||||
name={field.name}
|
|
||||||
type="number"
|
|
||||||
step="0.01"
|
|
||||||
value={field.state.value}
|
|
||||||
onBlur={field.handleBlur}
|
|
||||||
onChange={(e) =>
|
|
||||||
field.handleChange(parseFloat(e.target.value) || 0)
|
|
||||||
}
|
|
||||||
aria-invalid={isInvalid}
|
|
||||||
disabled={isBuiltin}
|
|
||||||
/>
|
|
||||||
{isInvalid && (
|
|
||||||
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
|
||||||
)}
|
|
||||||
</Field>
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<form.Field
|
|
||||||
name={`models[${index}].config.cost.output`}
|
|
||||||
children={(field) => {
|
|
||||||
const isInvalid =
|
|
||||||
!!field.state.meta.errors.length && field.state.meta.isTouched
|
|
||||||
return (
|
|
||||||
<Field data-invalid={isInvalid}>
|
|
||||||
<FieldLabel
|
|
||||||
htmlFor={field.name}
|
|
||||||
className="text-xs flex items-center gap-1"
|
|
||||||
>
|
|
||||||
<DollarSign className="w-3 h-3" /> Output Cost (1M)
|
|
||||||
</FieldLabel>
|
|
||||||
<Input
|
|
||||||
id={field.name}
|
|
||||||
name={field.name}
|
|
||||||
type="number"
|
|
||||||
step="0.01"
|
|
||||||
value={field.state.value}
|
|
||||||
onBlur={field.handleBlur}
|
|
||||||
onChange={(e) =>
|
|
||||||
field.handleChange(parseFloat(e.target.value) || 0)
|
|
||||||
}
|
|
||||||
aria-invalid={isInvalid}
|
|
||||||
disabled={isBuiltin}
|
|
||||||
/>
|
|
||||||
{isInvalid && (
|
|
||||||
<FieldError errors={mapErrors(field.state.meta.errors)} />
|
|
||||||
)}
|
|
||||||
</Field>
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
))}
|
||||||
{!isBuiltin && (
|
</div>
|
||||||
<Button
|
</ScrollArea>
|
||||||
type="button"
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="absolute -top-2 -right-2 h-8 w-8 rounded-full bg-background border border-border text-muted-foreground hover:text-destructive transition-colors shadow-sm"
|
|
||||||
onClick={() => modelsField.removeValue(index)}
|
|
||||||
>
|
|
||||||
<Trash2 className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user