mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-11-18 07:23:50 +08:00
fix: add configurable model approval retries
This commit is contained in:
1 parent
23446606a4
commit
d2e7e3a8a7
8 files changed
+464
-11
No files matched your search
@@ -21,6 +21,7 @@ import {
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Field as FormField, FieldDescription, FieldGroup, FieldLabel } from "@/components/ui/field";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
@@ -200,6 +201,8 @@ const defaultJudge = (): JudgeConfig => ({
|
||||
profile_id: 0,
|
||||
prompt: "",
|
||||
timeout_seconds: 15,
|
||||
retry_count: 0,
|
||||
retry_interval_ms: 1000,
|
||||
fail_action: "allow",
|
||||
ask_timeout_seconds: 300,
|
||||
ask_timeout_action: "deny",
|
||||
@@ -207,7 +210,7 @@ const defaultJudge = (): JudgeConfig => ({
|
||||
});
|
||||
|
||||
function JudgeCard() {
|
||||
const [cfg, setCfg] = React.useState<JudgeConfig>(defaultJudge());
|
||||
const [cfg, setCfg] = React.useState<JudgeConfig>(defaultJudge);
|
||||
const [profiles, setProfiles] = React.useState<LLMProfile[]>([]);
|
||||
const [loading, setLoading] = React.useState(true);
|
||||
const [saving, setSaving] = React.useState(false);
|
||||
@@ -376,7 +379,7 @@ function JudgeCard() {
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
<Field label="模型判定超时(秒)">
|
||||
<Field label="每次模型判定超时(秒)">
|
||||
<Input
|
||||
type="number"
|
||||
min={1}
|
||||
@@ -387,7 +390,48 @@ function JudgeCard() {
|
||||
}}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="模型失败时(出错 / 超时 / 无法解析)">
|
||||
<FieldGroup>
|
||||
<FormField>
|
||||
<FieldLabel htmlFor="judge-retry-count">失败重试次数</FieldLabel>
|
||||
<Input
|
||||
id="judge-retry-count"
|
||||
type="number"
|
||||
min={0}
|
||||
max={20}
|
||||
step={1}
|
||||
value={cfg.retry_count}
|
||||
onChange={(e) => {
|
||||
const n = Number(e.target.value);
|
||||
if (Number.isInteger(n) && n >= 0 && n <= 20) patch({ retry_count: n });
|
||||
}}
|
||||
aria-describedby="judge-retry-count-hint"
|
||||
/>
|
||||
<FieldDescription id="judge-retry-count-hint">
|
||||
首次审批失败后额外重试 0–20 次,0 表示不重试。出错、超时或裁决无法解析时重试;正常放行、转人工或拦截后立即结束。
|
||||
</FieldDescription>
|
||||
</FormField>
|
||||
<FormField data-disabled={cfg.retry_count === 0}>
|
||||
<FieldLabel htmlFor="judge-retry-interval">重试间隔(毫秒)</FieldLabel>
|
||||
<Input
|
||||
id="judge-retry-interval"
|
||||
type="number"
|
||||
min={0}
|
||||
max={3600000}
|
||||
step={1}
|
||||
value={cfg.retry_interval_ms}
|
||||
disabled={cfg.retry_count === 0}
|
||||
onChange={(e) => {
|
||||
const n = Number(e.target.value);
|
||||
if (Number.isInteger(n) && n >= 0 && n <= 3600000) patch({ retry_interval_ms: n });
|
||||
}}
|
||||
aria-describedby="judge-retry-interval-hint"
|
||||
/>
|
||||
<FieldDescription id="judge-retry-interval-hint">
|
||||
默认 1000 毫秒,0 表示立即重试。每次审批均有独立超时,全部尝试失败后执行下方失败策略。模型配置中的建连和空响应重试仍在每次审批内生效。
|
||||
</FieldDescription>
|
||||
</FormField>
|
||||
</FieldGroup>
|
||||
<Field label="模型失败时(重试耗尽后)">
|
||||
<Select value={cfg.fail_action} onValueChange={(v) => patch({ fail_action: v as JudgeConfig["fail_action"] })}>
|
||||
<SelectTrigger><SelectValue /></SelectTrigger>
|
||||
<SelectContent>
|
||||
|
||||
@@ -2511,6 +2511,8 @@ function route(m: string, path: string, seg: string[], q: URLSearchParams, b: Re
|
||||
profile_id: 0,
|
||||
prompt: "",
|
||||
timeout_seconds: 15,
|
||||
retry_count: 0,
|
||||
retry_interval_ms: 1000,
|
||||
fail_action: "allow",
|
||||
ask_timeout_seconds: 300,
|
||||
ask_timeout_action: "deny",
|
||||
|
||||
@@ -1361,7 +1361,9 @@ export interface JudgeConfig {
|
||||
enabled: boolean;
|
||||
profile_id: number; // 0 = 跟随激活/默认配置
|
||||
prompt: string; // 判定提示词;GET 未设置时后端回填内置模板全文
|
||||
timeout_seconds: number; // 模型调用超时
|
||||
timeout_seconds: number; // 每次模型审批调用的超时
|
||||
retry_count: number; // 审批失败后的额外重试次数,0 = 不重试
|
||||
retry_interval_ms: number; // 审批重试间隔(毫秒),0 = 立即重试
|
||||
fail_action: "allow" | "ask" | "deny"; // 模型出错/超时/不可解析时的回退
|
||||
ask_timeout_seconds: number; // 模型判 ask 转人工后的审批等待超时
|
||||
ask_timeout_action: "allow" | "deny"; // 审批超时后的默认动作
|
||||
|
||||
Reference in new issue
Block a user