feat(阶段三): 实现AI提示词编辑功能

- 集成 Monaco Editor 用于提示词编辑
- 创建提示词变量配置(14个可用变量)
- 创建提示词模板库(5个预设模板)
- 实现 PromptTemplateService 服务类
- 创建变量替换和预览功能
- 添加 PreviewPromptAction 用于预览提示词
- 创建变量帮助文档和模板选择器视图组件
- 支持变量验证和自动替换
This commit is contained in:
2026-03-09 10:59:45 +08:00
parent 3b90d97f02
commit 1d30fb1d4c
11 changed files with 866 additions and 1 deletions

146
config/prompt_variables.php Normal file
View File

@@ -0,0 +1,146 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| AI提示词可用变量
|--------------------------------------------------------------------------
|
| 定义在AI提示词模板中可以使用的变量列表
| 每个变量包含:名称、描述、示例值、类型
|
*/
'variables' => [
[
'name' => 'user',
'label' => '用户名称',
'description' => '当前登录用户的姓名',
'example' => '张三',
'type' => 'string',
'category' => 'user',
],
[
'name' => 'user_id',
'label' => '用户ID',
'description' => '当前登录用户的唯一标识符',
'example' => '12345',
'type' => 'integer',
'category' => 'user',
],
[
'name' => 'user_role',
'label' => '用户角色',
'description' => '当前登录用户的角色',
'example' => '操作员',
'type' => 'string',
'category' => 'user',
],
[
'name' => 'station',
'label' => '工作站名称',
'description' => '终端所在的工作站名称',
'example' => '生产线A-工位1',
'type' => 'string',
'category' => 'station',
],
[
'name' => 'station_id',
'label' => '工作站ID',
'description' => '终端所在的工作站ID',
'example' => '1001',
'type' => 'integer',
'category' => 'station',
],
[
'name' => 'terminal_name',
'label' => '终端名称',
'description' => '当前终端的名称',
'example' => 'TERM-0001',
'type' => 'string',
'category' => 'terminal',
],
[
'name' => 'terminal_code',
'label' => '终端编码',
'description' => '当前终端的唯一编码',
'example' => 'TERM-0001',
'type' => 'string',
'category' => 'terminal',
],
[
'name' => 'time',
'label' => '当前时间',
'description' => '当前的日期和时间',
'example' => '2024-01-15 14:30:00',
'type' => 'datetime',
'category' => 'time',
],
[
'name' => 'date',
'label' => '当前日期',
'description' => '当前的日期',
'example' => '2024-01-15',
'type' => 'date',
'category' => 'time',
],
[
'name' => 'time_only',
'label' => '当前时刻',
'description' => '当前的时间(不含日期)',
'example' => '14:30:00',
'type' => 'time',
'category' => 'time',
],
[
'name' => 'shift',
'label' => '当前班次',
'description' => '当前的工作班次',
'example' => '早班',
'type' => 'string',
'category' => 'time',
],
[
'name' => 'knowledge_bases',
'label' => '关联知识库',
'description' => '终端关联的知识库列表',
'example' => '安全操作规程, 设备维护手册',
'type' => 'array',
'category' => 'knowledge',
],
[
'name' => 'company_name',
'label' => '公司名称',
'description' => '系统配置的公司名称',
'example' => 'XX制造有限公司',
'type' => 'string',
'category' => 'system',
],
[
'name' => 'department',
'label' => '部门名称',
'description' => '用户所属的部门',
'example' => '生产部',
'type' => 'string',
'category' => 'user',
],
],
/*
|--------------------------------------------------------------------------
| 变量分类
|--------------------------------------------------------------------------
|
| 变量的分类标签用于在UI中分组显示
|
*/
'categories' => [
'user' => '用户信息',
'station' => '工作站信息',
'terminal' => '终端信息',
'time' => '时间信息',
'knowledge' => '知识库信息',
'system' => '系统信息',
],
];