feat: 参数类型与提示模板的角色全部改为枚举类型

This commit is contained in:
2025-05-05 01:42:43 +08:00
parent 077166e1a6
commit 041a908180
6 changed files with 42 additions and 17 deletions

View File

@@ -36,7 +36,7 @@ public class NodeVariable {
* 类型
*/
@NotNull(message = "类型不能为空")
private String type;
private NodeVariableType type;
/**
* 是否必填
@@ -74,7 +74,7 @@ public class NodeVariable {
}
private Object getSerializable(JSONObject custom) {
switch (getVariableType()) {
switch (this.type) {
case TEXT_INPUT, PARAGRAPH, SELECT, FILE -> {
return custom.getString(variable);
}
@@ -89,10 +89,5 @@ public class NodeVariable {
}
@JsonIgnore
public NodeVariableType getVariableType() {
return NodeVariableType.get(type);
}
}

View File

@@ -1,7 +1,7 @@
package com.metis.domain.entity.base;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
@Data
@@ -15,7 +15,7 @@ public class VariableOption {
/**
* 值
*/
@NotNull(message = "值不能为空")
@NotBlank(message = "值不能为空")
private String value;

View File

@@ -1,13 +1,22 @@
package com.metis.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
@Getter
public enum ChatRoleType {
SYSTEM,
USER,
AI,
TOOL_EXECUTION_RESULT;
SYSTEM("system"),
USER("user"),
AI("ai"),
TOOL_EXECUTION_RESULT("toolExecutionResult");
@JsonValue
private final String value;
ChatRoleType(String value) {
this.value = value;
}
}

View File

@@ -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.util.ObjectUtil;

View File

@@ -36,7 +36,7 @@ public class StartNodeValidator implements NodeValidator<StartNodeConfig> {
}
for (NodeVariable variable : variables) {
switch (variable.getVariableType()) {
switch (variable.getType()) {
// 文本类型校验
case TEXT_INPUT, PARAGRAPH -> textVariableValidator(variable);
// 下拉框变量校验

View File

@@ -1,5 +1,4 @@
{
"appId": 1919041086810968064,
"name": "llm运行测试",
"description": "llm运行测试",
"graph": {
@@ -17,13 +16,32 @@
"icon": "SuitcaseLine",
"toolbarPosition": "right",
"config": {
// 输入变量
"variables": [
{
// 输入变量字段名称
"variable": "query",
"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",
// 最大长度
"maxLength": 60,
"required": true
// 是否必填
"required": true,
"options": {
"label": "描述",
// 描述为空的时候, label显示值
"value": "值"
// 值不能为空
},
"allowedFileUploadMethods": ["localFile","remoteUrl"], // 允许上传方式
"allowedFileTypes": [""], // 允许文件类型 自定义
"allowedFileExtensions": [""] // 允许文件扩展名 可以自定义
},
{
"variable": "background",
@@ -60,14 +78,17 @@
"icon": "",
"toolbarPosition": "right",
"config": {
// 上下文字段 node_5 为节点id, background为阶段运行之后的内容
"context": "node_5.background",
"retryConfig": {
"enable": true,
"maxRetries": 3,
"retryInterval": 1000
},
// 提示模板
"promptTemplate": [
{
// 角色
"role": "system",
"text": "你的背景是${context}",
"id": "1"