Files
QuestionProject/ai_knowledge_base_v2/apps/admin-web/src/config/systemSettings.ts

278 lines
8.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
export type SystemSettingValue = string | number | boolean;
type SystemSettingType = "number" | "switch" | "text" | "password";
export interface SystemSettingDefinition {
key: string;
label: string;
type: SystemSettingType;
defaultValue: SystemSettingValue;
min?: number;
max?: number;
placeholder?: string;
description: string;
}
export interface SystemSettingSection {
title: string;
description: string;
settings: SystemSettingDefinition[];
}
export const systemSettingSections: SystemSettingSection[] = [
{
title: "用户与登录",
description: "控制学员准入、默认资料、验证码和登录态有效时间。",
settings: [
{
key: "daily_chat_limit",
label: "默认每日聊天额度",
type: "number",
defaultValue: 100,
min: 0,
max: 100000,
description: "新建或导入学员未单独填写额度时使用。",
},
{
key: "access_token_expire_minutes",
label: "登录 Token 有效期(分钟)",
type: "number",
defaultValue: 43200,
min: 5,
max: 43200,
description: "用户端和管理端登录后的 Token 有效期。",
},
{
key: "sms_code_expire_minutes",
label: "验证码有效期(分钟)",
type: "number",
defaultValue: 5,
min: 1,
max: 60,
description: "短信验证码生成后的可使用时间。",
},
{
key: "mock_sms_enabled",
label: "使用 mock 短信",
type: "switch",
defaultValue: true,
description: "开发和演示环境可开启,生产环境应关闭并接入真实短信。",
},
{
key: "mock_sms_code",
label: "mock 短信验证码",
type: "text",
defaultValue: "123456",
placeholder: "例如 123456",
description: "mock 短信开启时使用的固定验证码。",
},
{
key: "aliyun_sms_access_key_id",
label: "阿里云 AccessKey ID",
type: "password",
defaultValue: "",
placeholder: "请输入 RAM 用户 AccessKey ID",
description: "关闭 mock 短信后用于调用阿里云短信服务。",
},
{
key: "aliyun_sms_access_key_secret",
label: "阿里云 AccessKey Secret",
type: "password",
defaultValue: "",
placeholder: "请输入 RAM 用户 AccessKey Secret",
description: "敏感配置,建议使用最小权限 RAM 用户。",
},
{
key: "aliyun_sms_sign_name",
label: "阿里云短信签名",
type: "text",
defaultValue: "",
placeholder: "例如 某某课堂",
description: "需与阿里云短信控制台审核通过的签名一致。",
},
{
key: "aliyun_sms_template_code",
label: "阿里云模板 Code",
type: "text",
defaultValue: "",
placeholder: "例如 SMS_123456789",
description: "验证码短信模板 Code。",
},
{
key: "aliyun_sms_template_param_key",
label: "验证码变量名",
type: "text",
defaultValue: "code",
placeholder: "默认 code",
description: "模板中验证码变量名,例如模板变量为 ${code} 时填写 code。",
},
{
key: "aliyun_sms_endpoint",
label: "阿里云短信 Endpoint",
type: "text",
defaultValue: "dysmsapi.aliyuncs.com",
placeholder: "dysmsapi.aliyuncs.com",
description: "一般保持默认值即可。",
},
{
key: "default_user_name_prefix",
label: "默认用户名前缀",
type: "text",
defaultValue: "用户",
placeholder: "例如 用户",
description: "系统需要生成默认名称时使用的前缀。",
},
],
},
{
title: "AI 问答",
description: "控制 Agent 调用、上下文和用户端回答展示策略。",
settings: [
{
key: "ai_timeout_seconds",
label: "AI 请求超时(秒)",
type: "number",
defaultValue: 60,
min: 5,
max: 300,
description: "真实模型请求超过该时间应判定为超时。",
},
{
key: "mock_model_enabled",
label: "使用 mock 大模型",
type: "switch",
defaultValue: true,
description: "开发和演示环境可开启,真实模型验收前应关闭。",
},
{
key: "chat_context_message_count",
label: "上下文消息数",
type: "number",
defaultValue: 10,
min: 0,
max: 100,
description: "当前会话带入模型的最近历史消息条数;更早内容会滚动摘要,设为 0 将关闭会话记忆。修改后下一次提问立即生效。",
},
{
key: "show_reference_sources",
label: "用户端展示引用来源",
type: "switch",
defaultValue: true,
description: "后台始终记录引用;此项控制用户端是否展示。",
},
{
key: "chat_max_active_requests",
label: "问答最大并发数",
type: "number",
defaultValue: 2,
min: 1,
max: 1000,
description: "同一后端进程内同时进入飞书和模型生成链路的最大请求数。",
},
{
key: "chat_max_queue_size",
label: "问答最大排队数",
type: "number",
defaultValue: 20,
min: 0,
max: 10000,
description: "超过最大并发后允许等待的请求数量,超过后直接提示稍后再试。",
},
{
key: "chat_queue_timeout_seconds",
label: "问答排队超时(秒)",
type: "number",
defaultValue: 60,
min: 1,
max: 3600,
description: "请求在排队中超过该时间后自动结束并提示用户稍后再试。",
},
{
key: "chat_active_lease_seconds",
label: "问答执行租约(秒)",
type: "number",
defaultValue: 900,
min: 60,
max: 86400,
description: "Redis 全局队列中执行名额的自动过期时间,防止 worker 异常退出后长期占用并发名额。",
},
],
},
{
title: "外部服务",
description: "控制飞书搜索接口、飞书直读超时和重试策略。",
settings: [
{
key: "feishu_search_url",
label: "飞书检索服务地址",
type: "text",
defaultValue: "",
placeholder: "例如 https://example.com/search",
description: "如使用独立飞书检索适配服务,在这里填写调用地址。",
},
{
key: "feishu_app_id",
label: "飞书应用 AppID",
type: "text",
defaultValue: "",
placeholder: "填写飞书开放平台应用 AppID",
description: "用于后端直读飞书知识库;系统设置优先于环境变量。",
},
{
key: "feishu_app_secret",
label: "飞书应用 AppSecret",
type: "password",
defaultValue: "",
placeholder: "填写飞书开放平台应用 AppSecret",
description: "用于后端获取飞书 tenant_access_token保存后立即生效。",
},
{
key: "feishu_timeout_seconds",
label: "飞书请求超时(秒)",
type: "number",
defaultValue: 20,
min: 1,
max: 120,
description: "飞书相关接口调用超过该时间应判定为超时。",
},
{
key: "feishu_retry_count",
label: "飞书检索重试次数",
type: "number",
defaultValue: 2,
min: 0,
max: 10,
description: "飞书检索失败时的最大重试次数。",
},
],
},
{
title: "系统开关",
description: "控制系统级展示和运行策略,不包含密钥类配置。",
settings: [
{
key: "show_operation_log_detail",
label: "展示操作日志详情",
type: "switch",
defaultValue: true,
description: "开启后后台审计页可展示更完整的操作上下文。",
},
{
key: "chat_export_enabled",
label: "允许导出聊天记录",
type: "switch",
defaultValue: true,
description: "关闭后后台不应提供聊天记录导出能力。",
},
{
key: "maintenance_mode",
label: "维护模式",
type: "switch",
defaultValue: false,
description: "预留给后续停机维护提示和访问控制使用。",
},
],
},
];
export const systemSettingDefinitions = systemSettingSections.flatMap((section) => section.settings);