核心架构重构: - Config 按职责拆分为 LlmConfig/EmbeddingConfig/VisionConfig/CdsConfig/StorageConfig 五个子结构 - AppState 拆分为 LlmState/DataSourceState/SessionState 三个子结构,消除 50+ 平铺字段 - 新增 ServiceError 结构化错误类型替代 handler 中的 msg.contains() 字符串匹配 - 移除 api::handlers 兼容命名空间,路由直接引用 agent/auth/papers 等模块 认证性能优化: - login_rate_limiter/upload_rate_limiter 从 Mutex<HashMap> 迁移为 DashMap(无锁) - 新增 session_last_active: DashMap<String, AtomicU64>,auth 中间件快速路径免写锁 - 会话过期清理改为按间隔触发(300s),避免每次请求全表扫描 - MAX_SESSIONS 1000→10000,SSE 广播通道 256→1024 Agent 工具增强: - AgentTool trait 新增 is_internal()/display_name(),SSE 事件携带工具元数据 - 新增 GET /chat/tools 端点暴露注册工具列表 - pending_questions/pending_permissions 增加 created_at 时间戳,自动清理过期条目(10min TTL) - Agent 超时现在正确 abort 后台任务并设置取消令牌 观测数据源修复: - FITS 解析: APOGEE/DESI 改用 read_image+切片替代 read_rows(修复 fitsio panic) - ZTF: CIRCLE 参数分隔符 +→空格(修复 IRSA 400),半径自动裁剪至硬上限 - MAST TESS: parse_tic_json 兼容数组/对象两种 API 响应格式 - 统一检索: per_target_limit 默认 50→1,sources 支持 per-source release/version - Gaia 测光从 VizieR 镜像切换至官方 TAP 服务 RAG 并发优化: - 向量化降级从串行改为并发 5 条/批(buffer_unordered) - 混合检索 RRF 合并从借用改为 owned RetrievalResult 安全加固: - PDF 中间件: URL 解码 %2F/%2E 后判扩展名;文件名过滤非 ASCII + 禁 \ 防头注入 - chat_agent 日志截断问题内容至 50 字符;list_sessions 强制 limit clamp 前端双主题: - 设计令牌三层架构: primitive→semantic→component,浅色暖纸张学术/暗色 Night Indigo - useTheme hook + ThemeToggle 侧边栏组件 + main.tsx 防 FOUC 初始化 - 全组件从硬编码 slate 色迁移至语义令牌(bg-surface/text-content/border-subtle 等) - 新增 ToastContainer 非阻塞通知系统 部署优化: - deploy.sh 引入 SSH ControlMaster 单次密码复用
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
// dashboard/src/components/agent/AnswerCard.tsx
|
|
// 最终答案卡片:展示 Agent 的最终回答
|
|
import { CheckCircle2 } from 'lucide-react';
|
|
import type { ColorScheme } from './constants';
|
|
import { AgentMarkdown } from './AgentMarkdown';
|
|
|
|
interface AnswerCardProps {
|
|
content: string;
|
|
colorScheme: ColorScheme;
|
|
isStreaming?: boolean;
|
|
}
|
|
|
|
export function AnswerCard({
|
|
content,
|
|
colorScheme,
|
|
isStreaming,
|
|
}: AnswerCardProps) {
|
|
return (
|
|
<div className="relative space-y-2">
|
|
<div
|
|
className={`absolute -left-[21px] top-3 w-2.5 h-2.5 rounded-full border-2 border-white ${colorScheme.answer}`}
|
|
/>
|
|
<div className="flex flex-col items-start">
|
|
<span className="text-[10px] font-bold text-tertiary px-1 flex items-center gap-1 mb-1">
|
|
<CheckCircle2
|
|
className={`w-3.5 h-3.5 text-success ${isStreaming ? 'animate-pulse' : ''}`}
|
|
/>
|
|
<span>结论</span>
|
|
</span>
|
|
<div className="w-full rounded-2xl px-5 py-4 text-xs leading-relaxed font-semibold border bg-surface text-content border-subtle prose prose-sm max-w-none select-text prose-headings:text-content prose-headings:font-bold prose-strong:text-content prose-code:text-blueprint prose-img:rounded-lg">
|
|
<AgentMarkdown>{content}</AgentMarkdown>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|