Browse Source

jbot2框架新提示词修改,复合语义和跨领域语义识别执行

wjg 1 year ago
parent
commit
01239ebbd6
68 changed files with 810 additions and 816 deletions
  1. 0 7
      app/src/main/assets/cfg/dataset/smarthome/device_types.json
  2. 0 10
      app/src/main/assets/cfg/dataset/smarthome/sh_cmd_list.json
  3. 0 12
      app/src/main/assets/cfg/dataset/testgpt/center_topics.json
  4. 0 10
      app/src/main/assets/cfg/dataset/testgpt/tg_cmd_list.json
  5. 0 10
      app/src/main/assets/cfg/dataset/tvass/media_cmdlist.json
  6. 0 7
      app/src/main/assets/cfg/dataset/tvass/tv_cmd_list.json
  7. 0 8
      app/src/main/assets/cfg/dataset/tvass/tv_play_mode.json
  8. 1 1
      app/src/main/assets/cfg/domains/system/domain.json
  9. 8 0
      app/src/main/assets/cfg/jedge.json
  10. 0 44
      app/src/main/assets/cfg/picker/jsh/addDevice.json
  11. 0 30
      app/src/main/assets/cfg/picker/jsh/command.json
  12. 58 0
      app/src/main/assets/cfg/picker/jsh/command.tpl
  13. 0 7
      app/src/main/assets/cfg/picker/jsh/setBrightness.json
  14. 0 25
      app/src/main/assets/cfg/picker/jsh/setColorMode.json
  15. 0 7
      app/src/main/assets/cfg/picker/jsh/setColorTemperature.json
  16. 0 7
      app/src/main/assets/cfg/picker/jsh/setFlowMode.json
  17. 0 7
      app/src/main/assets/cfg/picker/jsh/setLighterMode.json
  18. 0 23
      app/src/main/assets/cfg/picker/mediaAcc/command.json
  19. 49 0
      app/src/main/assets/cfg/picker/mediaAcc/command.tpl
  20. 0 6
      app/src/main/assets/cfg/picker/mediaAcc/queryMovie.json
  21. 0 6
      app/src/main/assets/cfg/picker/mediaAcc/queryMovieUSB.json
  22. 0 18
      app/src/main/assets/cfg/picker/system/cutter.json
  23. 61 0
      app/src/main/assets/cfg/picker/system/domain.rel.tpl
  24. 43 0
      app/src/main/assets/cfg/picker/system/domain.tpl
  25. 1 1
      app/src/main/assets/cfg/picker/system/task.json
  26. 37 0
      app/src/main/assets/cfg/picker/system/taskMake.tpl
  27. 0 26
      app/src/main/assets/cfg/picker/tvctrl/command.json
  28. 52 0
      app/src/main/assets/cfg/picker/tvctrl/command.tpl
  29. 0 7
      app/src/main/assets/cfg/picker/tvctrl/setDisplay.json
  30. 0 7
      app/src/main/assets/cfg/picker/tvctrl/setVolume.json
  31. 0 7
      app/src/main/assets/cfg/picker/tvctrl/switchChannel.json
  32. 0 7
      app/src/main/assets/cfg/picker/tvctrl/switchSource.json
  33. 0 7
      app/src/main/assets/cfg/picker/tvctrl/tvHelp.json
  34. 0 7
      app/src/main/assets/cfg/picker/tvctrl/tvStatus.json
  35. 7 37
      app/src/main/java/com/ch/jedge/bots/jsmart/JedgeSmartHomeBot.java
  36. 17 22
      app/src/main/java/com/ch/jedge/bots/tvass/JedgeTVAssistant.java
  37. 3 3
      app/src/main/java/com/ch/jedge/glm/JedgeGlmBridgeService.java
  38. 4 4
      app/src/main/java/com/ch/jedge/glm/zhipuai/StandardEventSourceListener.java
  39. 14 12
      app/src/main/java/com/ch/jedge/jbot/JedgeBotGptService.java
  40. 4 2
      app/src/main/java/com/ch/jedge/jbot/JedgeDomainTesterOld.java
  41. 6 3
      app/src/main/java/com/ch/jedge/jbot/other/corpus/CorpusTask.java
  42. 12 5
      app/src/main/java/com/ch/jedge/jbot2/JedgeBotGptService.java
  43. 2 1
      app/src/main/java/com/ch/jedge/jbot2/JedgeVoiceBotService.java
  44. 123 39
      app/src/main/java/com/ch/jedge/jbot2/intent/JedgeJBotCBService.java
  45. 1 1
      app/src/main/java/com/ch/jedge/jbot2/intent/bot/JBotAppClient.java
  46. 4 1
      app/src/main/java/com/ch/jedge/jbot2/llm/JedgeLLMContext.java
  47. 47 0
      app/src/main/java/com/ch/jedge/jbot2/llm/debug/JedgeLLMDataRecorder.java
  48. 105 63
      app/src/main/java/com/ch/jedge/jbot2/llm/pickers/JedgeLLMParamPicker.java
  49. 8 14
      app/src/main/java/com/ch/jedge/jbot2/llm/pickers/JedgeLLMParamPickerManager.java
  50. 0 15
      app/src/main/java/com/ch/jedge/jbot2/llm/pickers/JedgeSmartHomeActionPicker.java
  51. 0 9
      app/src/main/java/com/ch/jedge/jbot2/llm/pickers/JedgeTaskObjectivePicker.java
  52. 0 50
      app/src/main/java/com/ch/jedge/jbot2/llm/request/JedgeLLMCOTRequest.java
  53. 0 55
      app/src/main/java/com/ch/jedge/jbot2/llm/request/JedgeLLMFilterRequest.java
  54. 0 32
      app/src/main/java/com/ch/jedge/jbot2/llm/request/JedgeLLMRequest.java
  55. 35 0
      app/src/main/java/com/ch/jedge/jbot2/llm/request/JedgeLLMRequestMaker.java
  56. 8 1
      app/src/main/java/com/ch/jedge/jbot2/llm/world/JedgeLLMDmWorld.java
  57. 14 0
      app/src/main/java/com/ch/jedge/jbot2/llm/world/knl/JedgeDomainQueryMaker.java
  58. 2 3
      app/src/main/java/com/ch/jedge/jbot2/llm/world/knl/JedgeDomainSelector.java
  59. 16 55
      app/src/main/java/com/ch/jedge/jbot2/llm/world/knl/JedgeLLMKnWorld.java
  60. 0 13
      app/src/main/java/com/ch/jedge/jbot2/llm/world/knl/task/JedgeContentCutter.java
  61. 1 1
      app/src/main/java/com/ch/jedge/jbot2/llm/world/model/JedgeMdDomain.java
  62. 7 16
      app/src/main/java/com/ch/jedge/jbot2/llm/world/system/JedgeLLMSystemTask.java
  63. 30 35
      app/src/main/java/com/ch/jedge/jbot2/llm/world/task/JedgeLLMAgent.java
  64. 7 3
      app/src/main/java/com/ch/jedge/jbot2/llm/world/task/JedgeLLMTaskPool.java
  65. 1 1
      app/src/main/java/com/ch/jedge/llm/filter/glm/MainActivity.java
  66. 3 3
      app/src/main/java/com/ch/jedge/tvmufis/JedgeTvMufisService.java
  67. 7 0
      app/src/main/java/com/ch/jedge/utils/JedgeBotConst.java
  68. 12 3
      app/src/main/java/com/ch/jedge/utils/JedgeLlmUtil.java

+ 0 - 7
app/src/main/assets/cfg/dataset/smarthome/device_types.json

@@ -1,7 +0,0 @@
-[
-  {"key": "球泡灯", "disc": "灯"},
-  {"key": "开关", "disc": ""},
-  {"key": "彩光灯带", "disc": "灯、灯带"},
-  {"key": "窗帘", "disc": ""},
-  {"key": "插座", "disc": ""}
-]

+ 0 - 10
app/src/main/assets/cfg/dataset/smarthome/sh_cmd_list.json

@@ -1,10 +0,0 @@
-[
-  {"key": "turnOn", "disc": "打开或开启一个设备"},
-  {"key": "turnOff", "disc": "关闭设备"},
-  {"key": "setBrightness", "disc": "调整灯光亮度,需要额外参数,参数关键字:set_value,参数值:亮度值整数值,亮度值范围是:0-65535,最低亮度为655,变化幅度为6553"},
-  {"key": "setColorTemperature", "disc": "设备色温调整为冷光或暖光,需要额外参数,参数关键字:set_value,参数值:灯光温度取值整数值,灯光温度值范围是:2700-6500,2700为暖光,6500为冷光,变化幅度为1000"},
-  {"key": "setLighterMode", "disc": "调整灯光模式:日光模式,彩光模式,流光模式,需要额外参数,参数关键字:set_value,参数值:模式取值整数值,模式值取值:流光=9,彩光=8,日光=6"},
-  {"key": "setFlowMode", "disc": "流光模式下、调整流光速度,需要额外参数,参数关键字:flow_speed,参数值:流光速度整数值,流光速度取值为0-100"},
-  {"key": "setColorMode", "disc": "设备颜色调整为红色,橙色,黄色,绿色,青色,蓝色,紫色,需要额外参数,参数关键字:hue,参数值:颜色对应的hue整数值,红色:0,橙色:5439,黄色:10944,绿色:21823,青色:32768,蓝色:43712,紫色:54591"},
-  {"key": "activeScene", "disc": "离开或回家,设备的全开全关,打开或关闭所有灯等操作,跟已命名的场景名称相关的操作"}
-]

+ 0 - 12
app/src/main/assets/cfg/dataset/testgpt/center_topics.json

@@ -1,12 +0,0 @@
-[
-  {"key": "问候语", "disc": "一般聊天的初次问候语、期望得到使用帮助或提示基本的可提问的内容"},
-  {"key": "一般介绍", "disc": "问到 TestGPT 助手介绍的定义,一般特性,询问机器人助手、TestGPT是什么、是谁开发的等机器人助手本身的功能介绍相关内容)"},
-  {"key": "检测中心总体介绍", "disc": "检测中心的一般性简介内容,背景、历史、资质、认证、人员、组织架构等"},
-  {"key": "检测中心联系方式", "disc": "联系方式项,可取的值地址,邮编,电话,传真,联系人,网址,网站,邮箱"},
-  {"key": "检测中心资质", "disc": "如果询问检测中心获得了哪些资质"},
-  {"key": "标准信息查询", "disc": "记住用户的名字,单位,联系方式等相关的内容"},
-  {"key": "记录信息", "disc": "标准规范,电视,冰箱等各类产品的所需要涉及的标准和规范等类型"},
-  {"key": "设备检测范围", "disc": "描述各种设备需要做哪些检测项目、设备类型等的咨询,检测中心业务检测的设备、计量检测设备的范围"},
-  {"key": "业务流程咨询", "disc": "问道要做检测和校准,需要哪些流程,提供哪些资料,得到哪些结果及其载体等,需要哪些具体的操作步骤等"},
-  {"key": "业务状态查询", "disc": "问及已推进项目的进展"}
-]

+ 0 - 10
app/src/main/assets/cfg/dataset/testgpt/tg_cmd_list.json

@@ -1,10 +0,0 @@
-[
-  {"key": "consult", "disc": "用户请求信息咨询"},
-  {"key": "prompt", "disc": "向用户发出功能提示的请求"},
-  {"key": "record", "disc": "用户提到自身的信息"},
-  "//可选择的取值是:人名,单位名称,电话,手机,地址,产品及型号,设备及型号,监测项目,传真,联系人,网址,网站,邮箱",
-  {"key": "business", "disc": "创建,提交,查询测试项目的操作"},
-  "//具体检测项目相关的一些数据,资料,进度和人员等跟检测项目相关的信息"
-]
-
-

+ 0 - 10
app/src/main/assets/cfg/dataset/tvass/media_cmdlist.json

@@ -1,10 +0,0 @@
-[
-  {"key": "miSearch", "disc": "查询媒体影片信息咨询相关功能"},
-  "//,根据用户提供的信息提取关键字,并查找对应的影片信息",
-  {"key": "miPlay", "disc": "用户要求或希望播放媒体,包括在线媒体和电视机本地存储的媒体内容。带有播放模式参数, \"mode\"=播放模式, 播放模式替换为对应的值"},
-  "//根据已经命中的媒体信息,去播放队对应的影片或歌曲,并设置对应的播放参数",
-  {"key": "miSave", "disc": "用户希望记录其的个性化喜好"},
-  "//,根据已经播放的历史或内容,记住用户的一些播放参数",
-  {"key": "miCopy", "disc": "文件拷贝,通常是从U盘到电视,或从电视到U盘拷贝。可选择额外参数是文件名,\"file\"=拷贝文件, 类型为字符串,U盘根目录或电视指定路径下的文件名"},
-  {"key": "miQuitUDrive", "disc": "弹出U盘或USB移动硬盘操作,弹出U盘或插入操作。可选择额外参数是文件名,\"drive\"=弹出对象"}
-]

+ 0 - 7
app/src/main/assets/cfg/dataset/tvass/tv_cmd_list.json

@@ -1,7 +0,0 @@
-[
-  {"key": "setVolume", "disc": "设置音量,需要额外参数, 音量大小, key 为 volume, 整数值, 范围0-100"},
-  {"key": "setDisplay", "disc": "设置显示信息,需要额外参数, 亮度值 : key 为 lightness, 整数值, 范围从0-100"},
-  {"key": "setSound", "disc": "设置声音模式,需要额外参数, 可选值为下列字符串: 标准,剧场,音乐,新闻"},
-  {"key": "setPicture", "disc": "设置图像模式,需要额外参数, 可选值为下列字符串: 标准,柔和,亮丽"},
-  {"key": "switchSource", "disc": "切换源,需要额外参数 源类型:  key 为 channel, 可选值为下列字符串: HDMI1, HDMI2, HDMI3, HDMI4"},
-]

+ 0 - 8
app/src/main/assets/cfg/dataset/tvass/tv_play_mode.json

@@ -1,8 +0,0 @@
-[
-  {"key": "single", "disc": "单播模式,播放完暂停后续播放"},
-  {"key": "ordered", "disc": "顺序播放,顺序模式,顺序播放播放列表中的所有内容后停止播放"},
-  "//,根据用户提供的信息提取关键字,并查找对应的影片信息",
-  {"key": "repeat", "disc": "循环播放,循环模式,持续播放同一个或多个文件的播放列表"},
-  "//根据已经命中的媒体信息,去播放队对应的影片或歌曲,并设置对应的播放参数",
-  {"key": "recommend", "disc": "推荐模式,播放完毕后,自动推荐播放下一步影片"}
-]

+ 1 - 1
app/src/main/assets/cfg/domains/system/domain.json

@@ -1,4 +1,4 @@
 {
   "key": "JedgeTaskSystem",
-  "disc": "对当前正在执行的任务相关的状态执行,控制,目标修正和结果评价等.也包括用户的一些无目标咨询,一般问候或询问系统能力等范畴"
+  "disc": ""
 }

+ 8 - 0
app/src/main/assets/cfg/jedge.json

@@ -0,0 +1,8 @@
+{
+  "host": "127.0.0.1",
+  "host1": "10.168.1.102",
+  "port": 8877,
+  "debugMode": true,
+  "noCommand": false,
+  "noCmdExec": false
+}

+ 0 - 44
app/src/main/assets/cfg/picker/jsh/addDevice.json

@@ -1,44 +0,0 @@
-{
-  "title":"添加设备",
-  "cmd":"从给定数据中提取添加设备的房间,分组等信息",
-  "fmt":"{\"device_location\":房间,\"device_type\":设备类型,\"device_group\":设备功能分组}",
-  "prefix":"房间是当前系统中已存在的房间,分组是系统中已经预设的设备分组",
-  "targets":"房间,设备功能分组",
-  "dataset": [
-    {
-      "name":"房间",
-      "key":"device_location",
-      "disc":"设备可以编入的房间",
-      "values": {
-        "主卧": "主人的房间,卧室",
-        "客厅": "客厅",
-        "餐厅": "餐厅",
-        "老人房": "老人的房间,卧室",
-        "儿童房": "儿童的房间,卧室"
-      }
-    },{
-      "name":"设备功能分组",
-      "key":"device_group",
-      "disc":"房间中预先设置的设备功能编组",
-      "values": {
-        "大灯": "主要照明编组",
-        "夜灯": "夜间起居时的弱光小灯",
-        "小灯": "辅助照明灯光",
-        "氛围灯": "氛围照明灯光,一版是灯带,墙壁射灯等",
-        "功能灯": "阅读、看电视、看书、休闲时的区位灯"
-      }
-      },{
-        "name":"设备类型",
-        "key":"device_type",
-        "disc":"设备的类型",
-        "values": {
-          "球泡灯": "球泡灯",
-          "开关": "",
-          "彩光灯带": "灯、灯带",
-          "窗帘": "",
-          "插座": ""
-        }
-      }
-  ]
-}
-

