[quiz] feat: 会话总结一键出题 + 聊天 "/" 命令栏与 skills 强制注入(含 frontendv2) - #80
Merged
Conversation
- prompts.py: 回答规范第4条改为「总述+分点展开+收尾」结构要求,新增详尽度 ❌/✅ 对照示例;寒暄类保持简洁 - main.py: harness LLM temperature 0 → 0.4(输出更舒展;LLM 为全部 agent 共享) - vector_search.py: 默认 k 5→8、每视频展示 chunk 上限 3→6,工具描述引导深度问题用 k=10-15(RAGService over-recall≥30,放大 k 安全)
会话总结出题(非定时): - POST /quiz/generate-from-summary:会话归属/消息/Agent 在线预检 + 配额,建 quiz_sets 行(source_type=session_summary)后 BackgroundTasks 生成 - services/quiz_from_summary.py:get_or_create_summary 复用/自动生成总结并持久化(与总结弹窗共享同一份)→ 总结切伪 chunk → 复用 quiz agent 的 generate_questions → 落库现有 quiz_sets/quiz_questions,答题/批改/错题本全复用 - session_summary.py:抽出共享持久化 _insert_summary_record + 非流式 get_or_create_summary - models.py/system.sql:quiz_sets 加 nullable chat_session_id(MySQL 附加列,无 Milvus 影响) skills 强制注入(按请求,Claude Code 式): - ChatRequest.skill_ids(≤10)→ dispatcher 透传 → ChatAgentState → inject_context 并发加载全文 → system prompt 新增「用户指定技能」区块;未安装跳过告警 配额两阶段修复(用量统计不准): - quiz_quota 新增 check_quota(peek 不消耗);两个出题端点改为 peek→建行→consume:被拒不建行不扣额、建行失败不烧配额、竞态容忍 自动迁移补登: - database.py 迁移列表登记 quiz_sets.chat_session_id + _ensure_index 索引(存量库重启自动补齐,幂等) frontendv2: - slash-menu.tsx:Codex 风格命令栏(命令/Skills 两组,↑↓/Enter/Tab/Esc,Skills 多选) - chat-input.tsx:"/" 触发+过滤+键盘拦截、已选 skills chips、发送携带 skill_ids(仅单条消息生效) - quiz-from-summary-dialog.tsx:配置→轮询→成功跳题库向导;quiz-view 支持 ?quiz= 深链 - lib/api:chat.ts 加 skill_ids、quiz.ts 加 generateFromSummary 测试:test_quiz_from_summary.py 27 例(chunk 切分/题型分布/总结复用/预检/透传/配额顺序);ruff 全绿
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
两个功能 + 两组配套修复,共 2 个提交:
POST /quiz/generate-from-summary:基于会话总结出题,无总结时自动生成并持久化(与总结弹窗共享同一份);题目复用 quiz agent 的generate_questions,落库现有 quiz_sets/quiz_questions,答题/批改/错题本全复用配套修复
quiz_sets.chat_session_id补登进database.py _migrate_add_columns+ 索引 ensure(存量库重启自动补齐,已对真实库验证幂等;之前线上 1054 即缺此登记)quiz_quota新增 peek 式check_quota;两个出题端点改为 peek→建行→consume——被拒不建行不扣额、建行失败不烧配额、竞态容忍数据库变更
quiz_sets新增 nullablechat_session_id VARCHAR(64)+ 索引(MySQL 附加列,无 Milvus 影响;system.sql 已同步,启动自动迁移已登记)测试
test_quiz_from_summary.py27 例:伪 chunk 切分 / 题型分布 / get_or_create_summary 复用路径 / 预检 404/400/503 / dispatcher skill_ids 透传 / 配额 peek 语义与路由顺序ruff check app/全绿;frontendv2tsc --noEmit+next build通过