import { useState } from "react"; import { Check } from "lucide-react"; import { setMemory, type Identity } from "../lib/api"; import { Button, Input, Textarea, Field, useToast } from "../ui"; // 偏好记忆面板 —— 让用户显式登记/纠正模型对自己的记忆(→ PUT /api/v1/memory)。 export function MemoryPanel({ identity, onSaved }: { identity: Identity; onSaved?: () => void }) { const toast = useToast(); const [key, setKey] = useState("回答偏好"); const [value, setValue] = useState("简洁、中文、多给要点"); const [saved, setSaved] = useState>([]); const save = async () => { if (!key.trim()) return; try { const m = await setMemory(identity, key.trim(), value.trim()); setSaved((s) => [{ key: key.trim(), value: value.trim() }, ...s.filter((x) => x.key !== key.trim())]); toast.push("success", m); onSaved?.(); } catch (e) { toast.push("error", (e as Error).message); } }; return (

偏好记忆(让模型知道是我)

setKey(e.target.value)} placeholder="如 称呼 / 回答偏好" />