+ 0 - 30
app/src/main/assets/cfg/picker/jsh/command.json

@@ -1,30 +0,0 @@
-{
-	"key":"command",
-	"title":"直接指令的多动作提取",
-	"role":"语义分析专家",
-	"cmd":"准确区分用户的意图,一个动作意图只生成一条数据,多个动作意图尽量拆分为多条结构数据。",
-	"fmt":"[{\"command\":动作名称}]",
-	"prefix":"动作是指用户给出准确行动意图时的行为。",
-	"targets":"动作类型",
-	"datasets": [
-		{
-			"name":"动作类型",
-			"key":"command",
-			"disc":"用户意图给出的指令或动作意图",
-			"values": {
-				"turnOn": "打开或开启设备",
-				"turnOff": "关闭或停止设备",
-				"setColorMode": "设置灯光的颜色,红橙黄绿青蓝紫色",
-				"setColorTemperature": "设置灯光色温,冷光或暖光,也可以是白光或黄光",
-				"setBrightness": "设置灯亮度",
-				"setLighterMode": "设置灯光模式:日光,流光,彩光",
-				"setFlowMode": "设置流光速度",
-				"addDevice": "添加设备",
-				"removeDevice": "删除设备",
-				"groupDevice": "设备分组",
-				"ungroupDevice": "接触设备分组",
-				"others": "与上述命令无法匹配的命令"
-			}
-		}
-	]
-}

+ 58 - 0
app/src/main/assets/cfg/picker/jsh/command.tpl

