Skip to content

提交大模型json描述需要改成json schema #485

@baisui1981

Description

@baisui1981

现在提交给大模型的prompt内容,相关代码位置:https://github.com/datavane/tis/blob/v5.0.0/tis-console/src/main/java/com/qlangtech/tis/aiagent/core/TISPlanAndExecuteAgent.java#L116

用户需求:创建一个管道从mysql同步到mysql,实例名称为:mysql-mysql-order。源端数据库配置是 host:192.168.28.200 ,端口:3306,dbname:order2,用户名:root,密码为:123456,目标端配置,host:192.168.28.200,端口:3306,dbname:shop ,用户名:root,密码为123456。从目标端选取几张表,需要表前缀为:order

请分析上述需求,识别数据同步的源端和目标端类型,并提取配置参数。

请严格按照以上JSON Schema格式返回结果,只返回JSON,不要包含其他说明文字:
{
  "intention":"string类型",
  "source": {"type":"string,值必须为系统提示词中枚举到的端类型关键词,大小写必须一致","extractInfo":"类型为string,从用户提供的数据通道任务描述信息中抽取源端相关的描述信息","selectedTabs":"类型为string,从用户提供的数据通道任务描述信息中抽取源端相关的信息(如:‘除AA、BB表以外的所有表’,‘前缀为user的表’,‘AA,BB’),如不能抽取得到则设置为空字符串"} ,
  "target": {"type":"string,值必须为系统提示词中枚举到的端类型关键词,大小写必须一致","extractInfo":"类型为string,从用户提供的数据通道任务描述信息中抽取目标端相关的描述信息"} ,
  "options": {
    "execute_batch": "类型为boolean,表明数据管道创建完成之后是否立即触发全量数据同步,默认为false",
    "enable_incr": "类型为boolean,表明数据管道创建完成后是否立即启动增量事实同步,默认为false"
  }
}

response是:

{
	"options":{
		"enable_incr":false,
		"execute_batch":false
	},
	"source":{
		"selectedTabs":"",
		"type":"MySQL",
		"extractInfo":"host:192.168.28.200,端口:3306,dbname:order2,用户名:root,密码为:123456"
	},
	"intention":"CreatePipeline",
	"target":{
		"selectedTabs":"前缀为order的表",
		"type":"MySQL",
		"extractInfo":"host:192.168.28.200,端口:3306,dbname:shop,用户名:root,密码为123456。从目标端选取几张表,需要表前缀为:order"
	}
}

JSON 结构性描述不是标准化的schema描述文本,为了让大模型更好地理解json结构,需要将提交prompt中的json内容描述转换成标准的schema描述信息:

{
	"name": "CreatePipelineRequest",
	"schema": {
		"type": "object",
		"properties": {
			"intention": {
				"type": "string",
				"description": "他是一个枚举类型,支持的值为:CreatePipeline(创建端到端的数据同步管道相关的任务),Other(不能识别到全部归到此类型)"
			},
			"source": {
				"type": "object",
				"properties": {
					"type": {
						"type": "string",
						"description": "值必须为系统提示词中枚举到的端类型关键词,大小写必须一致"
					},
					"extractInfo": {
						"type": "string",
						"description": "从用户提供的数据通道任务描述信息中抽取源端相关的描述信息"
					},
					"selectedTabs": {
						"type": "string",
						"description": "从用户提供的数据通道任务描述信息中抽取源端相关的信息(如:‘除AA、BB表以外的所有表’,‘前缀为user的表’,‘AA,BB’),如不能抽取得到则设置为空字符串"
					}
				},
				"required": ["type", "extractInfo", "selectedTabs"]
			},
			"target": {
				"type": "object",
				"properties": {
					"type": {
						"type": "string",
						"description": "值必须为系统提示词中枚举到的端类型关键词,大小写必须一致"
					},
					"extractInfo": {
						"type": "string",
						"description": "从用户提供的数据通道任务描述信息中抽取目标端相关的描述信息"
					}
				},
				"required": ["type", "extractInfo"]
			},
			"options": {
				"type": "object",
				"properties": {
					"enable_incr": {
						"type": "boolean",
						"description": "表明数据管道创建完成之后是否立即触发全量数据同步"
					},
					"execute_batch": {
						"type": "boolean",
						"description": "表明数据管道创建完成后是否立即启动增量事实同步"
					}
				},
				"required": ["enable_incr", "execute_batch"]
			}
		},
		"required": ["intention", "source", "target", "options"]
	},
	"strict": true
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions