constants.ts 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /**
  2. * AI 数据分析应用 —— 常量与展示映射
  3. */
  4. import { useGlobSetting } from '@/core/hooks/setting';
  5. const glob = useGlobSetting();
  6. /** 后端管理路径前缀(defHttp 会自动再加 urlPrefix=/js) */
  7. export const AI_ADMIN_PATH = glob.adminPath || '/a';
  8. /** 接口完整前缀:/js/a —— 与后端 context-path 一致 */
  9. export const AI_API_PREFIX = `${glob.urlPrefix || ''}${AI_ADMIN_PATH}`;
  10. /** 后端根地址(生产环境为绝对地址,开发环境为空走代理) */
  11. export const AI_API_ORIGIN = glob.apiUrl || '';
  12. /**
  13. * 拼接后端可达地址(含 origin)。
  14. * 用于 fetch / img src 这类不走 defHttp 的场景。
  15. */
  16. export function resolveApiUrl(path: string): string {
  17. const p = path.startsWith('/') ? path : `/${path}`;
  18. return `${AI_API_ORIGIN}${AI_API_PREFIX}${p}`;
  19. }
  20. /** 流式对话地址 */
  21. export const CHAT_STREAM_URL = resolveApiUrl('/chat/stream');
  22. /** 会话列表默认每页条数(前端本地分页) */
  23. export const SESSION_PAGE_SIZE = 20;
  24. /* ------------------------------------------------------------------ *
  25. * 工具名称 → 中文展示
  26. *
  27. * 覆盖聊天时间线/状态栏/产物栏会露出来的全部工具(后端 @Tool 名,见
  28. * ai-server .../module/agent/tools 与 mcp/AgentScopeMcpToolProvider)。
  29. * ★ 加了新工具要同步补这里,否则时间线会退回显示英文工具名;
  30. * 产物文件名的中文前缀另有一份(后端 ArtifactService.ARTIFACT_LABELS)。
  31. * ------------------------------------------------------------------ */
  32. export const TOOL_LABELS: Record<string, string> = {
  33. // ---- 基础设施 ----
  34. execute_sql: '执行 SQL 查询',
  35. list_tables: '列出数据表',
  36. search_table_schema: '检索表结构',
  37. query_table_data: '查询表格数据',
  38. execute_python: '执行 Python 分析',
  39. render_chart: '校验图表配置',
  40. render_graph: '校验关系图谱',
  41. get_current_workspace: '读取当前工作空间',
  42. get_user_selected_workspace: '读取用户所选空间',
  43. get_case_graph: '取关系图谱数据',
  44. // ---- 人员画像与亲密度(person) ----
  45. list_persons: '列出案件人员',
  46. get_person_call_profile: '通话数据画像',
  47. stat_person_call_station: '通话基站分布',
  48. stat_person_call_top10: '最常联系人 TOP10',
  49. stat_call_record_summary: '通话记录汇总',
  50. get_person_trans_profile: '交易数据画像',
  51. stat_person_trans_top10: '最常交易对手 TOP10',
  52. stat_trans_record_summary: '交易记录汇总',
  53. get_trans_bank_card_info: '银行卡交易汇总',
  54. stat_trans_amount_trend_month: '交易金额月度趋势',
  55. stat_trans_amount_trend_year: '交易金额年度趋势',
  56. stat_intimacy_summary: '亲密度总览',
  57. // ---- 通话明细(call) ----
  58. get_call_records: '查询通话明细',
  59. stat_call_night_summary: '夜间通话汇总',
  60. stat_call_night_detail: '夜间通话明细',
  61. stat_call_continuous_summary: '持续通话汇总',
  62. stat_call_continuous_detail: '持续通话明细',
  63. stat_call_sensitive_summary: '敏感日期通话汇总',
  64. stat_call_sensitive_detail: '敏感日期通话明细',
  65. // ---- 交易与资金(trans) ----
  66. get_trans_records: '查询交易明细',
  67. stat_trans_big_summary: '大额交易汇总',
  68. stat_trans_big_by_date: '大额交易按日统计',
  69. stat_trans_big_detail: '大额交易明细',
  70. stat_trans_together: '共同交易分析',
  71. stat_trans_card_hold: '代持卡分析',
  72. stat_trans_cash_flow: '交易现金流汇总',
  73. stat_trans_continuous_summary: '持续交易汇总',
  74. stat_trans_continuous_detail: '持续交易明细',
  75. stat_trans_fast_fund_flow: '资金快转分析',
  76. stat_trans_financial: '金融交易筛选',
  77. stat_trans_fixed_deposit: '定期存款汇总',
  78. stat_trans_fixed_deposit_detail: '定期存款明细',
  79. stat_trans_frequency: '交易频次统计',
  80. stat_trans_sensitive_summary: '敏感日期交易汇总',
  81. stat_trans_sensitive_detail: '敏感日期交易明细',
  82. // ---- 轨迹 / 出行 / 快递(track) ----
  83. stat_track_cell_tower_summary: '基站轨迹汇总',
  84. stat_track_cell_tower_detail: '基站轨迹明细',
  85. stat_track_en_local_summary: '境外昼夜活动汇总',
  86. stat_track_en_local_detail: '境外昼夜活动明细',
  87. stat_express_summary: '快递收寄汇总',
  88. stat_express_by_phone: '按号码查快递',
  89. get_express_records: '查询快递明细',
  90. stat_track_meet_summary: '人员碰面汇总',
  91. stat_track_meet_detail: '人员碰面明细',
  92. stat_together_live_summary: '同住关系汇总',
  93. stat_together_live_detail: '同住关系明细',
  94. get_hotel_stay_detail: '旅馆住宿明细',
  95. get_together_live_info_detail: '同住服务记录明细',
  96. stat_together_travel_summary: '同行出行汇总',
  97. stat_together_travel_detail: '同行出行明细',
  98. get_travel_record_detail: '出行票务明细',
  99. // ---- 关系图谱(graph) ----
  100. // get_case_graph 见基础段
  101. // ---- 非表格材料档案(file) ----
  102. list_file_profiles: '检索材料清单',
  103. stat_file_profiles_by_category: '材料分类统计',
  104. get_file_sample: '读取材料正文片段',
  105. // ---- 案件管理(MCP 接入用) ----
  106. list_cases: '列出案件清单',
  107. open_case: '切换案件',
  108. current_case: '查看当前案件',
  109. close_case: '解除案件绑定',
  110. // ---- 框架内置(AgentScope 提供,源码里没有 @Tool 注解) ----
  111. reset_equipped_tools: '切换工具组',
  112. };
  113. export function toolLabel(name?: string): string {
  114. if (!name) return '工具调用';
  115. return TOOL_LABELS[name] || name;
  116. }
  117. /* ------------------------------------------------------------------ *
  118. * 富内容块
  119. * ------------------------------------------------------------------ */
  120. /** 块类型 */
  121. export type BlockKind = 'markdown' | 'code' | 'html' | 'echarts' | 'graph' | 'image' | 'insight';
  122. /** 围栏语言 → 块类型 */
  123. export const FENCE_BLOCK_MAP: Record<string, BlockKind> = {
  124. echarts: 'echarts',
  125. graph: 'graph',
  126. html: 'html',
  127. // AI 研判结构化产物(线索 + 下一步思路),契约见 InsightPromptBuilder#RENDER_CONTRACT。
  128. // ★ 改契约必须两头一起改:后端提示词 / scanner 校验 / blocks/InsightBlock.vue
  129. insight: 'insight',
  130. };
  131. /** 代码块中需要高亮/特殊展示的语言(非富渲染) */
  132. export const PLAIN_CODE_LANGS = [
  133. 'json',
  134. 'sql',
  135. 'python',
  136. 'bash',
  137. 'sh',
  138. 'text',
  139. 'plaintext',
  140. 'yaml',
  141. 'xml',
  142. 'java',
  143. 'ts',
  144. 'js',
  145. 'vue',
  146. 'css',
  147. 'less',
  148. ];
  149. /* ------------------------------------------------------------------ *
  150. * 业务工具组(与后端 AgentToolRegistry#groupLabel 保持一致)
  151. * ------------------------------------------------------------------ */
  152. /** 业务工具组短标签:研判方案页展示 / 编辑弹窗勾选项标题用 */
  153. export const TOOL_GROUP_LABELS: Record<string, string> = {
  154. person: '人员画像与亲密度',
  155. call: '通话分析',
  156. trans: '交易与资金分析',
  157. track: '轨迹、出行与快递',
  158. graph: '关系图谱',
  159. file: '非表格材料档案',
  160. };
  161. /** 研判方案配置里可能出现的全部业务组(顺序即页面展示顺序) */
  162. export const TOOL_GROUP_KEYS = Object.keys(TOOL_GROUP_LABELS);
  163. export function toolGroupLabel(group?: string | null): string {
  164. if (!group) return '';
  165. return TOOL_GROUP_LABELS[group] || group;
  166. }
  167. /* ------------------------------------------------------------------ *
  168. * 报告导出
  169. * ------------------------------------------------------------------ */
  170. export type ReportFormat = 'markdown' | 'pdf';
  171. export const REPORT_FORMATS: Array<{ value: ReportFormat; label: string; icon: string; tip: string }> = [
  172. { value: 'markdown', label: 'Markdown', icon: 'mdi:language-markdown', tip: '导出 .md 纯文本,保留原始结构与围栏块' },
  173. { value: 'pdf', label: 'PDF', icon: 'mdi:file-pdf-box', tip: '调用浏览器打印,选择"另存为 PDF"' },
  174. ];
  175. /* ------------------------------------------------------------------ *
  176. * 流式渲染节流参数
  177. * ------------------------------------------------------------------ */
  178. /** 尾部重扫窗口(字节/字符)——已解析完成的块会被冻结,仅重扫尾部窗口 */
  179. export const TAIL_RESCAN_SIZE = 8 * 1024;
  180. /** 增量重扫最小间隔(毫秒) */
  181. export const RESCAN_THROTTLE_MS = 100;