refactor(knowledge-base-edit): reorganize imports and adjust grid layout for answer mode

This commit is contained in:
mlogclub
2026-04-18 14:00:40 +08:00
parent c84870b968
commit 3249c8ae96
2 changed files with 44 additions and 47 deletions
@@ -677,7 +677,6 @@ function EditDialogBody({
>
<SectionCard
title="基础信息"
description="定义这个 Agent 是谁、使用哪个模型、以什么服务模式工作,并配置基础话术。"
>
<div className="grid grid-cols-1 gap-4 xl:grid-cols-3">
<Field data-invalid={!!errors.name}>
@@ -750,44 +749,6 @@ function EditDialogBody({
</FieldContent>
</Field>
<Field data-invalid={!!errors.fallbackMode}>
<FieldLabel></FieldLabel>
<FieldContent className="space-y-3">
<Controller
control={control}
name="fallbackMode"
render={({ field }) => (
<OptionCombobox
value={field.value}
options={fallbackModeOptions}
placeholder="请选择兜底策略"
searchPlaceholder="搜索兜底策略"
emptyText="未找到兜底策略"
onChange={field.onChange}
/>
)}
/>
<FieldError errors={[errors.fallbackMode]} />
</FieldContent>
</Field>
<Field data-invalid={!!errors.fallbackMessage}>
<FieldLabel htmlFor="ai-agent-fallback-message">
</FieldLabel>
<FieldContent>
<div className="text-xs text-muted-foreground mb-1">
Graph Tool
</div>
<Textarea
id="ai-agent-fallback-message"
rows={5}
{...register("fallbackMessage")}
/>
<FieldError errors={[errors.fallbackMessage]} />
</FieldContent>
</Field>
<Field data-invalid={!!errors.systemPrompt}>
<FieldLabel htmlFor="ai-agent-system-prompt">
@@ -805,7 +766,6 @@ function EditDialogBody({
<SectionCard
title="服务策略"
description="控制 Graph Tool 转人工配置、兜底策略和自动回复边界。"
>
<div className="grid grid-cols-1 gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(320px,1.15fr)]">
<div className="space-y-4">
@@ -1011,6 +971,46 @@ function EditDialogBody({
) : null}
</FieldContent>
</Field>
<div className="mt-4 grid grid-cols-1 gap-4 xl:grid-cols-1">
<Field data-invalid={!!errors.fallbackMode}>
<FieldLabel></FieldLabel>
<FieldContent className="space-y-3">
<Controller
control={control}
name="fallbackMode"
render={({ field }) => (
<OptionCombobox
value={field.value}
options={fallbackModeOptions}
placeholder="请选择兜底策略"
searchPlaceholder="搜索兜底策略"
emptyText="未找到兜底策略"
onChange={field.onChange}
/>
)}
/>
<FieldError errors={[errors.fallbackMode]} />
</FieldContent>
</Field>
<Field data-invalid={!!errors.fallbackMessage}>
<FieldLabel htmlFor="ai-agent-fallback-message">
</FieldLabel>
<FieldContent>
<div className="mb-1 text-xs text-muted-foreground">
</div>
<Textarea
id="ai-agent-fallback-message"
rows={5}
{...register("fallbackMessage")}
/>
<FieldError errors={[errors.fallbackMessage]} />
</FieldContent>
</Field>
</div>
</div>
<div className="rounded-xl border bg-muted/10 p-4">
@@ -28,15 +28,15 @@ import {
type CreateKnowledgeBasePayload,
type KnowledgeBase,
} from "@/lib/api/admin";
import { getEnumLabel, getEnumOptions } from "@/lib/enums";
import {
KnowledgeAnswerMode,
KnowledgeAnswerModeLabels,
KnowledgeBaseType,
KnowledgeBaseTypeLabels,
KnowledgeChunkProvider,
KnowledgeChunkProviderLabels,
KnowledgeAnswerMode,
KnowledgeAnswerModeLabels,
} from "@/lib/generated/enums";
import { getEnumLabel, getEnumOptions } from "@/lib/enums";
type KnowledgeBaseEditDialogProps = {
open: boolean;
@@ -383,7 +383,7 @@ function KnowledgeBaseFormDialogBody({
</div>
) : null}
<div className="grid grid-cols-1 gap-4 sm:grid-cols-3">
<div className="grid grid-cols-1 gap-4 sm:grid-cols-4">
<Field data-invalid={!!errors.defaultTopK}>
<FieldLabel htmlFor="kb-default-top-k">TopK</FieldLabel>
<FieldContent>
@@ -431,9 +431,6 @@ function KnowledgeBaseFormDialogBody({
<FieldError errors={[errors.defaultRerankLimit]} />
</FieldContent>
</Field>
</div>
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
<Field data-invalid={!!errors.answerMode}>
<FieldLabel htmlFor="kb-answer-mode"></FieldLabel>
<FieldContent>