@@ -0,0 +1,58 @@
+取值依据:{
+     	"turnOn": "打开或开启设备",
+     	"turnOff": "关闭或停止设备",
+     	"setColorMode": "设置灯光的颜色,红(hue:0),橙(hue:5439),黄(hue:10944),绿(hue:21823),青(hue:32768),蓝(hue:43712),紫色(hue:54591)",
+     	"setColorTemperature": "设置灯光色温,冷光或白光(set_value:6500),暖光或黄光(set_value:2700)",
+     	"setBrightness": "设置灯亮度,最小(set_value:655),最大(set_value:65535)",
+     	"setLighterMode": "设置灯光模式:日光模式(set_value:6),流光模式(set_value:8),彩光模式(set_value:9)",
+     	"setFlowMode": "设置流光速度",
+     	"addDevice": "添加设备",
+     	"removeDevice": "删除设备",
+     	"groupDevice": "设备分组",
+     	"ungroupDevice": "解除设备分组",
+     	"devHelp": "涉及设备操控的帮助信息",
+     	"others": "与上述命令无法匹配的动作意图"
+ }
+
+我将给出一系列定义:
+* 操作意图:阐释了对应用户输入可供执行的操作选项;
+** 取值依据:阐释了对各可执行操作的定义;
+*** 额外参数的处理:默认情况下,额外参数的key名为'value';当取值依据中,定义了额外参数的key名时,优先使用定义的key名。
+* 用户输入:用户原始输入信息。
+* 意图短语:最小的,包含且仅包含一个意图,包括其动作和参数的短句;
+
+请根据以上定义,按照如下的思维链执行任务:
+步骤1:提取用户输入原文
+步骤2:将用户输入原文转化为一系列意图短语
+步骤3:针对意图短语,分别选择操作意图中匹配的取值
+步骤4:将生产的一系列取值,按照指定格式输出
+
+从用户输入内容中抽取分用户的意图,按先后顺序对动作意图和参数进行分析,匹配对应的动作取值,并提取对应参数
+请从"turnOn,turnOff,setColorMode,setColorTemperature,setBrightness,setLighterMode,setFlowMode,addDevice,removeDevice,groupDevice,ungroupDevice,devHelp,others"中区分用户动作意图,
+动作意图取值只在上述取值依据中提取,如果不能识别的动作意图,或者参数存在,但与动作意图不能严格对应时,不要输出动作意图,
+没有匹配参数时,param设置为空,
+输出格式如下所示,应将全部取值封装为一个list对象:
+[{"command":具体的动作意图取值, "param":{"参数key":"参数value",...}]
+
+以下是一些示例:
+输入:'''打开大灯'''
+输出:[{"command":"turnOn"}]
+输入:'''关闭客厅灯'''
+输出:[{"command":"turnOff"}]
+输入:'''灯带设置为紫色'''
+输出:[{"command":"setColorMode", "param":{"hue":54591,"lightness":65535}]
+输入:'''灯带设置为流光模式'''
+输出:[{"command":"setLighterMode", "param":{"set_value":6}}]
+输入:'''打开灯带,并设置为暖光'''
+输出:[{"command":"turnOn"},{"command":"setColorTemperature", "param":{"set_value":2700}}]
+输入:'''打开灯带,并设置为暖光,亮度最大'''
+输出:[{"command":"turnOn"},{"command":"setColorTemperature", "param":{"set_value":2700}},{"command":"setBrightness", "param":{"set_value":65536}}]
+输入:'''灯带设成彩光模式,颜色为紫色,亮度最低'''
+输出:[{"command":"setLighterMode", "param":{"set_value":8}},{"command":"setColorMode", "param":{"hue":54591,"lightness":65535}},{"command":"setBrightness", "param":{"set_value":"655"}}]
+输入:'''筒射灯调成白光,最亮'''
+输出:[{"command":"setColorTemperature", "param":{"set_value":6500}},{"command":"setBrightness", "param":{"set_value":65536}}]
+
+请严格遵循示例的逻辑与输出格式,执行以下任务:
+用户输入: {query},
+你的输出
+

+ 0 - 7
app/src/main/assets/cfg/picker/jsh/setBrightness.json

@@ -1,7 +0,0 @@
-{
-  "title":"设置亮度",
-  "cmd":"从给定数据中提取亮度参数",
-  "fmt":"{\"set_value\":亮度值}",
-  "prefix":"亮度是调整灯光亮度的参数",
-  "targets":"亮度是从0-65535,0表示关闭,655是最小值,变化增减量为6553"
-}

+ 0 - 25
app/src/main/assets/cfg/picker/jsh/setColorMode.json

@@ -1,25 +0,0 @@
-{
-  "key":"setColorMode",
-  "title":"设置颜色",
-  "cmd":"从给定数据中提取恰当的参数",
-  "fmt":"{\"lightness\":65535,\"hue\":颜色值}",
-  "prefix":"用户可以选择的颜色有红,橙,黄,绿,青,蓝,紫",
-  "targets":"颜色参数",
-  "datasets": [
-    {
-      "name":"颜色参数",
-      "key":"hue",
-      "disc":"用户可以选择的颜色参数",
-      "//": "颜色对应的hue整数值,红色:0,橙色:5439,黄色:10944,绿色:21823,青色:32768,蓝色:43712,紫色:54591",
-      "values": {
-        "0": "红,红色或红光",
-        "5439": "橙,橙色或橙光",
-        "10944": "黄,黄色或黄光",
-        "21823": "绿,绿色或绿光",
-        "32768": "青,青色或青光",
-        "43712": "蓝,蓝色或蓝光",
-        "54591": "紫,紫色或紫光"
-      }
-    }
-  ]
-}

+ 0 - 7
app/src/main/assets/cfg/picker/jsh/setColorTemperature.json

@@ -1,7 +0,0 @@
-{
-  "title":"设置色温",
-  "cmd":"从给定数据中提取色温参数",
-  "fmt":"{\"set_value\":色温值}",
-  "prefix":"色温用于设置双色灯的色温参数,包括冷暖色,或者说黄色,白色",
-  "targets":"色温从2700-6500,2700表示暖光,偏黄色,6500冷光,偏白色"
-}

+ 0 - 7
app/src/main/assets/cfg/picker/jsh/setFlowMode.json

@@ -1,7 +0,0 @@
-{
-  "title":"设置流光速度",
-  "cmd":"从给定数据中提取流光速度",
-  "fmt":"{\"set_value\":流光速度}",
-  "prefix":"流光速度即灯光变化速度的快慢",
-  "targets":"流光速度从0-100,0最慢,100最快,变化值为10"
-}

+ 0 - 7
app/src/main/assets/cfg/picker/jsh/setLighterMode.json

@@ -1,7 +0,0 @@
-{
-  "title":"设置灯光模式",
-  "cmd":"从给定数据中灯光模式参数",
-  "fmt":"{\"set_value\":亮度值}",
-  "prefix":"灯光模式分为流光模式,彩光模式和日光模式,彩光可以调颜色,日光模式可以调色温,流光模式可设置流光速度",
-  "targets":"日光模式:set_value=6,彩光模式:set_value=8,流光模式:set_value=9"
-}

+ 0 - 23
app/src/main/assets/cfg/picker/mediaAcc/command.json

@@ -1,23 +0,0 @@
-{
-	"key":"command",
-	"title":"直接指令的多动作提取",
-	"cmd":"准确区分用户的意图,一个动作意图只生成一条数据,多个动作意图尽量拆分为多条结构数据。",
-	"fmt":"[{\"command\":动作名称}]",
-	"prefix":"动作是指用户给出准确行动意图时的行为。",
-	"targets":"动作类型",
-	"datasets": [
-		{
-			"name":"动作类型",
-			"key":"command",
-			"disc":"用户意图给出的指令或动作意图",
-			"values": {
-				"queryMovie": "咨询电影相关信息",
-				"queryMovieUSB": "咨询U盘中的内容",
-				"playMovie": "播放电影",
-				"playUSB": "播放U盘里面的内容",
-				"copyUSB": "拷贝U盘内容到电视",
-				"tvHelp"	: "一般性介绍电视的主要功能,询问电视有哪些功能,电视助手能做些什么,咨询电视设备控制功能,主要涉及跟电视的声音,显示参数,显示和音量控制,输入输出设置,网络配置等相关的功能询问"
-			}
-		}
-	]
-}

+ 49 - 0
app/src/main/assets/cfg/picker/mediaAcc/command.tpl

@@ -0,0 +1,49 @@
+取值依据:{
+        "queryMovie": "咨询电影相关信息",
+        "queryMovieUSB": "咨询U盘中的内容",
+        "playMovie": "播放电影",
+        "playUSB": "播放U盘里面的内容",
+        "copyUSB": "拷贝U盘内容到电视",
+        "quitUSB": "退出USB设备",
+        "mdHelp": "介绍U盘或USB移动硬盘播放帮助,媒体咨询范围帮助等信息"
+        "others": "与上述命令无法匹配的动作意图"
+}
+
+我将给出一系列定义:
+* 操作意图:阐释了对应用户输入可供执行的操作选项;
+** 取值依据:阐释了对各可执行操作的定义;
+*** 额外参数的处理:默认情况下,额外参数的key名为'value';当取值依据中,定义了额外参数的key名时,优先使用定义的key名。
+* 用户输入:用户原始输入信息。
+* 意图短语:最小的,包含且仅包含一个意图,包括其动作和参数的短句;
+
+请根据以上定义,按照如下的思维链执行任务:
+步骤1:提取用户输入原文
+步骤2:将用户输入原文转化为一系列意图短语
+步骤3:针对意图短语,分别选择操作意图中匹配的取值
+步骤4:将生产的一系列取值,按照指定格式输出
+
+从用户输入内容中抽取分用户的意图,按先后顺序对动作意图和参数进行分析,匹配对应的动作取值,并提取对应参数
+请从"queryMovie,queryMovieUSB,playMovie,playUSB,copyUSB,quitUSB,mdHelp,others"中区分用户动作意图,
+动作意图取值只在上述取值依据中提取,如果不能识别的动作意图,或者动作意图与参数不能严格对应时,不要输出,
+没有匹配参数时,param设置为空,
+输出格式如下所示,应将全部取值封装为一个list对象:
+[{"command":具体的动作意图取值, "param":{"参数key":"参数value",...}]
+
+以下是一些示例:
+输入:'''星球大战拍了多少集? 导演是谁?'''
+输出:[{"command":"queryMovie", "param":{"item":["多少集","导演"]}}]
+输入:'''U盘中有哪些电影?播放这些电影'''
+输出:[{"command":"queryMovieUSB"},{"command":"playUSB"}]
+输入:'''星球大战'''
+输出:[{"command":"playMovie", "param":{"name":"星球大战"}]
+输入:'''播放纪录片宇宙'''
+输出:[{"command":"playMovie", "param":{"name":"纪录片宇宙"}]
+输入:'''退出USB硬盘'''
+输出:[{"command":"quitUSB"]
+输入:'''怎么找片子?'''
+输出:[{"command":"mdHelp"]
+
+请严格遵循示例的逻辑与输出格式,执行以下任务:
+用户输入: {query},
+你的输出
+

+ 0 - 6
app/src/main/assets/cfg/picker/mediaAcc/queryMovie.json

@@ -1,6 +0,0 @@
-{
-  "title":"咨询电影相关信息",
-  "cmd":"从给定数据中提取咨询电影相关内容的参数",
-  "fmt":"{\"param\":咨询参数}",
-  "targets":"参数项可包括片名,导演,制片公司"
-}

+ 0 - 6
app/src/main/assets/cfg/picker/mediaAcc/queryMovieUSB.json

@@ -1,6 +0,0 @@
-{
-  "title":"咨询电影相关信息",
-  "cmd":"用户输入中提取要咨询媒体信息的参数",
-  "fmt":"{\"param\":咨询参数}",
-  "targets":"参数项可包括片名,导演,制片公司"
-}

+ 0 - 18
app/src/main/assets/cfg/picker/system/cutter.json

@@ -1,18 +0,0 @@
-{
-  "title":"主题相关内容提取",
-  "role":"关联内容提取器",
-  "cmd":"分析用户输入,分割提取与用户提供的参数密切相关内容",
-  "fmt":"{\"query\":相关内容}",
-  "prefix":"",
-  "targets":"相关内容",
-  "datasets": [
-    {
-      "name":"领域分类",
-      "key":"domain",
-      "disc":"用户输入内容所属知识领域范畴",
-      "values":{
-        "other": "与其它领域均不相关"
-      }
-    }
-  ]
-}

+ 61 - 0
app/src/main/assets/cfg/picker/system/domain.rel.tpl

@@ -0,0 +1,61 @@
+取值依据: {
+	"other": "与上述领域领域均不相关",
+	"SmartTaskTester": "可选实体列表如下,
+		实体对象:测试控制器,实体类型:测试控制器类型, 动实体作:执行测试(带用中英文例名),执行(带用中英文例名),启动用例(带用中英文例名),列举用例,停止测试等动作",
+	"TVControl": "可选实体列表如下,
+		实体对象:电视,实体类型:电视控制器, 动实体作:电视控制(打开或关闭电视),
+		实体对象:声音,实体类型:声音控制器, 动实体作:电视音量设置(大小或具体数字),
+		实体对象:屏幕,实体类型:屏幕控制器, 动实体作:电视亮度设置(大小或具体数字),屏幕色彩(亮丽,普通,柔和模式设置),
+		实体对象:源,实体类型源控制器, 动实体作:执行切换源(可以切换到:ATV,HDMI)等动作",
+	"JedgeSmartHome": "可选实体列表如下,
+		实体对象:线控灯一,实体类型:线控灯, 动实体作:可执行开关动作,
+        实体对象:过道灯,实体类型:筒射灯, 动实体作:可执行开关,亮度设置,色温设置(设置为冷光,暖光,也可以说白光或黄光),
+        实体对象:客厅灯,实体类型:球泡灯, 动实体作:可执行开关,亮度设置,色温设置(设置为冷光,暖光,也可以说白光或黄光),
+        实体对象:大灯,实体类型:球泡灯, 动实体作:可执行开关,亮度设置,色温设置(设置为冷光,暖光,也可以说白光或黄光),
+        实体对象:小灯,实体类型:球泡灯, 动实体作:可执行开关,亮度设置,色温设置(设置为冷光,暖光,也可以说白光或黄光),
+		实体对象:灯带,实体类型:灯带, 动实体作:可执行开关,亮度设置,色温设置(设置为冷光,暖光,也可以说白光或黄光),颜色设置(红,橙,黄,绿,青,蓝,紫等颜色的设置)",
+	"MediaInfo": "可选实体列表如下,
+		实体对象:媒体咨询,实体类型:电影搜索器, 动实体作:可执行电影信息检索(电影,电视,音乐,纪录片,动画片,包括片名,出品制作方,导演,主要演员,片子简介,剧情简介等信息), 播放电影,播放列表动作,
+		实体对象:USB控制器,实体类型:USB控制器, 动实体作:对U盘,移动硬盘等对象,执行媒体查找,USB播放(到电视,到硬盘), USB设备弹出(U盘或移动硬盘)"
+}
+
+取值依据: {
+	"TVControl":"可选实体列表如下n实体对象:电视,实体类型:电视控制器, 动实体作:电视控制(打开或关闭电视),n实体对象:音量,实体类型:音量控制器, 动实体作:电视音量设置(大小或具体数字),n实体对象:屏幕,实体类型:屏幕控制器, 动实体作:电视亮度设置(大小或具体数字),屏幕色彩(亮丽,普通,柔和模式设置),n实体对象:源,实体类型:源控制器, 动实体作:执行切换源(可以切换到:ATV,HDMI)等动作,n",
+	"MediaInfo":"可选实体列表如下n实体对象:媒体控制,实体类型:媒体控制器, 动实体作:可执行电影信息检索(电影,电视,音乐,纪录片,动画片,包括片名,出品制作方,导演,主要演员,片子简介,剧情简介等信息), 播放电影,播放列表动作,n实体对象:USB 控制对象,实体类型:USB 控制器, 动实体作:对U盘,移动硬盘等对象,执行媒体查找,USB播放(到电视,到硬盘), USB设备弹出(U盘或移动硬盘),n",
+	"others":"与上述领域领域均不相关"
+}
+
+我将给出一系列定义:
+* 领域分类:阐释了对应用户输入可供分类的领域选项;
+** 取值依据:阐释了对各可领域选项的定义;
+* 用户输入:用户原始输入信息。
+* 实体动作短语:包含且仅包含一个实体对象和动作参数的短语;
+
+请根据以上定义,按照如下的思维链执行任务:
+步骤1:提取用户输入原文
+步骤2:将用户输入原文转化为一系列实体动作短语
+步骤3:针对实体,分别选择领域分类中的试图对象中进行匹配和取值
+步骤4:将生产的一系列取值及其对应的实体短语,按照指定格式输出
+从用户输入内容中抽取实体及动作和参数,按先后顺序对可分类操作的对象和功能领域进行领域分类及实体内容转化,每个短语都包含对应的实体,动作和完整参数,
+请从 "other,SmartTaskTester,TVControl,JedgeSmartHome,MediaInfo"中区分用户功能领域,
+实体对象只在上述取值依据中提取,如果不能识别的实体对象,或者实体对象与输入描述的动实体作不能严格对应时,不要输出,
+输出格式如下所示,应将全部取值封装为一个list对象:
+[{"domain":领域分类取值, "query": 分割后的实体短语, "object":实体名称}]
+
+以下是一些示例:
+输入:'''打开电视,音量调到30,播放U盘的内容,电视亮度调到最高'''
+输出:[{"domain":"TVControl","query":"打开电视","object":"电视"},{"domain":"TVControl","query":"音量调到 30,","object":"声音"},{"domain":"TVControl","query":"播放 U 盘的内容,","object":"USB控制器"},{"domain":"TVControl","query":"电视亮度调到最高,","object":"屏幕"}]
+输入:'''打开空调,过道灯亮度设置为最大,调成黄光'''
+输出:[{"domain":"JedgeSmartHome","query":"打开空调","object":"空调"},{"domain":"JedgeSmartHome","query":"过道灯亮度设置为最大","object":"过道灯"},{"domain":"JedgeSmartHome","query":"调成黄光","object":"过道灯"}]
+输入:'''打开大灯,灯带和电视'''
+输出:[{"domain":"JedgeSmartHome","query":"打开大灯","object":"大灯"},{"domain":"JedgeSmartHome","query":"打开灯带","object":"灯带"},{"domain":"TVControl","query":"打开电视","object":"电视"}]
+输入:'''开灯带,调成青色,电视音量调到50,再把灯带调成暖光,最低亮度'''
+输出:[{"domain":"JedgeSmartHome","query":"开灯带,调成青色","object":"灯带"},{"domain":"TVControl","query":"电视音量调到 50","object":"声音"},{"domain":"JedgeSmartHome","query":"再把灯带调成暖光,最低亮度","object":"灯带"}]
+输入:'''执行err'''
+输出:[{"domain":"SmartTaskTester","query":"执行err","object":"测试控制器"}]
+输入:'''打开灯带,绵阳有哪些体育赛事?'''
+输出:[{"domain":"SmartTaskTester","query":"打开灯带","object":"灯带"},{"domain":"other","query":"绵阳有哪些体育赛事?", "object":null}]
+
+请严格遵循示例的逻辑与输出格式,执行以下任务:
+用户输入: {query},
+你的输出

+ 43 - 0
app/src/main/assets/cfg/picker/system/domain.tpl

@@ -0,0 +1,43 @@
+取值依据: {data}
+
+我将给出一系列定义:
+* 领域分类:阐释了对应用户输入可供分类的领域选项;
+** 取值依据:阐释了对各可领域选项的定义;
+* 用户输入:用户原始输入信息。
+* 实体动作短语:包含且仅包含一个实体对象和动作参数的短语;
+
+请根据以上定义,按照如下的思维链执行任务:
+步骤1:提取用户输入原文
+步骤2:将用户输入原文转化为一系列实体动作短语
+步骤3:针对实体,分别选择领域分类中的试图对象中进行匹配和取值
+步骤4:将生产的一系列取值及其对应的实体短语,按照指定格式输出
+从用户输入内容中抽取实体及动作和参数,按先后顺序对可分类操作的对象和功能领域进行领域分类及实体内容转化,每个短语都包含对应的实体,动作和完整参数,
+请从 "{data_keys}" 中区分用户功能领域,
+实体对象只在上述取值依据中提取,如果不能识别的实体对象,或者实体对象与输入描述的动实体作不能严格对应时,不要输出,
+输出格式如下所示,应将全部取值封装为一个list对象:
+[{"domain":领域分类取值, "query": 分割后的实体短语, "object":实体名称}]
+
+以下是一些示例:
+输入:'''关闭客厅灯打开灯带'''
+输出:[{"domain":"JedgeSmartHome","query":"关闭客厅灯","object":"客厅灯"},{"domain":"JedgeSmartHome","query":"打开灯带","object":"灯带"}]
+输入:'''打开电视音量调到30播放U盘的内容电视亮度调到最高'''
+输出:[{"domain":"TVControl","query":"打开电视","object":"电视"},{"domain":"TVControl","query":"音量调到 30,","object":"声音"},{"domain":"TVControl","query":"播放 U 盘的内容,","object":"USB控制器"},{"domain":"TVControl","query":"电视亮度调到最高,","object":"屏幕"}]
+输入:'''打开空调过道灯亮度设置为最大调成黄光'''
+输出:[{"domain":"JedgeSmartHome","query":"打开空调","object":"空调"},{"domain":"JedgeSmartHome","query":"过道灯亮度设置为最大","object":"过道灯"},{"domain":"JedgeSmartHome","query":"调成黄光","object":"过道灯"}]
+输入:'''打开大灯灯带和电视'''
+输出:[{"domain":"JedgeSmartHome","query":"打开大灯","object":"大灯"},{"domain":"JedgeSmartHome","query":"打开灯带","object":"灯带"},{"domain":"TVControl","query":"打开电视","object":"电视"}]
+输入:'''开灯带调成青色电视音量调到50再把灯带调成暖光最低亮度'''
+输出:[{"domain":"JedgeSmartHome","query":"开灯带,调成青色","object":"灯带"},{"domain":"TVControl","query":"电视音量调到 50","object":"声音"},{"domain":"JedgeSmartHome","query":"再把灯带调成暖光,最低亮度","object":"灯带"}]
+输入:'''执行err'''
+输出:[{"domain":"SmartTaskTester","query":"执行err","object":"测试控制器"}]
+输入:'''打开灯带绵阳有哪些体育赛事?'''
+输出:[{"domain":"JedgeSmartHome","query":"打开灯带","object":"灯带"},{"domain":"other","query":"绵阳有哪些体育赛事?", "object":null}]
+输入:'''柔和模式'''
+输出:[{"domain":"TVControl","query":"柔和模式","object":"屏幕"}]
+输入:'''打开电视并播放U盘'''
+输出:[{"domain":"TVControl","query":"打开电视","object":"电视"},{"domain":"MediaInfo","query":"播放U盘","object":"USB控制器"}]
+{example}
+
+请严格遵循示例的逻辑与输出格式,执行以下任务:
+用户输入: {query},
+你的输出

+ 1 - 1
app/src/main/assets/cfg/picker/system/task.json

@@ -13,7 +13,7 @@
 			"values":{
 				"direcInst":"描述动作或指令,以及其相关的约束条件,时间点或时间延迟,地点,及其它参数和目标等",
 				"addKnowledge":"包含对事件的完整陈述,陈述一条实事,增加系统的知识和状态的参数",
-				"queryStatus":"询问,请求,咨询,任务或设备的状态,参数,属性等,希望了解系统的状态,,目标或任务的做法,指令的提法,信息的咨询等帮助信息",
+				"queryHelp":"询问,请求,咨询,任务或设备的状态,参数,属性等,希望了解系统的状态,,目标或任务的做法,指令的提法,信息的咨询等帮助信息",
 				"other":"其它与上述不相关内容"
 			}
 		}

+ 37 - 0
app/src/main/assets/cfg/picker/system/taskMake.tpl

@@ -0,0 +1,37 @@
+你将会接收到一份类json格式的信息,它由以下部分组成:
+* 领域分类:阐释了对应用户输入可供分类的领域选项;
+** 取值依据:阐释了对各可领域选项的定义;
+* 用户输入:用户原始输入信息。
+
+我将给出一系列定义:
+* 实体短语:包含且仅包含一个实体对象(如冰箱、空调等)的短语;
+
+请根据以上定义,按照如下的思维链执行任务:
+步骤1:提取用户输入原文
+步骤2:将用户输入原文转化为一系列实体短语
+步骤3:针对实体,分别选择领域分类中匹配的取值
+步骤4:将生产的一系列取值及其对应的实体短语,按照指定格式输出
+
+输出格式如下所示,应将全部取值封装为一个list对象:
+[{"domain":... /*具体的领域分类取值*/,"query":... /*对应的实体短语*/}]
+
+以下是一些示例:
+输入:'''
+{领域分类取值依据:{"other":"与其它领域均不相关","JedgeSmartHome":"智慧家居设备操作,包括灯,锁,窗帘,插座,开关,空调设备的一次或多次的操作。但不包含电视的控制操作。","TVControl":"电视机的控制和设置等功能,包括音量设置,屏幕设置,电视屏幕的色彩模式设置,频道选择,信号源控制等相关的指令,但是不要包括家居控制或媒体影片等信息。","MediaInfo":"电影,电视,音乐,纪录片,动画片等各类影视剧的媒体信息查询,播放,包括片名,出品制作方,导演,主要演员,片子简介,剧情简介,U盘控制相关操作。"},用户输入:家里有点热,电视屏幕有点暗}
+'''
+输出:[{"domain": "JedgeSmartHome", "query": "家里有点热"},{"domain": "TVControl", "query": "电视屏幕有点暗"}]
+
+输入:'''
+{领域分类取值依据:{"other":"与其它领域均不相关","JedgeSmartHome":"智慧家居设备操作,包括灯,锁,窗帘,插座,开关,空调设备的一次或多次的操作。但不包含电视的控制操作。","TVControl":"电视机的控制和设置等功能,包括音量设置,屏幕设置,电视屏幕的色彩模式设置,频道选择,信号源控制等相关的指令,但是不要包括家居控制或媒体影片等信息。","MediaInfo":"电影,电视,音乐,纪录片,动画片等各类影视剧的媒体信息查询,播放,包括片名,出品制作方,导演,主要演员,片子简介,剧情简介,U盘控制相关操作。"},用户输入:开灯带,调成青色,电视音量调到50,再把灯带调成暖光,最低亮度}
+'''
+输出:[{"domain": "JedgeSmartHome", "query": "开灯带,调成青色"},{"domain": "TVControl", "query": "电视音量调到50"},{"domain": "JedgeSmartHome", "query": "再把灯带调成暖光,最低亮度"}]
+
+输入:'''
+{领域分类取值依据:{"other":"与其它领域均不相关","JedgeSmartHome":"智慧家居设备操作,包括灯,锁,窗帘,插座,开关,空调设备的一次或多次的操作。但不包含电视的控制操作。","TVControl":"电视机的控制和设置等功能,包括音量设置,屏幕设置,电视屏幕的色彩模式设置,频道选择,信号源控制等相关的指令,但是不要包括家居控制或媒体影片等信息。","MediaInfo":"电影,电视,音乐,纪录片,动画片等各类影视剧的媒体信息查询,播放,包括片名,出品制作方,导演,主要演员,片子简介,剧情简介,U盘控制相关操作。"},用户输入:开冰箱,调到五十度,再调到负五十度,我觉得有点无聊}
+'''
+输出:[{"domain": "JedgeSmartHome", "query": "开冰箱,调到五十度,再调到负五十度"},{"domain": "other", "query": "我觉得有点无聊"}]
+
+请严格遵循示例的逻辑与输出格式,执行以下任务:
+输入:
+```{{query}}```
+输出:

+ 0 - 26
app/src/main/assets/cfg/picker/tvctrl/command.json

@@ -1,26 +0,0 @@
-{
-	"key":"command",
-	"role":"语义分析专家",
-	"title":"直接指令的多动作提取",
-	"cmd":"准确区分用户对电视的操作意图列表",
-	"fmt":"[{\"command\":操作意图}]",
-	"prefix":"操作意图是指用户给出准确行动意图时的行为。",
-	"targets":"操作意图",
-	"datasets": [
-		{
-			"name":"操作意图",
-			"key":"command",
-			"disc":"用户意图给出的指令或动作意图",
-			"values": {
-				"turnOn": "打开电视",
-				"turnOff": "关闭电视",
-				"switchChannel": "切换频道, 需要额外参数,频道编号,  key 为 channel, 整数值, 0-999",
-				"setVolume": "设置音量,需要额外参数, 音量大小, key 为 volume, 整数值, 范围0-100",
-				"setDisplay": "设置显示信息,包括亮度,颜色模式",
-				"switchSource": "切换源,需要额外参数 源类型:  key 为 channel, 可选值为下列字符串: HDMI1, HDMI2, HDMI3",
-				"tvStatus"	: "查看电视当前的状态:频道设置,色彩模式设置,音量设置,分辨率设置,输入源设置,账号等信息",
-				"tvHelp"	: "一般性介绍电视的主要功能,询问电视有哪些功能,电视助手能做些什么,咨询电视设备控制功能,主要涉及跟电视的声音,显示参数,显示和音量控制,输入输出设置,网络配置等相关的功能询问"
-			}
-		}
-	]
-}

+ 52 - 0
app/src/main/assets/cfg/picker/tvctrl/command.tpl

@@ -0,0 +1,52 @@
+取值依据:{
+        "turnOn": "打开电视",
+        "turnOff": "关闭电视",
+        "switchChannel": "切换频道",
+        "setVolume": "设置音量,需要额外参数, 音量大小",
+        "setDisplay": "设置显示信息,包括亮度, 颜色模式",
+        "setSoundMode": "设置声音模式",
+        "switchSource": "切换源,需要额外参数",
+        "tvStatus"	: "查看电视当前的状态:音量大小,屏幕亮度,频道设置,色彩模式设置,音量设置,分辨率设置,输入源设置,账号等信息",
+        "tvHelp"	: "一般性介绍电视的主要功能,询问电视有哪些功能,电视助手能做些什么,咨询电视设备控制功能,主要涉及跟电视的声音,显示参数,显示和音量控制,输入输出设置,网络配置等相关的功能询问",
+        "others": "与上述命令无法匹配的动作意图"
+}
+
+我将给出一系列定义:
+* 操作意图:阐释了对应用户输入可供执行的操作选项;
+** 取值依据:阐释了对各可执行操作的定义;
+*** 额外参数的处理:默认情况下,额外参数的key名为'value';当取值依据中,定义了额外参数的key名时,优先使用定义的key名。
+* 用户输入:用户原始输入信息。
+* 意图短语:最小的,包含且仅包含一个意图,包括其动作和参数的短句;
+
+请根据以上定义,按照如下的思维链执行任务:
+步骤1:提取用户输入原文
+步骤2:将用户输入原文转化为一系列意图短语
+步骤3:针对意图短语,分别选择操作意图中匹配的取值
+步骤4:将生产的一系列取值,按照指定格式输出
+
+从用户输入内容中抽取分用户的意图,按先后顺序对动作意图和参数进行分析,匹配对应的动作取值,
+请从"turnOn,turnOff,switchChannel,setVolume,setDisplay,setSoundMode,switchSource,tvStatus,tvHelp,others"中区分用户动作意图,
+动作意图取值只在上述取值依据中提取,如果不能识别的动作意图,或者动作意图与参数不能严格对应时,不要输出,
+输出格式如下所示,应将全部取值封装为一个list对象:
+[{"command":具体的动作意图取值}]
+
+以下是一些示例:
+输入:'''切换到hdmi1'''
+输出:[{"command":"switchSource"}]
+输入:'''关闭电视'''
+输出:[{"command":"turnOff"}]
+输入:'''切换到55频道'''
+输出:[{"command":"switchChannel",, "param":{"set_value":55}}]
+输入:'''音量8,亮度100,柔和模式'''
+输出:[{"command":"setVolume", "param":{"volume":8}},{"command":"setDisplay", "param":{"lightness":100}},{"command":"setDisplay", "param":{"mode":"柔和"}}]
+输入:'''设为音乐模式'''
+输出:[{"command":"setSoundMode", "param":{"mode":"音乐"}}]
+输入:'''怎么设置颜色模式?'''
+输出:[{"command":"tvHelp", "param":{"item":"怎么设置颜色模式"}}}]
+输入:'''当的音量时多少?亮度呢?什么显示模式?'''
+输出:[{"command":"tvStatus", "param":{"item":"volume"}},{"command":"tvHelp", "param":{"item":"lightness"},{"command":"tvHelp", "param":{"item":"mode"}}]
+
+请严格遵循示例的逻辑与输出格式,执行以下任务:
+用户输入: {query},
+你的输出
+

+ 0 - 7
app/src/main/assets/cfg/picker/tvctrl/setDisplay.json

@@ -1,7 +0,0 @@
-{
-  "title":"电视屏幕设置",
-  "cmd":"从给定数据中提取屏幕设置的参数,包括设置项和具体设置参数",
-  "fmt":"{\"item\":设置项,\"param\":设置值}",
-  "prefix":"屏幕的设置项包括亮度和色彩模式",
-  "targets":"设置项包括:亮度和色彩模式。亮度设置值从0到100,表示从最暗到最亮。色彩模式,包括亮丽,标准,柔和。"
-}

+ 0 - 7
app/src/main/assets/cfg/picker/tvctrl/setVolume.json

@@ -1,7 +0,0 @@
-{
-  "title":"设置音量",
-  "cmd":"从给定数据中提取音量的值",
-  "fmt":"{\"volume\":音量值}",
-  "prefix":"音量是指电视的音量大小",
-  "targets":"音量是从0-100,0表示静音,1是最小音量,变化增减量为10"
-}

+ 0 - 7
app/src/main/assets/cfg/picker/tvctrl/switchChannel.json

@@ -1,7 +0,0 @@
-{
-  "title":"设置电视频道",
-  "cmd":"从给定数据中提取频道值",
-  "fmt":"{\"channel\":频道值}",
-  "prefix":"频道即电视闭路的信号来源",
-  "targets":"整数值, 0-999, 加减时,每次增加或减少数字1"
-}

+ 0 - 7
app/src/main/assets/cfg/picker/tvctrl/switchSource.json

@@ -1,7 +0,0 @@
-{
-  "title":"切换源",
-  "cmd":"从给定数据中提取信号源",
-  "fmt":"{\"channel\":信号源}",
-  "prefix":"源是指电视输入的信号源",
-  "targets":"可选值为下列字符串: HDMI1, HDMI2, HDMI3"
-}

+ 0 - 7
app/src/main/assets/cfg/picker/tvctrl/tvHelp.json

@@ -1,7 +0,0 @@
-{
-  "title":"帮助咨询",
-  "cmd":"查询电视的咨询项和咨询关键字",
-  "fmt":"{\"query\":帮助项,\"key\":[关键字1,关键字2,...]}",
-  "prefix":"帮助是指用户在不知道的情况下咨询使用方法等",
-  "targets":"一般性介绍电视的主要功能,询问电视有哪些功能,电视助手能做些什么,咨询电视设备控制功能,主要涉及跟电视的声音,显示参数,显示和音量控制,输入输出设置,网络配置等相关的功能询问"
-}

+ 0 - 7
app/src/main/assets/cfg/picker/tvctrl/tvStatus.json

@@ -1,7 +0,0 @@
-{
-  "title":"状态查询",
-  "cmd":"查询电视的设置状态项",
-  "fmt":"{\"query\":状态项,\"key\":[关键字1,关键字2,...]}",
-  "prefix":"状态项是指当前电视的设置值",
-  "targets":"查看电视当前的状态:频道设置,色彩模式设置,音量设置,分辨率设置,输入源设置,账号等信息"
-}

+ 7 - 37
app/src/main/java/com/ch/jedge/bots/jsmart/JedgeSmartHomeBot.java

@@ -40,42 +40,11 @@ public class JedgeSmartHomeBot extends JBotAppBase {
                 if(cmd==null) {
                     return JMgbusUtil.MgbusResult(401,"控制失败");
                 }
-                switch (cmd) {
-                    case "setLightTemperature":
-                        cmd = "setColorTemperature";
-                        break;
-                    default:
-                        break;
-                }
-                QIData req = new QData().putString("command",cmd);
 
-                JSONArray params = eMsg.getJsonArray("param");
-                if (params != null) {
-                    QIData pp = new QData();
-                    for(Object param : params) {
-                        if(param instanceof String) {
-                            String[] paramSet = ((String) param).split("=");
-                            if(paramSet.length>=2) {
-                                String k = paramSet[0];
-                                String v = paramSet[1];
-                                switch (k) {
-                                    case "device_name":
-                                    case "device_location":
-                                    case "device_type":
-                                        req.putString(k, v);
-                                        break;
-                                    default:try {
-                                        pp.put(k, JSON.parse(v));
-                                    } catch (Exception e) {
-                                        e.printStackTrace();
-                                    } break;
-                                }
-                            }
+                QIData req = new QData().copyFrom(eMsg,"command", "param");
+                req.putString("device_name", eMsg.getName());
+//                req.putString("device_type", eMsg.getName());
 
-                        }
-                    }
-                    req.put("param", pp);
-                }
                 module.highLog("发送消息(coss):%s",req);
                 return postServiceRequest("coss", "/device/controlDevice", req);
             } catch (Exception e) {
@@ -133,14 +102,14 @@ public class JedgeSmartHomeBot extends JBotAppBase {
                     for(Object item : dft) {
                         if(item instanceof String) {
                             re.add(new QData().setName((String) item).setKey((String) item)
-                                    .putString("disc", "默认房间")
+                                    .putString("disc", "默认房间,可执行所有设备操作")
                                     .toJSONString());
                         }
                     }
                     for(Object item : usr) {
                         if(item instanceof String) {
                             re.add(new QData().setKey((String) item).setName((String) item)
-                                    .putString("disc", String.format("(房间:%s)", item))
+                                    .putString("disc", "用户房间, 可执行所有设备操作")
                                     .toJSONString());
                         }
                     }
@@ -169,7 +138,8 @@ public class JedgeSmartHomeBot extends JBotAppBase {
                                     .setName(devName)
                                     .putString("class", devType)
                                     .putString("房间", devRoom)
-                                    .putString("disc", String.format("%s(class:%s,房间:%s)",devName,devType,devRoom))
+                                    .putString("disc", "可执行灯光操作动作")
+//                                    .putString("disc", String.format("%s(class:%s,房间:%s)",devName,devType,devRoom))
                                     .toJSONString();
                             re.add(devInfo);
                             module.exMarkLog("设备信息=%s", devInfo);

+ 17 - 22
app/src/main/java/com/ch/jedge/bots/tvass/JedgeTVAssistant.java

@@ -50,15 +50,15 @@ public class JedgeTVAssistant extends JBotAppBase {
             //
             module.warnLog("Remote call %s", eMsg);
             String cmd = eMsg.getString("command");
-            JSONObject param = eMsg.getJsonObject("params");
+            JSONObject param = eMsg.getJsonObject("param");
             if("setVolume".equals(cmd))
                 setVolume(param);
 //            else if("switchSource".equals(cmd))
 //                switchSource(param);
             else if("setDisplay".equals(cmd))
                 setDisplay(param);
-            else if("setSound".equals(cmd))
-                setSound(param);
+            else if("setSoundMode".equals(cmd))
+                setSoundMode(param);
             else if("setPicture".equals(cmd))
                 setPicture(param);
 
@@ -78,22 +78,13 @@ public class JedgeTVAssistant extends JBotAppBase {
         @JDataGetter
         public List<String> tvCtrlNameList() {
             List<String> re = new ArrayList<>();
-            addTVCtrlDeviceDef(re,"音量控制","音量控制器", "调节电视音量大小的设备");
-            addTVCtrlDeviceDef(re,"源控制","源控制器", "电视输入源控制");
-            addTVCtrlDeviceDef(re,"屏幕控制","屏幕控制", "控制屏幕的亮度,颜色等");
+            addTVCtrlDeviceDef(re,"电视","电视控制器", "电视控制(打开或关闭电视)");
+            addTVCtrlDeviceDef(re,"音量","音量控制器", "电视音量设置(大小或具体数字)");
+            addTVCtrlDeviceDef(re,"屏幕","屏幕控制器", "电视亮度设置(大小或具体数字),屏幕色彩(亮丽,普通,柔和模式设置)");
+            addTVCtrlDeviceDef(re,"源","源控制器", "执行切换源(可以切换到:ATV,HDMI)等动作");
+            addTVCtrlDeviceDef(re,"声音模式","声音模式控制器", "电视声音模式设置(标准,剧场,音乐,新闻)");
             return re;
         }
-
-        private void addTVCtrlDeviceDef(List<String> re, String ctrlName,String objClass, String disc) {
-            String devInfo = new QData()
-                    .setKey(ctrlName)
-                    .setName(ctrlName)
-                    .putString("class", objClass)
-                    .putString("disc", String.format("%s(class:%s,功能:%s)", ctrlName, objClass, disc))
-                    .toJSONString();
-            re.add(devInfo);
-            module.exMarkLog("设备信息=%s", devInfo);
-        }
     }
 
     public JedgeTVAssistant(String botName) {
@@ -129,15 +120,19 @@ public class JedgeTVAssistant extends JBotAppBase {
         if(param.isEmpty())
             return;
 
-        String setItem = param.getString("item");
-        if("亮度".equals(setItem)) {
-            int value = param.getIntValue("param");
-            JeageTVBridge tvBridge = JeageTVBridge.getInstance();
+        JeageTVBridge tvBridge = JeageTVBridge.getInstance();
+
+        if(param.containsKey("lightness")) {
+            int value = param.getIntValue("lightness");
             tvBridge.TVsetBrightness(value);
         }
+        if(param.containsKey("mode")) {
+            String mode = param.getString("mode");
+            tvBridge.TVsetPictureMode(mode);
+        }
     }
 
-    private static void setSound(JSONObject param) {
+    private static void setSoundMode(JSONObject param) {
         if(param.isEmpty())
             return;
 

+ 3 - 3
app/src/main/java/com/ch/jedge/glm/JedgeGlmBridgeService.java

@@ -48,7 +48,7 @@ public class JedgeGlmBridgeService extends JMgbusService {
     private String sval_glm_model_lite32 = "chatglm_lite_32k";
 
     private String intentModel = sval_glm_model_pro;
-    private static final float fval_temperature = 0.9f;
+    private static final float fval_temperature = 0.01f;
     private static final float fval_top_p = 0.7f;
 
 
@@ -188,7 +188,7 @@ public class JedgeGlmBridgeService extends JMgbusService {
     @MgbusApi
     public QIData chat(QIData eMsg) {
         String user_msg = eMsg.getString("query");
-        System.out.printf("[CCCCCCC]Posting>>%s\n", user_msg);
+        System.out.printf("[向GLM发送请求]>>\n%s", user_msg);
         String content;
         if(StringUtils.isValidStr(user_msg))
             content = user_msg;
@@ -263,7 +263,7 @@ public class JedgeGlmBridgeService extends JMgbusService {
 //                        module.printClientLog(String.format("GLM response:>>%s", cc));
                         if(StringUtils.isValidStr(cc))
                             cc = cc.substring(1,cc.length()-1);
-                        module.printClientLog(String.format("GLM response:>>%s", cc));
+                        module.printClientLog(String.format("GLM response:>>\n%s", cc));
                         qData.put("r", cc);
                         qData.put("code", 200);
                         return qData;

+ 4 - 4
app/src/main/java/com/ch/jedge/glm/zhipuai/StandardEventSourceListener.java

@@ -34,12 +34,12 @@ public class StandardEventSourceListener extends ModelEventSourceListener {
 
     private SseMeta meta;
 
-    @Override
+//    @Override
     public void onOpen(EventSource eventSource, Response response) {
         //logger.info("server start sending events");
     }
 
-    @Override
+//    @Override
     public void onEvent(EventSource eventSource, String id, String type, String data, String meta) {
         boolean is_finish = false;
         String formatData = "";
@@ -68,7 +68,7 @@ public class StandardEventSourceListener extends ModelEventSourceListener {
         }
     }
 
-    @Override
+//    @Override
     public void onClosed(EventSource eventSource) {
         logger.info("server stream closed");
         try {
@@ -82,7 +82,7 @@ public class StandardEventSourceListener extends ModelEventSourceListener {
         }
     }
 
-    @Override
+//    @Override
     public void onFailure(EventSource eventSource, Throwable t, Response response) {
         try {
             logger.error("sse connection fail");

+ 14 - 12
app/src/main/java/com/ch/jedge/jbot/JedgeBotGptService.java

@@ -71,15 +71,15 @@ public class JedgeBotGptService extends JMgbusService {
             knAsk_prompt = sval_prompt_kn_talk;
         }
 
-        kn_talk_log_file = talk_log_org_ = FileUtils.contactPath("./", "logs");
-        try {
-            new File(talk_log_org_).mkdirs();
-        } catch (Exception ignored) {}
-        talk_log_org_ = FileUtils.contactPath(talk_log_org_,"userAsk.log");
-        kn_talk_log_file = FileUtils.contactPath(kn_talk_log_file,"knTalk.log");
-
-        //加载动态词库
-        JEDictUtil.loadStaticCommonDicts(dict_, FileUtils.contactPath("./", "cfg", "dict", "common"));
+//        kn_talk_log_file = talk_log_org_ = FileUtils.contactPath("./", "logs");
+//        try {
+//            new File(talk_log_org_).mkdirs();
+//        } catch (Exception ignored) {}
+//        talk_log_org_ = FileUtils.contactPath(talk_log_org_,"userAsk.log");
+//        kn_talk_log_file = FileUtils.contactPath(kn_talk_log_file,"knTalk.log");
+//
+//        //加载动态词库
+//        JEDictUtil.loadStaticCommonDicts(dict_, FileUtils.contactPath("./", "cfg", "dict", "common"));
 
         watchLocalEvent("OnModuleConnected", (w, keyVal, msg) -> {
             String host = msg.getString("host");
@@ -169,7 +169,8 @@ public class JedgeBotGptService extends JMgbusService {
 
     public JSONArray cutWords(String query) {
         if(query.contains("、")) {
-            query = query.replaceAll("、","_");
+//            query = query.replaceAll("、","_");
+            query = query.replace("、","_");
         }
         QIData p = postServiceRequest(sval_modual_word_cut, "/cw/cut", new QData().put("t", query));
         if(JMgbusUtil.isMgbusResultOk(p)) {
@@ -1326,8 +1327,9 @@ public class JedgeBotGptService extends JMgbusService {
 
     private void knTalkLog(String prompt, boolean succ) {
         String log =  "["+ TimeUtils.getNowShortStrWithMillis()+"] ["+(succ?"SUC":"FAL")+"]>>" + prompt;
-        log = log.replaceAll( "\n","");
-        FileUtils.appendLine(kn_talk_log_file, log+"\n", "UTF-8");
+//        log = log.replaceAll( "\n","");
+        log = log.replace( "\n","");
+//        FileUtils.appendLine(kn_talk_log_file, log+"\n", "UTF-8");
     }
 
     protected JedgeServiceSession findSession(QIData req, String prompt) {

+ 4 - 2
app/src/main/java/com/ch/jedge/jbot/JedgeDomainTesterOld.java

@@ -104,7 +104,8 @@ public class JedgeDomainTesterOld {
         }
 
         public String getIntentClassificationTemplate(String finalPrompt, String history) {
-            return intentClassifyTemplateString.replaceAll("\\{query}", finalPrompt).replaceAll("\\{history}", history);
+//            return intentClassifyTemplateString.replaceAll("\\{query}", finalPrompt).replaceAll("\\{history}", history);
+            return intentClassifyTemplateString.replace("{query}", finalPrompt).replace("{history}", history);
         }
 
         private String prepareDataset() {
@@ -195,7 +196,8 @@ public class JedgeDomainTesterOld {
     }
 
     public String getIntentTestPrompt(String query, String history) {
-        return donmainTestTemplateString.replaceAll("\\{query}", query).replaceAll("\\{history}", history);
+//        return donmainTestTemplateString.replaceAll("\\{query}", query).replaceAll("\\{history}", history);
+        return donmainTestTemplateString.replace("{query}", query).replace("{history}", history);
     }
 
     public QIData addNewDataSet(QIData req) {

+ 6 - 3
app/src/main/java/com/ch/jedge/jbot/other/corpus/CorpusTask.java

@@ -34,7 +34,8 @@ public class CorpusTask {
         List<String> lines = new ArrayList<>();
         lines.add(",===,,");
         String orgText = ","+baseText+",,";
-        orgText = orgText.replaceAll("\n", ",,\n,");
+//        orgText = orgText.replaceAll("\n", ",,\n,");
+        orgText = orgText.replace("\n", ",,\n,");
         lines.add(orgText);
         lines.add(",===,,");
         for(Object qa : qaList) {
@@ -121,14 +122,16 @@ public class CorpusTask {
     public void pushQuest(String  text){
         q_ = text;
         if(q_.indexOf('\n')!=-1) {
-            q_ = q_.replaceAll("\n","");
+//            q_ = q_.replaceAll("\n","");
+            q_ = q_.replace("\n","");
         }
     }
 
     public void pushAnswer(String  text) {
         a_ = text;
         if(a_.indexOf('\n')!=-1) {
-            a_ = a_.replaceAll("\n","");
+//            a_ = a_.replaceAll("\n","");
+            a_ = a_.replace("\n","");
         }
     }
 

+ 12 - 5
app/src/main/java/com/ch/jedge/jbot2/JedgeBotGptService.java

@@ -6,6 +6,7 @@ import com.ch.jedge.jbot2.dict.JedgeWordDict;
 import com.ch.jedge.jbot2.llm.JedgeLLMContext;
 import com.ch.jedge.jbot2.context.JedgeTalkSession;
 import com.ch.jedge.jbot2.context.JedgeSmartTaskContext;
+import com.ch.jedge.jbot2.llm.debug.JedgeLLMDataRecorder;
 import com.ch.jedge.utils.JedgeBotConst;
 import com.ch.jedge.utils.JedgeLlmUtil;
 import com.changhong.jedge.JMgbusModual;
@@ -38,13 +39,16 @@ public class JedgeBotGptService extends JMgbusService {
     private String talk_log_org_;
 
     private final JedgeSmartTaskContext smartTaskContext;
+    private final JedgeLLMDataRecorder smartTaskDataRecorder;
     private final JedgeLLMContext llmCtx;
 
     //基本词库
     //
     public JedgeBotGptService(JMgbusModual holder) {
         super(holder);
-        llmCtx = new JedgeLLMContext(module, this);
+        smartTaskDataRecorder = new JedgeLLMDataRecorder(module, this);
+        llmCtx = new JedgeLLMContext(module, this, smartTaskDataRecorder);
+
         smartTaskContext = new JedgeSmartTaskContext(llmCtx);
         auto_remove_call_info = false;
 
@@ -54,8 +58,8 @@ public class JedgeBotGptService extends JMgbusService {
 //        } catch (Exception ignored) {}
 //        talk_log_org_ = FileUtils.contactPath(talk_log_org_,"userAsk.log");
 //        kn_talk_log_file = FileUtils.contactPath(kn_talk_log_file,"knTalk.log");
-
-        //加载动态词库
+//
+//        //加载动态词库
 //        JEDictUtil.loadStaticCommonDicts(dict_, FileUtils.contactPath("./", "cfg", "dict", "common"));
 
         watchLocalEvent("OnModuleConnected", (w, keyVal, msg) -> {
@@ -115,7 +119,9 @@ public class JedgeBotGptService extends JMgbusService {
 
     public JSONArray cutWords(String query) {
         if(query.contains("、")) {
-            query = query.replaceAll("、","_");
+//            query = query.replaceAll("、","_");
+            query = query.replace("、","_");
+
         }
         QIData p = postServiceRequest(sval_modual_word_cut, "/cw/cut", new QData().put("t", query));
         if(JMgbusUtil.isMgbusResultOk(p)) {
@@ -416,7 +422,8 @@ public class JedgeBotGptService extends JMgbusService {
 
     private void knTalkLog(String prompt, boolean succ) {
         String log =  "["+ TimeUtils.getNowShortStrWithMillis()+"] ["+(succ?"SUC":"FAL")+"]>>" + prompt;
-        log = log.replaceAll( "\n","");
+//        log = log.replaceAll( "\n","");
+        log = log.replace( "\n","");
 //        FileUtils.appendLine(kn_talk_log_file, log+"\n", "UTF-8");
     }
 

+ 2 - 1
app/src/main/java/com/ch/jedge/jbot2/JedgeVoiceBotService.java

@@ -247,7 +247,8 @@ public class JedgeVoiceBotService  extends JMgbusService  {
         String streamText = req.getString("msg");
         module.printClientLog(String.format("GPT>>(Going:%s):%s", next_vui_going_?"true":"false", streamText));
         if(StringUtils.isValidStr(streamText) && !streamText.startsWith("[") && !streamText.startsWith("$")) {
-            streamText = streamText.replaceAll("\n", ""); //去掉空行
+//            streamText = streamText.replaceAll("\n", ""); //去掉空行
+            streamText = streamText.replace("\n", ""); //去掉空行
             if (vui_going_ && !streamText.isEmpty()) {
                 synchronized (gptSpeakList) {
                     String str = sentSpliter.pushChars(streamText);

+ 123 - 39
app/src/main/java/com/ch/jedge/jbot2/intent/JedgeJBotCBService.java

@@ -23,7 +23,6 @@ import java.util.Map;
 
 import static com.ch.jedge.utils.JedgeBotConst.sval_default_jbot_jedge;
 
-
 public class JedgeJBotCBService extends JMgbusService {
 
     private boolean is_active_ = false;
@@ -37,6 +36,9 @@ public class JedgeJBotCBService extends JMgbusService {
     private final Map<String, Integer> registeredClassesMap = new HashMap<>();
     //数据集获取API的信息
     private final Map<String, Method> DataGetterMap = new HashMap<>();
+    //已读取的数据集
+    private final Map<String, QIData> ObjModDataMap = new HashMap<>();
+    private final Map<String, QIData> ClsModDataMap = new HashMap<>();
 
     public JedgeJBotCBService(JMgbusModual holder) {
         super(holder);
@@ -190,8 +192,9 @@ public class JedgeJBotCBService extends JMgbusService {
                     if (QIData.class.isAssignableFrom(r) && pm.length == 1 && QIData.class.isAssignableFrom(pm[0])) {
                         String cbUri = String.format("/%s/%s", getName(), m.getName());
                         String domain = a.domain();
+                        //注册知识世界领域
                         registerJBotKnDomain(domain, module.getName(), cbUri);
-                        //先注册DmDomain
+                        //先注册模型世界领域
                         registerJBotDmDomain(domain, module.getName(), cbUri);
                     }
                 }
@@ -205,10 +208,40 @@ public class JedgeJBotCBService extends JMgbusService {
                 .putString("key", domain);
         synchronized (registeredDomainMap){
             if(registeredDomainMap.containsKey(domain)) {
-                req.copyFrom(registeredDomainMap.get(domain), "disc","picker","dmid");
+                req.copyFrom(registeredDomainMap.get(domain), "picker","dmid");
+            }
+        }
+
+        StringBuilder disc = new StringBuilder("可选实体列表如下:");
+        synchronized (ObjModDataMap) {
+            QIData objData = ObjModDataMap.get(domain);
+            if(objData!=null) {
+                List<String> keys = JedgeLlmUtil.getSortedKeyList(objData);
+                if(keys!=null) {
+                    for (String ok : keys) {
+                        JSONArray data = objData.getJsonArray(ok);
+                        if (data != null) {
+                            for (Object od : data) {
+                                if (od instanceof String) {
+                                    QIData odd = QData.fromString((String) od);
+                                    disc.append(String.format("实体对象:%s,实体类型:%s, 动实体作:%s,"
+                                        ,odd.getName(), odd.getString("class"), odd.getString("disc")));
+                                }
+                            }
+                        }
+                    }
+                }
+
+                //,
+                //		实体对象:电视,实体类型:电视控制器, 动实体作:电视控制(打开或关闭电视),
+                //		实体对象:声音,实体类型:声音控制器, 动实体作:电视音量设置(大小或具体数字),
+                //		实体对象:屏幕,实体类型:屏幕控制器, 动实体作:电视亮度设置(大小或具体数字),屏幕色彩(亮丽,普通,柔和模式设置),
+                //		实体对象:源,实体类型源控制器, 动实体作:执行切换源(可以切换到:ATV,HDMI)等动作"
             }
         }
 
+        req.putString("disc", disc.toString());
+
         QIData re = postServiceRequest(sval_default_jbot_jedge, "/gpt/registerDomain", req);
         if(!JMgbusUtil.isMgbusResultOk(re)) {
             module.errLog(String.format("知识领域注册失败 (%s) to %s : %s " , domain, sval_default_jbot_jedge, re.getString("msg")));
@@ -255,13 +288,21 @@ public class JedgeJBotCBService extends JMgbusService {
         synchronized (DataGetterMap) {
             Method m = DataGetterMap.get(initSet);
             if (m != null) {
-                try {
-                    Object re = m.invoke(this);
-                    if(re instanceof List) {
-                        initData =JedgeLlmUtil.JsonArrayFromStringList((List<String>)re);
+                if(ObjModDataMap.containsKey(domain)) {
+                    QIData objData = ObjModDataMap.get(domain);
+                    if(objData!=null) {
+                        initData = objData.getJsonArray(words);
+                    }
+                }
+                if(initData==null) {
+                    try {
+                        Object re = m.invoke(this);
+                        if (re instanceof List) {
+                            initData = JedgeLlmUtil.JsonArrayFromStringList((List<String>) re);
+                        }
+                    } catch (IllegalAccessException | InvocationTargetException e) {
+                        e.printStackTrace();
                     }
-                } catch (IllegalAccessException | InvocationTargetException e) {
-                    e.printStackTrace();
                 }
             }
         }
@@ -306,45 +347,55 @@ public class JedgeJBotCBService extends JMgbusService {
         synchronized (DataGetterMap) {
             Method m = DataGetterMap.get(initSet);
             if (m != null) {
-                try {
-                    Object re = m.invoke(this);
-                    if(re instanceof List) {
-                        initData =JedgeLlmUtil.JsonArrayFromStringList((List<String>)re);
+                if(ClsModDataMap.containsKey(domain)) {
+                    QIData objData = ClsModDataMap.get(domain);
+                    if(objData!=null) {
+                        initData = objData.getJsonArray(words);
+                    }
+                }
+                if(initData==null) {
+                    try {
+                        Object re = m.invoke(this);
+                        if (re instanceof List) {
+                            initData = JedgeLlmUtil.JsonArrayFromStringList((List<String>) re);
+                        }
+                    } catch (IllegalAccessException | InvocationTargetException e) {
+                        e.printStackTrace();
                     }
-                } catch (IllegalAccessException | InvocationTargetException e) {
-                    e.printStackTrace();
                 }
             }
         }
 
-        QIData req = new QData().putString("domain", domain).putString("cbUri", cbUri)
-                .putString("src", moduleName).putString("key", words)
-                .putBoolean("na", isNullable);
-        if(initData!=null) req.put("payload", initData);
-        synchronized (registeredDomainMap){
-            if(registeredDomainMap.containsKey(domain)) {
-                req.copyFrom( registeredDomainMap.get(domain),"dmid");
-            } else {
-                module.errLog(String.format("Fail to register DataSet (%s) to %s : domain %s 尚未注册 " , words, sval_default_jbot_jedge, domain));
-                return;
+        if(initData!=null && !initData.isEmpty()) {
+            QIData req = new QData().putString("domain", domain).putString("cbUri", cbUri)
+                    .putString("src", moduleName).putString("key", words)
+                    .putBoolean("na", isNullable);
+            req.put("payload", initData);
+            synchronized (registeredDomainMap) {
+                if (registeredDomainMap.containsKey(domain)) {
+                    req.copyFrom(registeredDomainMap.get(domain), "dmid");
+                } else {
+                    module.errLog(String.format("Fail to register DataSet (%s) to %s : domain %s 尚未注册 ", words, sval_default_jbot_jedge, domain));
+                    return;
+                }
             }
-        }
-        synchronized (registeredDomainMap) {
-            if(registeredDomainMap.containsKey(words)) {
-                req.putInteger("dsid", registeredClassesMap.get(words));
+            synchronized (registeredDomainMap) {
+                if (registeredDomainMap.containsKey(words)) {
+                    req.putInteger("dsid", registeredClassesMap.get(words));
+                }
             }
-        }
-        QIData re = postServiceRequest(sval_default_jbot_jedge, "/gpt/registerKnClass", req);
-        if(!JMgbusUtil.isMgbusResultOk(re)) {
-            module.errLog(String.format("世界类说明注册失败!! (%s) to %s : %s " , words, sval_default_jbot_jedge, re.getString("msg")));
-        } else {
-            int dsId = re.getInteger("dsid");
-            if(dsId>-1) {
-                synchronized (registeredClassesMap) {
-                    registeredClassesMap.put(words, dsId);  //也可能更新module
+            QIData re = postServiceRequest(sval_default_jbot_jedge, "/gpt/registerKnClass", req);
+            if (!JMgbusUtil.isMgbusResultOk(re)) {
+                module.errLog(String.format("世界类说明注册失败!! (%s) to %s : %s ", words, sval_default_jbot_jedge, re.getString("msg")));
+            } else {
+                int dsId = re.getInteger("dsid");
+                if (dsId > -1) {
+                    synchronized (registeredClassesMap) {
+                        registeredClassesMap.put(words, dsId);  //也可能更新module
+                    }
                 }
+                module.markLog(String.format("世界对象模型说明注册成功:%s(%d)", words, dsId));
             }
-            module.markLog(String.format("世界对象模型说明注册成功:%s(%d)", words, dsId));
         }
     }
 
@@ -380,6 +431,28 @@ public class JedgeJBotCBService extends JMgbusService {
         synchronized (DataGetterMap) {
             DataGetterMap.put(DGetterKey, m);
         }
+        JbotObject oa = m.getAnnotation(JbotObject.class);
+        if(oa!=null) {
+            try {
+                Object re = m.invoke(this);
+                if(re instanceof List) {
+                    JSONArray objListData = JedgeLlmUtil.JsonArrayFromStringList((List<String>) re);
+                    String domainKey = oa.domain();
+                    String objKey = oa.words();
+                    synchronized (ObjModDataMap) {
+                        QIData objData = ObjModDataMap.get(domainKey);
+                        if(objData==null) {
+                            objData = new QData();
+                            ObjModDataMap.put(domainKey, objData);
+                        }
+                        objData.put(objKey, objListData);
+                    }
+                }
+            } catch (IllegalAccessException | InvocationTargetException e) {
+                e.printStackTrace();
+            }
+        }
+
     }
 
     //扫描所有的无模型模板,并注册到jbot
@@ -387,6 +460,17 @@ public class JedgeJBotCBService extends JMgbusService {
         return new ArrayList<>();
     }
 
+    protected void addTVCtrlDeviceDef(List<String> re, String ctrlName,String objClass, String disc) {
+        String devInfo = new QData()
+                .setKey(ctrlName)
+                .setName(ctrlName)
+                .putString("class", objClass)
+                .putString("disc", disc)
+                .toJSONString();
+        re.add(devInfo);
+        module.exMarkLog("设备信息=%s", devInfo);
+    }
+
     public static List<String> loadDataSetFromString(String dsStr) {
         List<String> re = new ArrayList<>();
         QIData d  = QData.fromString(dsStr);

+ 1 - 1
app/src/main/java/com/ch/jedge/jbot2/intent/bot/JBotAppClient.java

@@ -16,7 +16,7 @@ public class JBotAppClient extends JMgbusClient {
     }
 
     public static JBotAppClient createInstance(String botName, String[] serviceNameArray, Class<? extends JMgbusService>[] serviceClsArray) {
-        JBotAppClient jLlmBot = new JBotAppClient("#0", botName, 20, true);
+        JBotAppClient jLlmBot = new JBotAppClient("#0", botName, 50, true);
         if(serviceClsArray==null
                 || (serviceNameArray!=null && serviceClsArray.length != serviceNameArray.length)
                 || (serviceNameArray==null && serviceClsArray.length!=1)) {

+ 4 - 1
app/src/main/java/com/ch/jedge/jbot2/llm/JedgeLLMContext.java

@@ -1,14 +1,17 @@
 package com.ch.jedge.jbot2.llm;
 
 import com.ch.jedge.jbot2.JedgeBotGptService;
+import com.ch.jedge.jbot2.llm.debug.JedgeLLMDataRecorder;
 import com.changhong.jedge.JMgbusModual;
 
 public class JedgeLLMContext {
     public final JMgbusModual module;
     public final JedgeBotGptService service;
+    public final JedgeLLMDataRecorder recorder;
 
-    public JedgeLLMContext(JMgbusModual module, JedgeBotGptService service) {
+    public JedgeLLMContext(JMgbusModual module, JedgeBotGptService service, JedgeLLMDataRecorder recorder) {
         this.module = module;
         this.service = service;
+        this.recorder = recorder;
     }
 }

+ 47 - 0
app/src/main/java/com/ch/jedge/jbot2/llm/debug/JedgeLLMDataRecorder.java

@@ -0,0 +1,47 @@
+package com.ch.jedge.jbot2.llm.debug;
+
+import com.ch.jedge.jbot2.JedgeBotGptService;
+import com.changhong.jedge.JMgbusModual;
+import com.changhong.qlib.QData;
+import com.changhong.qlib.intf.QIData;
+import com.changhong.qlib.util.TimeUtils;
+import com.changhong.qlib.util.file.FileUtils;
+
+//记录请求的输入和输出的值
+public class JedgeLLMDataRecorder {
+    private static final String logPath = "./cfg/test/tvSuperBrain/record/" + TimeUtils.getNowDateString("yyyy/MM/dd") + "/log";
+
+    public final JMgbusModual module;
+    public final JedgeBotGptService service;
+
+    public JedgeLLMDataRecorder(JMgbusModual module, JedgeBotGptService service) {
+        this.module = module;
+        this.service = service;
+    }
+
+    public void recordRawRequest(String pickerKey, String query, String origin) {
+        service.postServiceMessage("stt", "/lmc/reportCommand",
+                new QData().setKey(pickerKey).putString("req", query).putString("q", origin));
+        localRecordRequest(pickerKey, query);
+    }
+
+    public void recordRawResponse(String pickerKey, QIData resp, String origin) {
+        service.postServiceMessage("stt", "/lmc/reportResponse",
+                new QData().setKey(pickerKey).put("rsp", resp.asJson()).putString("q", origin));
+        writeCommandLog(pickerKey, "rsp", resp.toJSONString());
+    }
+
+    public void localRecordRequest(String recKey, String realQuery) {
+        writeCommandLog(recKey, "rq", realQuery);
+    }
+
+    public void localRecordOriginQuery(String query) {
+//        String logFn = FileUtils.contactPath(logPath, "origin.log");
+//        FileUtils.appendLine(logFn, query, "UTF-8");
+    }
+
+    private void writeCommandLog(String recKey, String ext, String realQuery) {
+//        String logFn = FileUtils.contactPath(logPath, recKey+"." + ext);
+//        FileUtils.appendLine(logFn, realQuery, "UTF-8");
+    }
+}

+ 105 - 63
app/src/main/java/com/ch/jedge/jbot2/llm/pickers/JedgeLLMParamPicker.java

@@ -4,16 +4,17 @@ package com.ch.jedge.jbot2.llm.pickers;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.ch.jedge.jbot2.context.JedgeTalkSession;
 import com.ch.jedge.jbot2.llm.JedgeLLMBaseObject;
 import com.ch.jedge.jbot2.llm.JedgeLLMContext;
 import com.ch.jedge.jbot2.llm.request.JedgeLLMRequest;
-import com.ch.jedge.jbot2.context.JedgeTalkSession;
 import com.ch.jedge.utils.JedgeLlmUtil;
 import com.changhong.jedge.JMgbusUtil;
 import com.changhong.qlib.QData;
 import com.changhong.qlib.QDataList;
 import com.changhong.qlib.intf.QIData;
 import com.changhong.qlib.util.StringUtils;
+import com.changhong.qlib.util.file.FileUtils;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
@@ -24,6 +25,7 @@ import java.util.*;
  *  可动态添加dataset的item项.当item项超过一定的数量时,需要执行多级分类.
  */
 public class JedgeLLMParamPicker  extends JedgeLLMBaseObject {
+    protected String complex_tpl;
     protected JedgeLLMRequest llmRequest = null;
     public String params_;          //所需要提取的参数及其说明,可能需要多次调用,确认最终参数。参数提取,可能需要额外的一次请求。
 
@@ -31,10 +33,7 @@ public class JedgeLLMParamPicker  extends JedgeLLMBaseObject {
     protected JedgeLLMResultValidator validator_ = null;  //结果校验器,检验结果是否包含某些参数,主要针对特定的消息格式模板进行
 
     protected final Map<String, QIData> mDatasetMap = new HashMap<>();
-    private String role = "";
-    private String cmd = "";
-    private String fmt = "";
-    private String prefix = "";
+    private String pickerKey = "";
 
     public JedgeLLMParamPicker(JedgeLLMContext llmCtx, Class<? extends JedgeLLMRequest> requestClass) {
         super(llmCtx);
@@ -90,13 +89,42 @@ public class JedgeLLMParamPicker  extends JedgeLLMBaseObject {
     }
 
     public QIData pickParamsFromQuery(JedgeTalkSession s, String query, String paramKey, String... para) {
-        String dataset = prepareDataset(paramKey);
-        String realQuery = llmRequest.getRealPrompt(s, query, para);
-        if(StringUtils.isValidStr(dataset)) {
-            realQuery = dataset + realQuery;
+        String realQuery = "";
+        String recKey = StringUtils.getSubStrAfter(pickerKey,'/', -1);
+        if(recKey==null) recKey = pickerKey;
+
+        if(StringUtils.isValidStr(complex_tpl)) {
+//            realQuery = complex_tpl.replaceAll("\\{query}", query);
+            realQuery = complex_tpl.replace("{query}", query);
+        } else return null;
+        if(complex_tpl.contains("{data}")) {
+            String dataset = prepareDataset(paramKey);
+            if(StringUtils.isNotValidStr(dataset)) dataset = "{}";
+//            realQuery = realQuery.replaceAll("\\{data}", dataset);
+            realQuery = realQuery.replace("{data}", dataset);
+        }
+        if(complex_tpl.contains("{data_keys}")) {
+            //替换KeyList
+            String targetKeyList = getDataKeyList(paramKey);
+            if(StringUtils.isNotValidStr(targetKeyList)) targetKeyList = "";
+//            realQuery = realQuery.replaceAll("\\{data_keys}", targetKeyList);
+            realQuery = realQuery.replace("{data_keys}", targetKeyList);
+        }
+        if(complex_tpl.contains("{example}")) {
+            //替换KeyList
+            String examples = getDataExamples(paramKey);
+            if(StringUtils.isNotValidStr(examples))
+                examples = "";
+//            realQuery = realQuery.replaceAll("\\{example}", examples);
+            realQuery = realQuery.replace("{example}", examples);
         }
+
+        llmContext.recorder.recordRawRequest(recKey, realQuery, query);
+
         QIData lmRsp = llmRequest.makeChatRequest(s, realQuery);
 
+        llmContext.recorder.recordRawResponse(recKey, lmRsp ,query);
+
         if(validator_!=null && !validator_.validateResult(lmRsp)) {
             //再次LLM Request,提取专有参数结果。
             return JMgbusUtil.MgbusResult(402, "Validate failed.");
@@ -104,27 +132,46 @@ public class JedgeLLMParamPicker  extends JedgeLLMBaseObject {
         return lmRsp;
     }
 
-    protected String prepareDataset(String... paramKey) {
+    //获取示例,新增模块如何解析的example
+    private String getDataExamples(String... paramKey) {
+        return null;
+//        StringBuilder re = new StringBuilder();
+//        if(paramKey!=null && paramKey.length>0) {
+//            synchronized (mDatasetMap) {
+//                for (String k : paramKey) {
+//                    QIData d = mDatasetMap.get(k);
+//                    if (d != null) {
+//                        re.append(d.getData("val").toJSONString(true));
+//                    }
+//                }
+//            }
+//        }
+//        return re.toString();
+    }
+
+    private String getDataKeyList(String... paramKey) {
         StringBuilder re = new StringBuilder();
-        if(paramKey==null || paramKey.length==0 || paramKey[0]==null) {
+        if(paramKey!=null && paramKey.length>0) {
             synchronized (mDatasetMap) {
-                for (String k : mDatasetMap.keySet()) {
+                for (String k : paramKey) {
                     QIData d = mDatasetMap.get(k);
                     if (d != null) {
-                        re.append(d.getName()).append(':');
-                        re.append(d.getString("d")).append(',');
-                        re.append("取值依据:").append(d.getData("val").toJSONString()).append('.');
+                        re.append(StringUtils.ListToString(JedgeLlmUtil.getSortedKeyList(d.getData("val")), ','));
                     }
                 }
             }
-        } else {
+        }
+        return re.toString();
+    }
+
+    protected String prepareDataset(String... paramKey) {
+        StringBuilder re = new StringBuilder();
+        if(paramKey!=null && paramKey.length>0) {
             synchronized (mDatasetMap) {
                 for (String k : paramKey) {
                     QIData d = mDatasetMap.get(k);
                     if (d != null) {
-                        re.append(d.getName()).append(':');
-                        re.append(d.getString("d")).append(',');
-                        re.append("取值依据:").append(d.getData("val").toJSONString()).append('.');
+                        re.append(d.getData("val").toJSONString(true));
                     }
                 }
             }
@@ -138,42 +185,14 @@ public class JedgeLLMParamPicker  extends JedgeLLMBaseObject {
         }
     }
 
-    public boolean loadPickerFromData(QIData defs) {
-        JSONArray ta = defs.getJsonArray("targets");
-        String targets = null;
-        if(ta!=null)
-            targets =  JedgeLlmUtil.StringFromStringJSONArray(ta);
-        else
-            targets = defs.getString("targets");
-
-        String cmd = defs.getString("cmd");
-        String fmt = defs.getString("fmt");
-        String role = defs.getString("role");
-        String prefix = defs.getString("prefix");
-        String[] targetDefs = null;
-        if(ta!=null)
-            targetDefs = targets.split(",");
-        else {
-            targetDefs = getParamDatasetValues(defs, targets);
-            if (targetDefs == null) {
-                targetDefs = new String[]{targets};
-            }
-        }
-        if(StringUtils.isNotValidStr(cmd) || StringUtils.isNotValidStr(fmt))
-            return false;
-        loadDataset(defs);
-        defineDataPicker( targetDefs, role, cmd, fmt, prefix);
-        return true;
-    }
-
     public boolean loadPickerFromFile(String filename) {
-        QIData defs = QData.fromFile(filename);
-        if(defs.isEmpty()) return false;
-        return loadPickerFromData(defs);
+        pickerKey = FileUtils.getFilenameWithoutExt(filename);
+        complex_tpl = StringUtils.readStringFromFile(filename);
+        return StringUtils.isValidStr(pickerKey) && StringUtils.isValidStr(complex_tpl);
     }
 
     //移除数据项
-    public void addDataToDatasetItem(String dmKey, String valKey, String val) {
+    public void addDataToDatasetItem(String dmKey, String dmName, String valKey, String val) {
         QIData ds;
         synchronized (mDatasetMap) {
             ds = mDatasetMap.get(dmKey);
@@ -187,16 +206,17 @@ public class JedgeLLMParamPicker  extends JedgeLLMBaseObject {
         JSONObject vals = ds.getJsonObject("val");
         if(vals==null) {
             vals = new JSONObject();
+            ds.setName(dmName);
             ds.put("val", vals);
         }
         vals.put(valKey, val);
-        rebuildLLMRequest();
+        rebuildLLMRequest(dmKey);
     }
 
-    private void rebuildLLMRequest() {
+    private void rebuildLLMRequest(String dmKey) {
         QIData ds;
         synchronized (mDatasetMap) {
-            ds = mDatasetMap.get("name");
+            ds = mDatasetMap.get(mDatasetMap.containsKey("name")?"name":dmKey);
         }
         String[] targetDefs;
         if(ds!=null) {
@@ -205,7 +225,7 @@ public class JedgeLLMParamPicker  extends JedgeLLMBaseObject {
         } else {
             targetDefs = new String[0];
         }
-        llmRequest.setTemplateStr(targetDefs, role, cmd, fmt, prefix);
+        // llmRequest.setTemplateStr(targetDefs, role, cmd, fmt, prefix);
     }
 
     //增加数据项
@@ -217,10 +237,37 @@ public class JedgeLLMParamPicker  extends JedgeLLMBaseObject {
         if(ds!=null) {
             JSONObject vals = ds.getJsonObject("val");
             if(vals.remove(valKey)!=null)
-                rebuildLLMRequest();
+                rebuildLLMRequest(dmKey);
         }
     }
 
+    public boolean loadPickerFromData(QIData defs) {
+        JSONArray ta = defs.getJsonArray("targets");
+        String targets = null;
+        if(ta!=null)
+            targets =  JedgeLlmUtil.StringFromStringJSONArray(ta);
+        else
+            targets = defs.getString("targets");
+
+        String cmd = defs.getString("cmd");
+        String fmt = defs.getString("fmt");
+        String role = defs.getString("role");
+        String prefix = defs.getString("prefix");
+        String[] targetDefs = null;
+        if(ta!=null)
+            targetDefs = targets.split(",");
+        else {
+            targetDefs = getParamDatasetValues(defs, targets);
+            if (targetDefs == null) {
+                targetDefs = new String[]{targets};
+            }
+        }
+        if(StringUtils.isNotValidStr(cmd) || StringUtils.isNotValidStr(fmt))
+            return false;
+        loadDataset(defs);
+        return true;
+    }
+
     public void loadDataset(QIData defs) {
         JSONArray datasets = defs.getJsonArray("datasets");
         if(datasets==null || datasets.isEmpty())
@@ -279,12 +326,7 @@ public class JedgeLLMParamPicker  extends JedgeLLMBaseObject {
         return null;
     }
 
-    protected void defineDataPicker(String[] targetDefs, String role, String cmd, String fmt, String prefix) {
-        //todo:: 从直接值中建立DataSetMap
-        this.role = role;
-        this.cmd = cmd;
-        this.fmt = fmt;
-        this.prefix = prefix;
-        llmRequest.setTemplateStr(targetDefs, role, cmd, fmt, prefix);
+    public String getPikerKey() {
+        return pickerKey;
     }
 }

+ 8 - 14
app/src/main/java/com/ch/jedge/jbot2/llm/pickers/JedgeLLMParamPickerManager.java

@@ -26,20 +26,14 @@ public class JedgeLLMParamPickerManager extends JedgeLLMBaseObject {
 
     public void loadPickersFromPath(String dirPath) {
         FileUtils.iteratorDirectory(dirPath, file -> {
-            String fn = file.getName();
-            if(fn.endsWith(".json")) {
-//                llmContext.module.highLog("扫描到 LLM Param Picker:%s", fn);
-                QIData pickerDef = QData.fromFile(file);
-                if(!pickerDef.isEmpty()) {
-                    JedgeLLMParamPicker picker = new JedgeLLMParamPicker(llmContext);
-                    if(picker.loadPickerFromData(pickerDef)) {
-                        String key = pickerDef.getKey();
-                        if(StringUtils.isNotValidStr(key))
-                            key = FileUtils.getFilenameWithoutExt(fn);
-                        llmContext.module.markLog("LLM Param Picker (%s) 成功加载", key);
-                        synchronized (pickerMap) {
-                            pickerMap.put(key, picker);
-                        }
+            String fn = file.getAbsolutePath();
+            if(fn.endsWith(".tpl")) {
+                JedgeLLMParamPicker picker = new JedgeLLMParamPicker(llmContext);
+                if(picker.loadPickerFromFile(fn)) {
+                    String key = picker.getPikerKey();
+                    llmContext.module.markLog("LLM Param Picker (%s) 成功加载", key);
+                    synchronized (pickerMap) {
+                        pickerMap.put(key, picker);
                     }
                 }
             }

+ 0 - 15
app/src/main/java/com/ch/jedge/jbot2/llm/pickers/JedgeSmartHomeActionPicker.java

@@ -1,15 +0,0 @@
-package com.ch.jedge.jbot2.llm.pickers;
-
-import com.ch.jedge.jbot2.llm.JedgeLLMContext;
-
-
-/**
- * 多重任务功能提取器
- */
-public class JedgeSmartHomeActionPicker extends JedgeLLMParamPicker {
-
-    public JedgeSmartHomeActionPicker(JedgeLLMContext llmCtx) {
-        super(llmCtx);
-        loadPickerFromFile("/storage/emulated/0/Android/data/com.ch.jedge.llm.filter.glm/cache/cfg/picker/action/index.json");
-    }
-}

+ 0 - 9
app/src/main/java/com/ch/jedge/jbot2/llm/pickers/JedgeTaskObjectivePicker.java

@@ -1,9 +0,0 @@
-package com.ch.jedge.jbot2.llm.pickers;
-
-import com.ch.jedge.jbot2.llm.JedgeLLMContext;
-
-public class JedgeTaskObjectivePicker extends JedgeLLMParamPicker {
-    public JedgeTaskObjectivePicker(JedgeLLMContext llmCtx) {
-        super(llmCtx);
-    }
-}

+ 0 - 50
app/src/main/java/com/ch/jedge/jbot2/llm/request/JedgeLLMCOTRequest.java

@@ -1,50 +0,0 @@
-package com.ch.jedge.jbot2.llm.request;
-
-
-import com.ch.jedge.jbot2.intent.bot.JBotAppBase;
-import com.ch.jedge.jbot2.llm.JedgeLLMContext;
-import com.changhong.qlib.util.StringUtils;
-
-/**
- *  发起请求:
- *  (1) 请求的相关参数结构:
- *      query
- *
- *      template
- *
- *      response解析器
- *
- *      callback
- *
- *      结构化参数的模板
- *
- *      参数及其解释
- *
- *      校验器
- *
- *  (2) 返回
- *      json结构
- *
- *
- */
-
-public class JedgeLLMCOTRequest extends JedgeLLMRequest {
-    public JedgeLLMCOTRequest(JedgeLLMContext llmCtx) {
-        super(llmCtx);
-    }
-
-    @Override
-    public void setTemplateStr(String[] split, String role, String cmd, String fmt, String prefix) {
-        String targets = StringUtils.ListToString(split, ',');
-        this.template_ =
-                String.format("你的角色是:%s," +
-                        "从用户输入内容中抽取实体或信息,从\"%s\"中%s," +
-                        "用结构化方式的json格式输出,格式:%s.只输出json内容,不输出其他。" +
-                        "用户输入:{query},让我们一步一步地分析:", role, targets, cmd ,fmt);
-        if(StringUtils.isValidStr(prefix))
-            this.template_ = prefix + "," + this.template_;
-//        if(JBotAppBase.isDebugMode())
-            llmContext.module.warnLog("template reset to : %s", template_);
-    }
-}
-

+ 0 - 55
app/src/main/java/com/ch/jedge/jbot2/llm/request/JedgeLLMFilterRequest.java

@@ -1,55 +0,0 @@
-package com.ch.jedge.jbot2.llm.request;
-
-
-import com.ch.jedge.jbot2.context.JedgeTalkSession;
-import com.ch.jedge.jbot2.llm.JedgeLLMContext;
-import com.changhong.qlib.util.StringUtils;
-
-/**
- *  发起请求:
- *  (1) 请求的相关参数结构:
- *      query
- *
- *      template
- *
- *      response解析器
- *
- *      callback
- *
- *      结构化参数的模板
- *
- *      参数及其解释
- *
- *      校验器
- *
- *  (2) 返回
- *      json结构
- *
- *
- */
-
-public class JedgeLLMFilterRequest extends JedgeLLMRequest {
-    public JedgeLLMFilterRequest(JedgeLLMContext llmCtx) {
-        super(llmCtx);
-    }
-
-    @Override
-    public void setTemplateStr(String[] split, String role, String cmd, String fmt, String prefix) {
-        String targets = StringUtils.ListToString(split, ',');
-        this.template_ =
-                String.format("你的角色是:%s," +
-                        "要过滤内容的相关领域是{domain},%s," +
-                        "填写到json数据格式中,格式:%s.只输出json内容,不输出其他。" +
-                        "用户输入:{query},你的输出:", role, cmd ,fmt);
-        if(StringUtils.isValidStr(prefix))
-            this.template_ = prefix + "," + this.template_;
-    }
-
-    @Override
-    public String getRealPrompt(JedgeTalkSession s, String query, String[] para) {
-        String p = super.getRealPrompt(s, query, para);
-//        return p.replaceAll("\\{domain}", para[0]);
-        return p.replace("{domain}", para[0]);
-    }
-}
-

+ 0 - 32
app/src/main/java/com/ch/jedge/jbot2/llm/request/JedgeLLMRequest.java

@@ -35,20 +35,9 @@ import com.changhong.qlib.util.StringUtils;
  */
 
 public class JedgeLLMRequest extends JedgeLLMBaseObject {
-    public String template_;        //解释这次请求的目的
 
     public JedgeLLMRequest(JedgeLLMContext llmCtx) {
         super(llmCtx);
-        this.template_ = "{query}";
-    }
-//
-//    public String getRealPrompt(JedgeTalkSession s, String query) {
-//        return template_.replaceAll("\\{query}", query);
-//    }
-
-    public String getRealPrompt(JedgeTalkSession s, String query, String[] para) {
-//        return template_.replaceAll("\\{query}", query);
-        return template_.replace("{query}", query);
     }
 
     public QIData makeChatRequest(JedgeTalkSession s, String realQuery) {
@@ -67,13 +56,6 @@ public class JedgeLLMRequest extends JedgeLLMBaseObject {
         return resp;
     }
 
-    //TODO::截获异步的请求
-    public QIData makeStreamRequest(JedgeTalkSession s, String realQuery) {
-        llmContext.service.makeRealGptStreamCall(s, realQuery);
-        //对结果字符串进行结构:判断其是否包含json结构字符串,斌并校验之
-        return null;
-    }
-
     public static QIData handleLLMTextResponse(String result) {
         if(StringUtils.isValidStr(result)) {
             result = result.trim();
@@ -96,19 +78,5 @@ public class JedgeLLMRequest extends JedgeLLMBaseObject {
         }
         return null;
     }
-
-    public void setTemplateStr(String[] split, String role, String cmd, String fmt, String prefix) {
-        String targets = StringUtils.ListToString(split, ',');
-        this.template_ =
-                String.format("你的角色是:%s," +
-                        "从用户输入内容中抽取实体或信息,从\"%s\"中%s," +
-                        "用结构化方式的json格式输出,格式:%s.只输出json内容,不输出其他。" +
-                        "用户输入:{query},你的输出:", role, targets, cmd ,fmt);
-        if(StringUtils.isValidStr(prefix))
-            this.template_ = prefix + "," + this.template_;
-//        if(JBotAppBase.isDebugMode())
-            llmContext.module.warnLog("template reset to : %s", template_);
-    }
-
 }
 

+ 35 - 0
app/src/main/java/com/ch/jedge/jbot2/llm/request/JedgeLLMRequestMaker.java

@@ -0,0 +1,35 @@
+package com.ch.jedge.jbot2.llm.request;
+
+
+import com.ch.jedge.jbot2.context.JedgeTalkSession;
+import com.ch.jedge.jbot2.llm.JedgeLLMContext;
+import com.changhong.qlib.util.StringUtils;
+
+/**
+ *  生成一个与特定领域主题相关的延申请求
+ */
+
+public class JedgeLLMRequestMaker extends JedgeLLMRequest {
+    public JedgeLLMRequestMaker(JedgeLLMContext llmCtx) {
+        super(llmCtx);
+    }
+//
+//    @Override
+//    public void setTemplateStr(String[] split, String role, String cmd, String fmt, String prefix) {
+//        String targets = StringUtils.ListToString(split, ',');
+//        this.template_ =
+//                String.format("你的角色是:%s," +
+//                        "根据用户输入内容中、从\"%s\"所代表的领域中%s," +
+//                        "用结构化方式的json格式输出,格式:%s.只输出json内容,不输出其他。" +
+//                        "用户输入:{query},你的输出:", role, targets, cmd ,fmt);
+//        if(StringUtils.isValidStr(prefix))
+//            this.template_ = prefix + "," + this.template_;
+//    }
+//
+//    @Override
+//    public String getRealPrompt(JedgeTalkSession s, String query, String[] para) {
+//        String p = super.getRealPrompt(s, query, para);
+//        return p.replaceAll("\\{domain}", para[0]);
+//    }
+}
+

+ 8 - 1
app/src/main/java/com/ch/jedge/jbot2/llm/world/JedgeLLMDmWorld.java

@@ -6,6 +6,7 @@ import com.ch.jedge.jbot2.context.JedgeTalkSession;
 import com.ch.jedge.jbot2.llm.JedgeLLMBaseObject;
 import com.ch.jedge.jbot2.llm.JedgeLLMContext;
 import com.ch.jedge.jbot2.llm.pickers.JedgeLLMParamPicker;
+import com.ch.jedge.jbot2.llm.world.knl.JedgeDomainQueryMaker;
 import com.ch.jedge.jbot2.llm.world.knl.JedgeDomainSelector;
 import com.ch.jedge.jbot2.llm.world.model.JedgeMdDomain;
 import com.ch.jedge.jbot2.llm.world.model.JedgeMdObject;
@@ -34,9 +35,12 @@ import static com.ch.jedge.utils.JedgeBotConst.ival_max_timeout_count;
 public class JedgeLLMDmWorld extends JedgeLLMBaseObject {
     protected final Map<String, JedgeMdDomain> domainMap = new HashMap<>();
     private final JedgeDomainSelector domainSelector;
+    private final JedgeDomainQueryMaker domainQueryMaker;
     public JedgeLLMDmWorld(JedgeLLMContext llmCtx) {
         super(llmCtx);
         domainSelector = new JedgeDomainSelector(llmCtx);
+        domainSelector.addDataToDatasetItem("domain", "领域分类器", "others", "与上述领域领域均不相关");
+        domainQueryMaker = new JedgeDomainQueryMaker(llmCtx);
     }
 
     /**
@@ -83,6 +87,7 @@ public class JedgeLLMDmWorld extends JedgeLLMBaseObject {
             for(String dmKey :toDel) {
                 domainMap.remove(dmKey);
                 domainSelector.removeDataFromDatasetItem("domain", dmKey);
+                domainQueryMaker.removeDataFromDatasetItem("domain", dmKey);
                 if(JedgeBotConst.debugMode)
                     llmContext.module.infoLog(String.format("Domain超时移除:%s", dmKey));
             }
@@ -126,7 +131,8 @@ public class JedgeLLMDmWorld extends JedgeLLMBaseObject {
         if(JedgeBotConst.debugMode)
             llmContext.module.highLog(String.format("领域模块注册成功:%s", dmKey));
 
-        domainSelector.addDataToDatasetItem("domain", dmKey, req.getString("disc"));
+        domainSelector.addDataToDatasetItem("domain", "领域分类器", dmKey, req.getString("disc"));
+        domainQueryMaker.addDataToDatasetItem("domain", "任务推理器", dmKey, req.getString("disc"));
         return JMgbusUtil.MgbusResult(200, "领域添加成功").putInteger("dmid", domainDef.getDmObjectId());
     }
 
@@ -139,6 +145,7 @@ public class JedgeLLMDmWorld extends JedgeLLMBaseObject {
                     JedgeMdDomain dmDef = domainMap.get(dmKey);
                     if(dmDef!=null && dmDef.getDmObjectId()==dmid) {
                         domainMap.remove(dmKey);
+                        domainQueryMaker.removeDataFromDatasetItem("domain", dmKey);
                         domainSelector.removeDataFromDatasetItem("domain", dmKey);
                         llmContext.module.highLog(String.format("领域模块移除成功:%s", dmKey));
                         return JMgbusUtil.MgbusResult(200,"removed " + dmKey);

+ 14 - 0
app/src/main/java/com/ch/jedge/jbot2/llm/world/knl/JedgeDomainQueryMaker.java

@@ -0,0 +1,14 @@
+package com.ch.jedge.jbot2.llm.world.knl;
+
+import com.ch.jedge.jbot2.llm.JedgeLLMContext;
+import com.ch.jedge.jbot2.llm.pickers.JedgeLLMParamPicker;
+import com.ch.jedge.jbot2.llm.request.JedgeLLMRequest;
+
+public class JedgeDomainQueryMaker extends JedgeLLMParamPicker {
+
+    public JedgeDomainQueryMaker(JedgeLLMContext llmContext) {
+        super(llmContext, JedgeLLMRequest.class);
+        loadPickerFromFile("/storage/emulated/0/Android/data/com.ch.jedge.llm.filter.glm/cache/cfg/picker/system/taskMake.tpl");
+    }
+
+}

+ 2 - 3
app/src/main/java/com/ch/jedge/jbot2/llm/world/knl/JedgeDomainSelector.java

@@ -2,14 +2,13 @@ package com.ch.jedge.jbot2.llm.world.knl;
 
 import com.ch.jedge.jbot2.llm.JedgeLLMContext;
 import com.ch.jedge.jbot2.llm.pickers.JedgeLLMParamPicker;
-import com.ch.jedge.jbot2.llm.request.JedgeLLMCOTRequest;
 import com.ch.jedge.jbot2.llm.request.JedgeLLMRequest;
 
 public class JedgeDomainSelector extends JedgeLLMParamPicker {
 
+
     public JedgeDomainSelector(JedgeLLMContext llmContext) {
         super(llmContext, JedgeLLMRequest.class);
-        loadPickerFromFile("/storage/emulated/0/Android/data/com.ch.jedge.llm.filter.glm/cache/cfg/picker/system/domain.json");
+        loadPickerFromFile("/storage/emulated/0/Android/data/com.ch.jedge.llm.filter.glm/cache/cfg/picker/system/domain.tpl");
     }
-
 }

+ 16 - 55
app/src/main/java/com/ch/jedge/jbot2/llm/world/knl/JedgeLLMKnWorld.java

@@ -36,7 +36,7 @@ public class JedgeLLMKnWorld extends JedgeLLMBaseObject {
 
     protected final Map<String, JedgeKnDomain> domainDefMap = new HashMap<>();
     protected final JedgeDomainSelector domainSelector;
-//    protected final JedgeContentCutter domainContentFilter;
+    private final JedgeDomainQueryMaker domainQueryMaker;
     protected final JedgeTaskTester taskTester;
     protected final JedgeSystemKnDomain domainSystem;
 
@@ -44,7 +44,8 @@ public class JedgeLLMKnWorld extends JedgeLLMBaseObject {
         super(llmCtx);
         taskTester = new JedgeTaskTester(llmCtx);
         domainSelector = new JedgeDomainSelector(llmCtx);
-//        domainContentFilter = new JedgeContentCutter(llmCtx);
+        domainSelector.addDataToDatasetItem("domain", "领域分类器", "others", "与上述领域领域均不相关");
+        domainQueryMaker = new JedgeDomainQueryMaker(llmCtx);
         if(JedgeBotConst.enableSmartTaskCreate) {
             String sdPath = "/storage/emulated/0/Android/data/com.ch.jedge.llm.filter.glm/cache/cfg/domains/system";
             domainSystem = new JedgeSystemKnDomain(llmCtx, sdPath);
@@ -57,68 +58,29 @@ public class JedgeLLMKnWorld extends JedgeLLMBaseObject {
         }
     }
 
-    //加上需要带参数的 内容提取请求 content的补充内容
-//    public String filterDomainContent(JedgeTalkSession s, String query, String domain) {
-//        return domainContentFilter.getClassifiedParam(s, query, "domain", domain);
-//    }
+
     //判断领域,可能存在多轮。
     public QIData testDomain(JedgeTalkSession s, String query) {
-        QIData domains = domainSelector.getClassifiedParamAsData(s, query, "domain");
-        if(domains instanceof QIDataList) {
-            if(((QIDataList) domains).getItemCount()>1) {
-                //移除重复或空的domain
-                int last = ((QIDataList) domains).getItemCount();
-                List<Integer> delList = new ArrayList<>();
-                for(int i=last-1;i>-1;i--) {
-                    Object obj = ((QIDataList) domains).asJsonArray().get(i);
-                    if(!(obj instanceof JSONObject) ||
-                            StringUtils.isNotValidStr(((JSONObject) obj).getString("query"))) {
-                        delList.add(i);
-                    }
-                }
-                for(int i : delList) {
-                    ((QIDataList) domains).removeItem(i);
-                }
-                if(((QIDataList) domains).asJsonArray().size()>0) {
-                    int i = 0;
-                    String first = null;
-                    StringBuilder tail = new StringBuilder();
-                    for (Object obj : ((QIDataList) domains).asJsonArray()) {
-                        if (obj instanceof JSONObject) {
-                            String q = ((JSONObject) obj).getString("query");
-                            if (i++ == 0) {
-                                first = q;
-                                if (query.length() - first.length() > 5)
-                                    return domains;
-                            } else
-                                tail.append(q);
-                        }
-                    }
-                    //去掉重复的内容
-                    if (first != null && first.length() > tail.length()) {
-                        int end = first.length() - tail.length();
-                        first = first.substring(0, end);
-                        ((JSONObject) ((QIDataList) domains).asJsonArray().get(0)).put("query", first);
-                        if (JBotAppBase.isDebugMode())
-                            llmContext.module.highLog("Rebound domains: %s", domains);
-                    }
-                }
-            }
-        }
-        return domains;
+        return domainSelector.getClassifiedParamAsData(s, query, "domain");
     }
 
     /**
      * 从domain中获得领域知识。
+     *
+     * @param s
      * @param domain    领域
      * @param taskKey   任务标记(中文)
      * @return          任务
      */
-    public JedgeLLMTask createTaskFromTemplate(String domain, String taskKey) {
+    public JedgeLLMTask createTaskFromTemplate(JedgeTalkSession s, String domain, String taskKey) {
+        String newTask = domainQueryMaker.getClassifiedParam(s, taskKey,"newTask");
         JedgeKnDomain domainDef = getDomain(domain);
         if(domainDef!=null) {
             return domainDef.createDomainTask(llmContext, taskKey, taskTester);
         }
+        //为用户生成一个推荐任务的对话或意图:
+
+
         return null;
     }
 
@@ -145,8 +107,8 @@ public class JedgeLLMKnWorld extends JedgeLLMBaseObject {
 
             for(String dmKey :toDel) {
                 domainDefMap.remove(dmKey);
+                domainQueryMaker.removeDataFromDatasetItem("domain", dmKey);
                 domainSelector.removeDataFromDatasetItem("domain", dmKey);
-//                domainContentFilter.removeDataFromDatasetItem("domain", dmKey);
                 if(JedgeBotConst.debugMode)
                     llmContext.module.infoLog(String.format("Domain超时移除:%s", dmKey));
             }
@@ -161,8 +123,6 @@ public class JedgeLLMKnWorld extends JedgeLLMBaseObject {
      * @return  返回值
      */
     public QIData addNewDomain(QIData req) {
-//        if(JedgeBotConst.debugMode)
-//            llmContext.module.infoLog("add domain : " + req);
         String dmKey = req.getKey();
         if(StringUtils.isNotValidStr(dmKey))
             return JMgbusUtil.MgbusResult(401, "No domainKey");
@@ -188,8 +148,8 @@ public class JedgeLLMKnWorld extends JedgeLLMBaseObject {
         if(JedgeBotConst.debugMode)
             llmContext.module.highLog(String.format("领域模块注册成功:%s", dmKey));
 
-        domainSelector.addDataToDatasetItem("domain", dmKey, req.getString("disc"));
-//        domainContentFilter.addDataToDatasetItem("domain", dmKey, req.getString("disc"));
+        domainSelector.addDataToDatasetItem("domain","领域分类器", dmKey, req.getString("disc"));
+        domainQueryMaker.addDataToDatasetItem("domain", "任务推理器",dmKey, req.getString("disc"));
         result.putInteger("dmid", domainDef.getDmObjectId());
         return result;
     }
@@ -203,6 +163,7 @@ public class JedgeLLMKnWorld extends JedgeLLMBaseObject {
                     JedgeKnDomain dmDef = domainDefMap.get(dmKey);
                     if(dmDef!=null && dmDef.getDmObjectId()==dmid) {
                         domainDefMap.remove(dmKey);
+                        domainQueryMaker.removeDataFromDatasetItem("domain", dmKey);
                         domainSelector.removeDataFromDatasetItem("domain", dmKey);
                         llmContext.module.highLog(String.format("领域模块移除成功:%s", dmKey));
                         return JMgbusUtil.MgbusResult(200,"removed " + dmKey);

+ 0 - 13
app/src/main/java/com/ch/jedge/jbot2/llm/world/knl/task/JedgeContentCutter.java

@@ -1,13 +0,0 @@
-package com.ch.jedge.jbot2.llm.world.knl.task;
-
-import com.ch.jedge.jbot2.llm.JedgeLLMContext;
-import com.ch.jedge.jbot2.llm.pickers.JedgeLLMParamPicker;
-import com.ch.jedge.jbot2.llm.request.JedgeLLMFilterRequest;
-
-public class JedgeContentCutter extends JedgeLLMParamPicker {
-
-    public JedgeContentCutter(JedgeLLMContext llmContext) {
-        super(llmContext, JedgeLLMFilterRequest.class);
-        loadPickerFromFile("/storage/emulated/0/Android/data/com.ch.jedge.llm.filter.glm/cache/cfg/picker/system/cutter.json");
-    }
-}

+ 1 - 1
app/src/main/java/com/ch/jedge/jbot2/llm/world/model/JedgeMdDomain.java

@@ -57,7 +57,7 @@ public class JedgeMdDomain extends JedgeKnObject  {
     }
 
     public void addDomainObjectName(String dm, String objName, String objInfo) {
-        objectSelector.addDataToDatasetItem(dm, objName, objInfo);
+        objectSelector.addDataToDatasetItem(dm, "对象名称" ,objName, objInfo);
     }
 
     public void removeDomainObjectName(String dm, String name) {

+ 7 - 16
app/src/main/java/com/ch/jedge/jbot2/llm/world/system/JedgeLLMSystemTask.java

@@ -60,34 +60,24 @@ public class JedgeLLMSystemTask extends JedgeLLMTask {
         String dm = d.getString("domain");
         if(StringUtils.isNotValidStr(dm))
             return false;
-//        if(JBotAppBase.isDebugMode())   //暂时不执行后续代码
-//            return true;
-        String taskType = taskTester.checkTaskType(s, q);
-        if(taskType!=null) {
-            if("direcInst".equals(taskType) ||
-                    "queryStatus".equals(taskType)) {
-                //直接执行一个即时指令
-                if(JedgeBotConst.debugMode) {
-                    llmContext.service.returnGptMessage(s, String.format("任务类型:%s\n", taskType), false);
-                }
+        if(JBotAppBase.isDebugMode())   //暂时不执行后续代码
+            llmContext.service.returnDirectGptMessage(s, String.format("处理指令:%s ...\n", q), false);
                 JedgeKnDomain dmDef = knWorld.getDomain(dm);
                 if (dmDef != null) {
                     //要判断这个指令是否具备了所有的参数,如果有参数提取失败,则Agent要发起提问,寻求进一步参数
                     JedgeLLMAgent agent = dmDef.getInstructionAgent();
                     if (agent != null) {
-                        String objectId = dmWorld.getOperationTarget(s, dm, q);  //获取操作对象
-                        agent.runInstruction(s, q, objectId, dmDef.getCommandKey());
+                        String objName = d.getString("object");
+                        agent.runInstruction(s, objName, q, dmDef.getCommandKey());
                     }
                     return true;
                 }
-            }
-        }
         //补充任务创建参数
         if(!checkTaskCreationParams(s, query, dm)) {
             return false;
         }
         // 创建一个新的任务
-        JedgeLLMTask theTask = knWorld.createTaskFromTemplate(dm, query);
+        JedgeLLMTask theTask = knWorld.createTaskFromTemplate(s, dm, query);
         if(theTask!=null) {
             //任务处理对话并创建Agent
             if(theTask.handleQuery(s, query, new QData(d))) {
@@ -103,7 +93,8 @@ public class JedgeLLMSystemTask extends JedgeLLMTask {
     }
 
     private boolean checkTaskCreationParams(JedgeTalkSession s, String query, String domain) {
-        return false;
+        //为用户推荐一个任务
+        return true;
     }
 
     public void resetTaskCreationStatus() {

+ 30 - 35
app/src/main/java/com/ch/jedge/jbot2/llm/world/task/JedgeLLMAgent.java

@@ -6,9 +6,11 @@ import com.ch.jedge.jbot2.llm.JedgeLLMBaseObject;
 import com.ch.jedge.jbot2.llm.JedgeLLMContext;
 import com.ch.jedge.jbot2.llm.pickers.JedgeLLMParamPicker;
 import com.ch.jedge.jbot2.llm.pickers.JedgeLLMParamPickerManager;
+import com.ch.jedge.utils.JedgeBotConst;
 import com.changhong.jedge.JMgbusUtil;
 import com.changhong.qlib.QData;
 import com.changhong.qlib.intf.QIData;
+import com.changhong.qlib.intf.QIDataList;
 import com.changhong.qlib.util.StringUtils;
 
 public class JedgeLLMAgent extends JedgeLLMBaseObject {
@@ -27,62 +29,55 @@ public class JedgeLLMAgent extends JedgeLLMBaseObject {
         ppManager.loadPickersFromPath(path);
     }
 
-    public boolean runInstruction(JedgeTalkSession s, String query, String objectId, String mainParamKey) {
+    public boolean runInstruction(JedgeTalkSession s, String objName, String query, String mainParamKey) {
         //需要加载哪些数据集
         JedgeLLMParamPicker indexParser = ppManager.getLLMParamPicker(mainParamKey);
         if(indexParser==null) {
             llmContext.service.returnDirectGptMessage(s, "未找到动作识别器:" + mainParamKey + "\n");
             return false;
         }
-        String actions = indexParser.getClassifiedParam(s, query, mainParamKey);
-//        llmContext.service.returnDirectGptMessage(s, "识别动作:" + actions + "\n");
-//        if(JBotAppBase.isDebugMode())   //暂时不执行后续代码
-//            return true;
-        QIData params = null;
-        if(actions!=null) {
-            if (actions.contains(",")) {
-                for (String acKey : actions.split(",")) {
-                    JedgeLLMParamPicker picker = ppManager.getLLMParamPicker(acKey);
-                    if (picker != null) {
-                        llmContext.service.returnDirectGptMessage(s, "处理参数:" + acKey + "\n");
-                        params = picker.pickParamsFromQuery(s, query, null);
-                    }
-                    makeInstructionCall(s, query, mainParamKey, acKey, objectId, params);
-                }
-            } else {
-                JedgeLLMParamPicker picker = ppManager.getLLMParamPicker(actions);
-                if (picker != null) {
-                    params = picker.pickParamsFromQuery(s, query, null);
-                }
-                makeInstructionCall(s, query, mainParamKey, actions, objectId, params);
+        QIData actions = indexParser.getClassifiedParamAsData(s, query, mainParamKey);
+        if(JedgeBotConst.debugNoCommandExec)   //暂时不执行后续代码
+            return true;
+        if(actions instanceof QIDataList) {
+            int actionsCount = ((QIDataList) actions).getItemCount();
+            for(int i=0;i<actionsCount;i++) {
+                QIData act = ((QIDataList) actions).getItem(i);
+                runSingleInstructionAction(s, objName, query, mainParamKey, act, act);
             }
+        } else {
+            runSingleInstructionAction(s, objName, query, mainParamKey, actions, actions);
         }
         return true;
     }
 
-    private void makeInstructionCall(JedgeTalkSession s, String query, String mainParamKey, String acKey, String objId, QIData params) {
-        if(objId.indexOf(',')>-1) {
-            String[] Objs = objId.split(",");
-            for(String o : Objs) {
-                makeInstructionCall(s, query, mainParamKey, acKey, params, o);
+    private void runSingleInstructionAction(JedgeTalkSession s, String objName, String query,
+                                            String mainParamKey, QIData action, QIData act) {
+        String command = act.getString(mainParamKey);
+        JedgeLLMParamPicker picker = ppManager.getLLMParamPicker(command);
+        QIData param = action.getData("param");
+        if (picker != null) {
+            llmContext.service.returnDirectGptMessage(s, "处理命令参数:" + command + "\n");
+            QIData exParam = picker.pickParamsFromQuery(s, query, null);
+            if(exParam!=null) {
+                param.copyData(exParam);
             }
-        } else {
-            makeInstructionCall(s, query, mainParamKey, acKey, params, objId);
         }
+        action.setName(objName);
+        makeInstructionCall(s, objName, query, command, action);
     }
 
-    private void makeInstructionCall(JedgeTalkSession s, String query, String mainParamKey, String acKey, QIData params, String o) {
-        QIData req = new QData().putString(mainParamKey, acKey).put("params", params).putString("name", o);
-        QIData resp = llmContext.service.postServiceRequest(cbMod, cbUri, req);
+    private void makeInstructionCall(JedgeTalkSession s, String objName, String query, String acKey, QIData action) {
+        QIData resp = llmContext.service.postServiceRequest(cbMod, cbUri, action);
         if (!JMgbusUtil.isMgbusResultOk(resp) && JBotAppBase.isDebugMode())
-            llmContext.service.returnDirectGptMessage(s, "请求" + acKey + "失败.\n");
+            llmContext.service.returnDirectGptMessage(s, String.format("对%s请求%s:失败.\n", objName, acKey));
         else {
             String returnMessage = resp.getString("llmMsg");
             if(StringUtils.isValidStr(returnMessage)) {
-                String responseQuery = String.format("用户输入:%s,系统返回:%s,请生成一个对用户的应答", query, returnMessage );
+                String responseQuery = String.format("用户输入:%s,系统返回:%s,请生成一个对用户的精简应答", query, returnMessage );
                 llmContext.service.makeRealGptStreamCall(s, responseQuery);
             }
-            llmContext.service.returnDirectGptMessage(s, "请求:" + acKey + "成功.\n");
+            llmContext.service.returnDirectGptMessage(s, String.format("对%s请求%s:成功.\n", objName, acKey));
         }
     }
 }

+ 7 - 3
app/src/main/java/com/ch/jedge/jbot2/llm/world/task/JedgeLLMTaskPool.java

@@ -8,6 +8,7 @@ import com.ch.jedge.jbot2.llm.JedgeLLMContext;
 import com.ch.jedge.jbot2.llm.world.JedgeLLMDmWorld;
 import com.ch.jedge.jbot2.llm.world.knl.JedgeLLMKnWorld;
 import com.ch.jedge.jbot2.llm.world.system.JedgeLLMSystemTask;
+import com.ch.jedge.utils.JedgeBotConst;
 import com.changhong.qlib.intf.QIData;
 import com.changhong.qlib.util.sync.SystemUtils;
 
@@ -66,8 +67,8 @@ public class JedgeLLMTaskPool extends JedgeLLMBaseObject {
 
         //如果不能判定领域,则判断与当前任务领域的融合性。
         QIData domain = knWorld.testDomain(s, query);
-//        if(JBotAppBase.isDebugMode())
-//            return null;
+        if(JedgeBotConst.debugNoCommand)
+            return null;
         if(activeTask!=null) {
             if(activeTask.handleQuery(s, query, domain)) {
                 //融合了上一个任务,不做后续任务创建处理
@@ -78,6 +79,7 @@ public class JedgeLLMTaskPool extends JedgeLLMBaseObject {
             }
         }
 
+        //如果domain为other,则用多个domain进行目标任务推荐。
         synchronized (systemTask) {
             if (systemTask.handleQuery(s, query, domain)) {
                 activeTask = systemTask.getCurrentTask();
@@ -96,7 +98,9 @@ public class JedgeLLMTaskPool extends JedgeLLMBaseObject {
     public void makeUnhandledQueryResponse(JedgeTalkSession s, String query) {
         //生成一个提示词?
         // knWorld.makeCommonResponse(s, query);
-        llmContext.service.returnDirectGptMessage(s, "暂不处理.\n", true);
+//        llmContext.service.returnDirectGptMessage(s, "暂不处理.\n", true);
+        llmContext.service.returnDirectGptMessage(s, "处理完成.\n", true);
+
     }
 
     public void onHeartbeat() {

+ 1 - 1
app/src/main/java/com/ch/jedge/llm/filter/glm/MainActivity.java

@@ -69,7 +69,7 @@ public class MainActivity extends AppCompatActivity {
         BaseJedgeService.startJedgeService(this , dir, jedgeBasePath, "llm", JGlmService.class);
         BaseJedgeService.startJedgeService(this , dir, jedgeBasePath, "tvass", TVAgentService.class);
         BaseJedgeService.startJedgeService(this , dir, jedgeBasePath, "tvmufis", TVMufisService.class);
-//        BaseJedgeService.startJedgeService(this , dir, jedgeBasePath, "jsmart", PanleAgentService.class);
+        BaseJedgeService.startJedgeService(this , dir, jedgeBasePath, "jsmart", PanleAgentService.class);
 
         //注册广播
         registerReceiver(new AsrMsgReceiver(), asr_filter);

+ 3 - 3
app/src/main/java/com/ch/jedge/tvmufis/JedgeTvMufisService.java

@@ -57,12 +57,12 @@ public class JedgeTvMufisService extends JMgbusService {
         glm_msg += eMsg.getString("msg");
         boolean isEnd = eMsg.getBoolean("end",false);
 //        Log.d("TVMUFIS", "GLM返回>>" + msg);
-        if(isEnd){
+//        if(isEnd) {
             JeageTVBridge bridge = JeageTVBridge.getInstance();
-            String msg = glm_msg;
+            String msg = glm_msg.replace("\n", "");
             bridge.putglmMsg(msg);
             glm_msg = "";
-        }
+//        }
         return JMgbusUtil.MgbusResult(200,"ok");
     }
 

+ 7 - 0
app/src/main/java/com/ch/jedge/utils/JedgeBotConst.java

@@ -62,10 +62,17 @@ public class JedgeBotConst {
     public static final String sval_verb_type_user_defined_inference = "nugr";      //需要推理预测结果的词,不是直接命中答案。
     public static final int lval_min_time_gap = 5000; //每5S添加一条向量数据,防止添加过快导致milvus崩溃
 
+    public static final String skey_jdk_template_data = "\\{data}";
+    public static final String skey_jdk_template_example = "\\{example}";
+    public static final String skey_jdk_template_query = "\\{query}";
+
     public static final String sval_predict_split = "$$$";
     public static final String sval_predict_sign = "@@@";
     public static final int sval_predict_sign_size = sval_predict_sign.length();
 
     public static boolean debugMode = false;
     public static boolean enableSmartTaskCreate = false;
+    public static boolean debugNoCommand = false;
+    public static boolean debugNoCommandExec = false;
+    public static boolean debugNoObjectId = true;
 }

+ 12 - 3
app/src/main/java/com/ch/jedge/utils/JedgeLlmUtil.java

@@ -6,10 +6,9 @@ import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.parser.Feature;
 import com.changhong.jedge.JMgbusUtil;
 import com.changhong.qlib.intf.QIData;
+import com.changhong.qlib.util.StringUtils;
 
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 public class JedgeLlmUtil {
     public static QIData simpleOk() {
@@ -132,4 +131,14 @@ public class JedgeLlmUtil {
         }
         return new String[0];
     }
+
+    public static List<String> getSortedKeyList(QIData objData) {
+        try {
+            ArrayList<String> re = new ArrayList<>(objData.asJsonObject().keySet());
+            Collections.sort(re);
+            return re;
+        } catch (Exception e ){
+            return null;
+        }
+    }
 }