|
| 1 | +/** 消息角色 */ |
| 2 | +export type MessageRole = "user" | "assistant" | "system"; |
| 3 | + |
| 4 | +/** 单条对话消息 */ |
| 5 | +export interface ChatMessage { |
| 6 | + id: string; |
| 7 | + role: MessageRole; |
| 8 | + text: string; |
| 9 | + success?: boolean; |
| 10 | + events?: RunEvent[]; |
| 11 | + /** 时间戳(可选,用于展示) */ |
| 12 | + time?: number; |
| 13 | +} |
| 14 | + |
| 15 | +/** 运行/流式事件(与后端 bridge-event 一致) */ |
| 16 | +export interface RunEvent { |
| 17 | + _event?: boolean; |
| 18 | + type: string; |
| 19 | + data?: Record<string, unknown>; |
| 20 | +} |
| 21 | + |
| 22 | +/** 对话框类型 */ |
| 23 | +export type DialogType = |
| 24 | + | null |
| 25 | + | "help" |
| 26 | + | "backend" |
| 27 | + | "context" |
| 28 | + | "exec" |
| 29 | + | "output" |
| 30 | + | "settings" |
| 31 | + | "ops"; |
| 32 | + |
| 33 | +/** 会话摘要 */ |
| 34 | +export interface Conversation { |
| 35 | + id: string; |
| 36 | + title: string; |
| 37 | + createdAt: number; |
| 38 | +} |
| 39 | + |
| 40 | +/** 后端 bridge_send 返回 */ |
| 41 | +export interface BridgeResponse { |
| 42 | + ok: boolean; |
| 43 | + message: string; |
| 44 | + /** 部分命令(如 list_models)返回的列表 */ |
| 45 | + models?: MyComsolModel[]; |
| 46 | +} |
| 47 | + |
| 48 | +/** 设置页「我创建的模型」列表项 */ |
| 49 | +export interface MyComsolModel { |
| 50 | + path: string; |
| 51 | + title: string; |
| 52 | + is_latest?: boolean; |
| 53 | +} |
| 54 | + |
| 55 | +/** 斜杠命令项(Prompt 下拉用) */ |
| 56 | +export interface SlashCommandItem { |
| 57 | + name: string; |
| 58 | + display: string; |
| 59 | + description: string; |
| 60 | +} |
| 61 | + |
| 62 | +export const SLASH_COMMANDS: SlashCommandItem[] = [ |
| 63 | + { name: "help", display: "/help", description: "显示帮助" }, |
| 64 | + { name: "ops", display: "/ops", description: "支持的 COMSOL 操作" }, |
| 65 | + { name: "run", display: "/run", description: "默认模式(自然语言 → 模型)" }, |
| 66 | + { name: "plan", display: "/plan", description: "计划模式(自然语言 → JSON)" }, |
| 67 | + { name: "exec", display: "/exec", description: "根据 JSON 创建模型" }, |
| 68 | + { name: "backend", display: "/backend", description: "选择 LLM 后端" }, |
| 69 | + { name: "context", display: "/context", description: "查看或清除对话历史" }, |
| 70 | + { name: "output", display: "/output", description: "设置默认输出文件名" }, |
| 71 | + { name: "demo", display: "/demo", description: "演示示例" }, |
| 72 | + { name: "doctor", display: "/doctor", description: "环境诊断" }, |
| 73 | + { name: "exit", display: "/exit", description: "退出" }, |
| 74 | +]; |
| 75 | + |
| 76 | +/** 常用场景快捷提示(MessageList 空状态) */ |
| 77 | +export interface QuickPromptItem { |
| 78 | + label: string; |
| 79 | + text: string; |
| 80 | +} |
| 81 | + |
| 82 | +export interface QuickPromptGroup { |
| 83 | + title: string; |
| 84 | + hint?: string; |
| 85 | + prompts: QuickPromptItem[]; |
| 86 | +} |
| 87 | + |
| 88 | +export const QUICK_PROMPT_GROUPS: QuickPromptGroup[] = [ |
| 89 | + { |
| 90 | + title: "几何", |
| 91 | + hint: "2D/3D", |
| 92 | + prompts: [ |
| 93 | + { label: "矩形", text: "创建一个宽 1 米、高 0.5 米的矩形" }, |
| 94 | + { label: "圆", text: "创建一个半径为 0.2 米的圆" }, |
| 95 | + { label: "长方体", text: "创建一个 1×0.5×0.3 米的长方体" }, |
| 96 | + ], |
| 97 | + }, |
| 98 | + { |
| 99 | + title: "物理与求解", |
| 100 | + hint: "传热/稳态", |
| 101 | + prompts: [ |
| 102 | + { label: "传热稳态", text: "添加固体传热物理场并做稳态研究" }, |
| 103 | + { label: "结构静力学", text: "添加固体力学并做稳态研究" }, |
| 104 | + ], |
| 105 | + }, |
| 106 | + { |
| 107 | + title: "诊断与命令", |
| 108 | + hint: "环境/帮助", |
| 109 | + prompts: [ |
| 110 | + { label: "环境诊断", text: "/doctor" }, |
| 111 | + { label: "帮助", text: "/help" }, |
| 112 | + ], |
| 113 | + }, |
| 114 | +]; |
| 115 | + |
| 116 | +/** COMSOL 操作说明(/ops 弹窗) */ |
| 117 | +export interface ComsolOp { |
| 118 | + action: string; |
| 119 | + label: string; |
| 120 | + description: string; |
| 121 | +} |
| 122 | + |
| 123 | +export const COMSOL_OPS: ComsolOp[] = [ |
| 124 | + { action: "geometry", label: "几何", description: "创建/编辑几何体与布尔运算" }, |
| 125 | + { action: "physics", label: "物理场", description: "添加物理场与边界条件" }, |
| 126 | + { action: "mesh", label: "网格", description: "划分网格" }, |
| 127 | + { action: "study", label: "研究", description: "稳态/瞬态/特征值等研究" }, |
| 128 | + { action: "material", label: "材料", description: "材料分配与属性" }, |
| 129 | +]; |
0 commit comments