feat: 参数类型与提示模板的角色全部改为枚举类型
This commit is contained in:
@@ -36,7 +36,7 @@ public class NodeVariable {
|
|||||||
* 类型
|
* 类型
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "类型不能为空")
|
@NotNull(message = "类型不能为空")
|
||||||
private String type;
|
private NodeVariableType type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否必填
|
* 是否必填
|
||||||
@@ -74,7 +74,7 @@ public class NodeVariable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Object getSerializable(JSONObject custom) {
|
private Object getSerializable(JSONObject custom) {
|
||||||
switch (getVariableType()) {
|
switch (this.type) {
|
||||||
case TEXT_INPUT, PARAGRAPH, SELECT, FILE -> {
|
case TEXT_INPUT, PARAGRAPH, SELECT, FILE -> {
|
||||||
return custom.getString(variable);
|
return custom.getString(variable);
|
||||||
}
|
}
|
||||||
@@ -89,10 +89,5 @@ public class NodeVariable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public NodeVariableType getVariableType() {
|
|
||||||
return NodeVariableType.get(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.metis.domain.entity.base;
|
package com.metis.domain.entity.base;
|
||||||
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -15,7 +15,7 @@ public class VariableOption {
|
|||||||
/**
|
/**
|
||||||
* 值
|
* 值
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "值不能为空")
|
@NotBlank(message = "值不能为空")
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,22 @@
|
|||||||
package com.metis.enums;
|
package com.metis.enums;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public enum ChatRoleType {
|
public enum ChatRoleType {
|
||||||
SYSTEM,
|
SYSTEM("system"),
|
||||||
USER,
|
USER("user"),
|
||||||
AI,
|
AI("ai"),
|
||||||
TOOL_EXECUTION_RESULT;
|
TOOL_EXECUTION_RESULT("toolExecutionResult");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
|
||||||
|
ChatRoleType(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.metis.runner.impl.llm;
|
package com.metis.runner.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
@@ -36,7 +36,7 @@ public class StartNodeValidator implements NodeValidator<StartNodeConfig> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (NodeVariable variable : variables) {
|
for (NodeVariable variable : variables) {
|
||||||
switch (variable.getVariableType()) {
|
switch (variable.getType()) {
|
||||||
// 文本类型校验
|
// 文本类型校验
|
||||||
case TEXT_INPUT, PARAGRAPH -> textVariableValidator(variable);
|
case TEXT_INPUT, PARAGRAPH -> textVariableValidator(variable);
|
||||||
// 下拉框变量校验
|
// 下拉框变量校验
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
"appId": 1919041086810968064,
|
|
||||||
"name": "llm运行测试",
|
"name": "llm运行测试",
|
||||||
"description": "llm运行测试",
|
"description": "llm运行测试",
|
||||||
"graph": {
|
"graph": {
|
||||||
@@ -17,13 +16,32 @@
|
|||||||
"icon": "SuitcaseLine",
|
"icon": "SuitcaseLine",
|
||||||
"toolbarPosition": "right",
|
"toolbarPosition": "right",
|
||||||
"config": {
|
"config": {
|
||||||
|
// 输入变量
|
||||||
"variables": [
|
"variables": [
|
||||||
{
|
{
|
||||||
|
// 输入变量字段名称
|
||||||
"variable": "query",
|
"variable": "query",
|
||||||
"label": "查询条件",
|
"label": "查询条件",
|
||||||
|
// 类型 TEXT_INPUT(1, "text-input", "文本"),
|
||||||
|
// PARAGRAPH(2, "paragraph", "段落"),
|
||||||
|
// SELECT(3, "select", "下拉框"),
|
||||||
|
// NUMBER(4, "number", "数字"),
|
||||||
|
// FILE(5, "file", "文件"),
|
||||||
|
// FILE_LIST(6, "file-list", "文件列表")
|
||||||
"type": "text-input",
|
"type": "text-input",
|
||||||
|
// 最大长度
|
||||||
"maxLength": 60,
|
"maxLength": 60,
|
||||||
"required": true
|
// 是否必填
|
||||||
|
"required": true,
|
||||||
|
"options": {
|
||||||
|
"label": "描述",
|
||||||
|
// 描述为空的时候, label显示值
|
||||||
|
"value": "值"
|
||||||
|
// 值不能为空
|
||||||
|
},
|
||||||
|
"allowedFileUploadMethods": ["localFile","remoteUrl"], // 允许上传方式
|
||||||
|
"allowedFileTypes": [""], // 允许文件类型 自定义
|
||||||
|
"allowedFileExtensions": [""] // 允许文件扩展名 可以自定义
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"variable": "background",
|
"variable": "background",
|
||||||
@@ -60,14 +78,17 @@
|
|||||||
"icon": "",
|
"icon": "",
|
||||||
"toolbarPosition": "right",
|
"toolbarPosition": "right",
|
||||||
"config": {
|
"config": {
|
||||||
|
// 上下文字段 node_5 为节点id, background为阶段运行之后的内容
|
||||||
"context": "node_5.background",
|
"context": "node_5.background",
|
||||||
"retryConfig": {
|
"retryConfig": {
|
||||||
"enable": true,
|
"enable": true,
|
||||||
"maxRetries": 3,
|
"maxRetries": 3,
|
||||||
"retryInterval": 1000
|
"retryInterval": 1000
|
||||||
},
|
},
|
||||||
|
// 提示模板
|
||||||
"promptTemplate": [
|
"promptTemplate": [
|
||||||
{
|
{
|
||||||
|
// 角色
|
||||||
"role": "system",
|
"role": "system",
|
||||||
"text": "你的背景是${context}",
|
"text": "你的背景是${context}",
|
||||||
"id": "1"
|
"id": "1"
|
||||||
|
|||||||
Reference in New Issue
Block a user