feat: remove fallback mode and max AI reply rounds from AIAgent model and related components

This commit is contained in:
mlogclub
2026-04-10 16:08:17 +08:00
parent ea327e2d97
commit c1d42be1fc
11 changed files with 11 additions and 172 deletions
@@ -47,8 +47,6 @@ import {
fetchSkillDefinitionsAll,
} from "@/lib/api/admin";
import {
AIAgentFallbackMode,
AIAgentFallbackModeLabels,
AIAgentHandoffMode,
AIAgentHandoffModeLabels,
AIModelType,
@@ -89,10 +87,6 @@ const schema = z.object({
.number()
.min(0, "回复超时秒数必须是大于等于 0 的整数"),
handoffMode: z.string().trim().min(1, "请选择转人工模式"),
maxAiReplyRounds: z
.number()
.min(0, "AI 最大回复次数必须是大于等于 0 的整数"),
fallbackMode: z.string().trim().min(1, "请选择兜底模式"),
fallbackMessage: z.string().trim(),
remark: z.string().trim(),
});
@@ -119,13 +113,6 @@ const handoffModeOptions = getEnumOptions(AIAgentHandoffModeLabels).map(
}),
);
const fallbackModeOptions = getEnumOptions(AIAgentFallbackModeLabels).map(
(option) => ({
value: String(option.value),
label: option.label,
}),
).filter((option) => option.value !== String(AIAgentFallbackMode.Handoff));
function buildForm(item: AIAgent | null): EditForm {
if (!item) {
return {
@@ -137,8 +124,6 @@ function buildForm(item: AIAgent | null): EditForm {
welcomeMessage: "",
replyTimeoutSeconds: 180,
handoffMode: String(AIAgentHandoffMode.WaitPool),
maxAiReplyRounds: 2,
fallbackMode: String(AIAgentFallbackMode.GuideRephrase),
fallbackMessage:
"我暂时没有找到足够准确的信息。你可以补充订单号、产品名或更具体的问题,我再继续帮你查。",
remark: "",
@@ -153,8 +138,6 @@ function buildForm(item: AIAgent | null): EditForm {
welcomeMessage: item.welcomeMessage || "",
replyTimeoutSeconds: item.replyTimeoutSeconds ?? 180,
handoffMode: String(item.handoffMode),
maxAiReplyRounds: item.maxAiReplyRounds ?? 2,
fallbackMode: String(item.fallbackMode),
fallbackMessage: item.fallbackMessage || "",
remark: item.remark || "",
};
@@ -177,8 +160,6 @@ function buildPayload(
replyTimeoutSeconds: Number(form.replyTimeoutSeconds),
teamIds,
handoffMode: Number(form.handoffMode),
maxAiReplyRounds: Number(form.maxAiReplyRounds),
fallbackMode: Number(form.fallbackMode),
fallbackMessage: form.fallbackMessage.trim(),
knowledgeIds,
skillIds,
@@ -1031,61 +1012,6 @@ function EditDialogBody({
<FieldError errors={[errors.replyTimeoutSeconds]} />
</FieldContent>
</Field>
<Field data-invalid={!!errors.maxAiReplyRounds}>
<FieldLabel
htmlFor="ai-agent-max-rounds"
className="flex items-center gap-1"
>
AI
<Popover>
<PopoverTrigger
render={
<button
type="button"
className="inline-flex items-center justify-center text-muted-foreground hover:text-foreground"
>
<InfoIcon className="size-4" />
</button>
}
/>
<PopoverContent side="top" align="start" className="max-w-xs">
<PopoverDescription>
AI handoff_to_human Graph Tool
</PopoverDescription>
</PopoverContent>
</Popover>
</FieldLabel>
<FieldContent>
<Input
id="ai-agent-max-rounds"
type="number"
min={0}
step={1}
{...register("maxAiReplyRounds", { valueAsNumber: true })}
/>
<FieldError errors={[errors.maxAiReplyRounds]} />
</FieldContent>
</Field>
<Field data-invalid={!!errors.fallbackMode}>
<FieldLabel></FieldLabel>
<FieldContent>
<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>
</div>
<div className="rounded-xl border bg-muted/10 p-4">
-5
View File
@@ -207,9 +207,6 @@ export type AIAgent = {
teams: { id: number; name: string }[]
handoffMode: number
handoffModeName: string
maxAiReplyRounds: number
fallbackMode: number
fallbackModeName: string
fallbackMessage: string
knowledgeIds: number[]
knowledgeBaseNames: string[]
@@ -241,8 +238,6 @@ export type CreateAIAgentPayload = {
replyTimeoutSeconds: number
teamIds: number[]
handoffMode: number
maxAiReplyRounds: number
fallbackMode: number
fallbackMessage: string
knowledgeIds: number[]
skillIds: number[]
+2 -33
View File
@@ -1,16 +1,5 @@
// Code generated by cmd/enums/generator.go. DO NOT EDIT.
export enum AIAgentFallbackMode {
NoAnswer = 1,
GuideRephrase = 2,
Handoff = 3,
}
export const AIAgentFallbackModeLabels: Record<AIAgentFallbackMode, string> = {
[AIAgentFallbackMode.NoAnswer]: "直接声明无答案",
[AIAgentFallbackMode.GuideRephrase]: "引导补充信息或换个问法",
[AIAgentFallbackMode.Handoff]: "直接转人工",
}
export enum AIAgentHandoffMode {
WaitPool = 1,
DefaultTeamPool = 2,
@@ -75,9 +64,11 @@ export const ContactTypeLabels: Record<ContactType, string> = {
export enum ExternalSource {
WebChat = "web_chat",
WxWorkKF = "wxwork_kf",
}
export const ExternalSourceLabels: Record<ExternalSource, string> = {
[ExternalSource.WebChat]: "网页客服",
[ExternalSource.WxWorkKF]: "企业微信客服",
}
export enum Gender {
@@ -340,15 +331,6 @@ export const ServiceStatusLabels: Record<ServiceStatus, string> = {
[ServiceStatus.Busy]: "忙碌",
}
export enum SkillExecutionMode {
PromptOnly = "prompt_only",
MCPTool = "mcp_tool",
}
export const SkillExecutionModeLabels: Record<SkillExecutionMode, string> = {
[SkillExecutionMode.PromptOnly]: "Prompt直出",
[SkillExecutionMode.MCPTool]: "MCP工具",
}
export enum Status {
Ok = 0,
Disabled = 1,
@@ -369,19 +351,6 @@ export const ThirdProviderLabels: Record<ThirdProvider, string> = {
[ThirdProvider.Dingtalk]: "钉钉",
}
export enum TicketPriority {
Low = 1,
Normal = 2,
High = 3,
Urgent = 4,
}
export const TicketPriorityLabels: Record<TicketPriority, string> = {
[TicketPriority.Low]: "低",
[TicketPriority.Normal]: "普通",
[TicketPriority.High]: "高",
[TicketPriority.Urgent]: "紧急",
}
export enum TicketSeverity {
Minor = 1,
Major = 2,