Update profile AI model

This commit is contained in:
tianma committed 2026-07-01 00:08:23 +08:00
1 parent e53fc2cab2
commit ee5d0b9ca9
2 files changed
+25 -3

No files matched your search

+1 -1
View File
@@ -216,7 +216,7 @@ const PASSWORD_SALT_BYTES = 16;
const SESSION_TOKEN_BYTES = 32;
const DEFAULT_SESSION_TTL_DAYS = 30;
const DEFAULT_R2_BUCKET_NAME = "edgeever-resources";
const DEFAULT_PROFILE_MODEL = "@cf/meta/llama-3.1-8b-instruct";
const DEFAULT_PROFILE_MODEL = "@cf/zai-org/glm-5.2";
const PROFILE_MEMO_LIMIT = 200;
const PROFILE_MEMO_TEXT_LIMIT = 1200;
const PROFILE_CHUNK_CHAR_LIMIT = 12000;
+24 -2
View File
@@ -8,7 +8,7 @@ import { Checkbox } from "@/components/ui/checkbox";
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import { Switch } from "@/components/ui/switch";
import { api } from "@/lib/api";
import { ApiRequestError, api } from "@/lib/api";
import { EVERNOTE_MIGRATION_PATH } from "@/lib/routes";
import { cn, formatDateTime } from "@/lib/utils";
import { AppConfirmDialog } from "./dialogs/ConfirmDialogs";
@@ -148,6 +148,28 @@ const confidenceLabel: Record<ProfileSnapshot["sections"][number]["insights"][nu
high: "依据较多",
};
const getProfileErrorMessage = (error: unknown) => {
if (!error) {
return undefined;
}
if (error instanceof ApiRequestError) {
if (error.code === "ai_request_failed") {
return "Cloudflare Workers AI 调用失败。请确认部署环境的 Workers AI 可用,或在环境变量 EDGE_EVER_PROFILE_MODEL 中指定一个当前可用的文本生成模型。";
}
if (error.code === "ai_not_configured") {
return "当前部署还没有配置 Workers AI binding,暂时无法生成人物画像。";
}
if (error.code === "no_profile_sources") {
return "还没有足够的有效笔记用于生成人物画像。";
}
}
return error instanceof Error ? error.message : "人物画像请求失败。";
};
const PersonaProfileCard = ({ profile, isLoading, isGenerating, errorMessage, onGenerate }: PersonaProfileCardProps) => (
<Card className="w-full min-w-0 overflow-hidden shadow-none">
<CardHeader className="p-4">
@@ -814,7 +836,7 @@ export const SettingsPane = ({
profile={profile}
isLoading={profileQuery.isLoading}
isGenerating={generateProfileMutation.isPending}
errorMessage={generateProfileMutation.error?.message ?? profileQuery.error?.message}
errorMessage={getProfileErrorMessage(generateProfileMutation.error ?? profileQuery.error)}
onGenerate={() => generateProfileMutation.mutate()}
/>
<EvernoteImportGuideCard onShowGuide={onShowGuide} />