feat: 智能体创建流程优化与管理员记忆页面
- 创建智能体页面:保存后自动跳转列表页、技能列表增加搜索过滤框 - Bootstrap 模式:开放全部技能可见性,注入专属提示词(skill_list 匹配意图、禁止 skill_manage) - 管理员记忆页面:新增 AdminMemoryPage 及路由,支持查看/编辑用户记忆条目 - 内存配置与管理员用户接口同步更新 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
18c2a4122f
commit
3748513996
12 files changed
+692
-143
No files matched your search
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { PenLineIcon, PlusIcon, SearchIcon, Trash2Icon } from "lucide-react";
|
||||
import { useId, useMemo, useState } from "react";
|
||||
import { useMemo, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -345,16 +345,13 @@ export function MemorySettingsPage() {
|
||||
);
|
||||
}
|
||||
|
||||
/** 记忆设置面板:用户可改的白名单字段。 */
|
||||
/** 记忆设置面板:仅暴露 Hindsight 这一个可选开关,其余默认开启不展示。 */
|
||||
function MemoryConfigPanel() {
|
||||
const { t } = useI18n();
|
||||
const m = t.settings.memory;
|
||||
const { configResponse, isLoading } = useMemoryConfig();
|
||||
const patchConfig = usePatchMemoryConfig();
|
||||
|
||||
const maxTokensId = useId();
|
||||
const bankMissionId = useId();
|
||||
|
||||
async function patch(overrides: Record<string, unknown>) {
|
||||
try {
|
||||
await patchConfig.mutateAsync(overrides);
|
||||
@@ -367,9 +364,7 @@ function MemoryConfigPanel() {
|
||||
const config: MemoryV2Config | null = configResponse?.config ?? null;
|
||||
const writable = new Set(configResponse?.writable_fields ?? []);
|
||||
|
||||
function isWritable(field: string) {
|
||||
return writable.has(field);
|
||||
}
|
||||
const hindsightOn = config?.injection.include_hindsight ?? false;
|
||||
|
||||
return (
|
||||
<SettingsSection title={m.settingsTitle} description={m.settingsDesc}>
|
||||
@@ -377,123 +372,43 @@ function MemoryConfigPanel() {
|
||||
<div className="text-muted-foreground text-sm">{t.common.loading}</div>
|
||||
) : (
|
||||
<div className="space-y-4 rounded-lg border p-4">
|
||||
<ToggleRow
|
||||
label={m.injectionEnabled}
|
||||
description={m.injectionEnabledDesc}
|
||||
checked={config.injection.enabled}
|
||||
disabled={!isWritable("injection.enabled") || patchConfig.isPending}
|
||||
onChange={(v) => void patch({ injection: { enabled: v } })}
|
||||
/>
|
||||
<ToggleRow
|
||||
label={m.includeBuiltin}
|
||||
description={m.includeBuiltinDesc}
|
||||
checked={config.injection.include_builtin}
|
||||
disabled={
|
||||
!isWritable("injection.include_builtin") || patchConfig.isPending
|
||||
}
|
||||
onChange={(v) => void patch({ injection: { include_builtin: v } })}
|
||||
/>
|
||||
{/* 只暴露 Hindsight 开关,记忆总开关和本地记忆默认开启不展示 */}
|
||||
<ToggleRow
|
||||
label={m.includeHindsight}
|
||||
description={m.includeHindsightDesc}
|
||||
checked={config.injection.include_hindsight}
|
||||
checked={hindsightOn}
|
||||
disabled={
|
||||
!isWritable("injection.include_hindsight") || patchConfig.isPending
|
||||
!writable.has("injection.include_hindsight") || patchConfig.isPending
|
||||
}
|
||||
onChange={(v) => void patch({ injection: { include_hindsight: v } })}
|
||||
/>
|
||||
|
||||
<div className="flex flex-wrap items-center justify-between gap-3 border-t pt-4">
|
||||
<div className="min-w-0">
|
||||
<label htmlFor={maxTokensId} className="text-sm font-medium">
|
||||
{m.maxTokens}
|
||||
</label>
|
||||
<p className="text-muted-foreground text-sm">{m.maxTokensDesc}</p>
|
||||
</div>
|
||||
<Input
|
||||
id={maxTokensId}
|
||||
type="number"
|
||||
min="100"
|
||||
max="8000"
|
||||
step="100"
|
||||
className="w-32"
|
||||
defaultValue={config.injection.max_tokens}
|
||||
disabled={!isWritable("injection.max_tokens") || patchConfig.isPending}
|
||||
onBlur={(event) => {
|
||||
const value = Number(event.target.value);
|
||||
if (
|
||||
Number.isFinite(value) &&
|
||||
value !== config.injection.max_tokens
|
||||
) {
|
||||
void patch({ injection: { max_tokens: value } });
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{/* Hindsight 细节设置:仅在 Hindsight 开启时展示 */}
|
||||
{hindsightOn && (
|
||||
<>
|
||||
<div className="flex flex-wrap items-center justify-between gap-3 border-t pt-4">
|
||||
<div className="min-w-0">
|
||||
<label className="text-sm font-medium">{m.recallBudget}</label>
|
||||
<p className="text-muted-foreground text-sm">{m.recallBudgetDesc}</p>
|
||||
</div>
|
||||
<Select
|
||||
value={config.hindsight.recall_budget}
|
||||
disabled={!writable.has("hindsight.recall_budget") || patchConfig.isPending}
|
||||
onValueChange={(v) => void patch({ hindsight: { recall_budget: v } })}
|
||||
>
|
||||
<SelectTrigger className="w-44">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="low">{m.recallBudgetLow}</SelectItem>
|
||||
<SelectItem value="mid">{m.recallBudgetMid}</SelectItem>
|
||||
<SelectItem value="high">{m.recallBudgetHigh}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center justify-between gap-3 border-t pt-4">
|
||||
<div className="min-w-0">
|
||||
<label className="text-sm font-medium">{m.memoryMode}</label>
|
||||
<p className="text-muted-foreground text-sm">{m.memoryModeDesc}</p>
|
||||
</div>
|
||||
<Select
|
||||
value={config.hindsight.memory_mode}
|
||||
disabled={!isWritable("hindsight.memory_mode") || patchConfig.isPending}
|
||||
onValueChange={(v) => void patch({ hindsight: { memory_mode: v } })}
|
||||
>
|
||||
<SelectTrigger className="w-44">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="context">{m.memoryModeContext}</SelectItem>
|
||||
<SelectItem value="tools">{m.memoryModeTools}</SelectItem>
|
||||
<SelectItem value="hybrid">{m.memoryModeHybrid}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center justify-between gap-3 border-t pt-4">
|
||||
<div className="min-w-0">
|
||||
<label className="text-sm font-medium">{m.recallBudget}</label>
|
||||
<p className="text-muted-foreground text-sm">{m.recallBudgetDesc}</p>
|
||||
</div>
|
||||
<Select
|
||||
value={config.hindsight.recall_budget}
|
||||
disabled={
|
||||
!isWritable("hindsight.recall_budget") || patchConfig.isPending
|
||||
}
|
||||
onValueChange={(v) => void patch({ hindsight: { recall_budget: v } })}
|
||||
>
|
||||
<SelectTrigger className="w-44">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="low">{m.recallBudgetLow}</SelectItem>
|
||||
<SelectItem value="mid">{m.recallBudgetMid}</SelectItem>
|
||||
<SelectItem value="high">{m.recallBudgetHigh}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2 border-t pt-4">
|
||||
<label htmlFor={bankMissionId} className="text-sm font-medium">
|
||||
{m.bankMission}
|
||||
</label>
|
||||
<p className="text-muted-foreground text-sm">{m.bankMissionDesc}</p>
|
||||
<Textarea
|
||||
id={bankMissionId}
|
||||
rows={2}
|
||||
defaultValue={config.hindsight.bank_mission}
|
||||
placeholder={m.bankMissionPlaceholder}
|
||||
disabled={!isWritable("hindsight.bank_mission") || patchConfig.isPending}
|
||||
onBlur={(event) => {
|
||||
const value = event.target.value;
|
||||
if (value !== config.hindsight.bank_mission) {
|
||||
void patch({ hindsight: { bank_mission: value } });
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</SettingsSection>
|
||||
|
||||
Reference in new issue
Block a user