From a1d42958d9fd04997803a24ec52dda735d800c09 Mon Sep 17 00:00:00 2001 From: lxc <3250162035@qq.com> Date: Tue, 19 Aug 2025 22:46:08 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=8A=A0=E5=AF=86?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 6 +- prompto-lab-app/Dockerfile | 6 +- .../src/main/resources/application.yml | 2 +- .../testnode/ainode/AIChatOperation.java | 74 ++++++++++++++----- 4 files changed, 66 insertions(+), 22 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1b6d8c2..0bff4d8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,7 +33,7 @@ jobs: echo "PR Description: $commit_message" env="" - module="PromptoLab" + module="" module_type="" version="" skip="" @@ -48,6 +48,10 @@ jobs: skip="${BASH_REMATCH[1]}" fi + if [[ "$commit_message" =~ -m:([^\ ]*) ]]; then + module="${BASH_REMATCH[1]}" + fi + if [[ "$commit_message" =~ -rp:([^\ ]*) ]]; then run_port="${BASH_REMATCH[1]}" fi diff --git a/prompto-lab-app/Dockerfile b/prompto-lab-app/Dockerfile index 0cb490e..da94c87 100644 --- a/prompto-lab-app/Dockerfile +++ b/prompto-lab-app/Dockerfile @@ -1,5 +1,5 @@ FROM adoptopenjdk:11-jre-hotspot -COPY *.jar /rvc-captcha.jar +COPY *.jar /prompto-lab.jar ARG SERVER_PORT ARG ACTIVE @@ -28,6 +28,6 @@ ENV UNIQUE_ID=${UNIQUE_ID} ENV JASYPT_PASSWORD = ${JASYPT_PASSWORD} EXPOSE ${SERVER_PORT} -ENTRYPOINT ["java","-jar","/.jar"] +ENTRYPOINT ["java","-jar","/prompto-lab.jar"] -# -e:test -type:single -m:rvc-captcha -v:1.0.2 -rp:8080 -de:<-e ACTIVE=test -e SERVER_PORT=8080> \ No newline at end of file +# -e:test -type:single -m:prompto-lab -v:1.0.2 -rp:8080 -de:<-e ACTIVE=test -e SERVER_PORT=8080> \ No newline at end of file diff --git a/prompto-lab-app/src/main/resources/application.yml b/prompto-lab-app/src/main/resources/application.yml index 64ee53e..77dce9f 100644 --- a/prompto-lab-app/src/main/resources/application.yml +++ b/prompto-lab-app/src/main/resources/application.yml @@ -7,7 +7,7 @@ spring: application: name: poet-agent datasource: - url: ${SPRING_DATASOURCE_URL:ENC(74AA8WeNmewtlYjGh4jIWPh8E6cxGrZ0M7zg+1wAfBJLR36B6GTw4cvCfA/EhuZiy0oSbrnGRERv5IxzsxfOFA==)} + url: ${SPRING_DATASOURCE_URL:ENC(AdWk4PSD8S3YHvL824vcUWPkYgVIdSRID1Sy7d2xGa+/WoU0PHMTXvVyk+n7LjQAeidxhRDRQSw9ilmYnY5eef5Tb+1lP4LSa+C5up64Sal7lEqgXbTvalO50Yrsn+mgUGoPJ5DfJ8bETsD35HPKNc/AhcxbzeJHFxrHKhYMsI8EJRFhpzho81HAUd6ARO1l2Ugryj+nbXfWMIgD7PZ6Uo32hHOYzxivRN18YiKmSHU=)} username: ${SPRING_DATASOURCE_USERNAME:ENC(nOfIk0lODnZFZinDkKMeEX5zHzXpOoIj)} password: ${SPRING_DATASOURCE_PASSWORD:ENC(W52dd0i/Q8pT/yEJIKs6Zc/brOr6KjXBPVcwdjoe4g4=)} driver-class-name: ${SPRING_DATASOURCE_DRIVER_CLASS_NAME:org.postgresql.Driver} diff --git a/prompto-lab-app/src/test/java/io/github/timemachinelab/testnode/ainode/AIChatOperation.java b/prompto-lab-app/src/test/java/io/github/timemachinelab/testnode/ainode/AIChatOperation.java index 0d99b4e..de7a4b6 100644 --- a/prompto-lab-app/src/test/java/io/github/timemachinelab/testnode/ainode/AIChatOperation.java +++ b/prompto-lab-app/src/test/java/io/github/timemachinelab/testnode/ainode/AIChatOperation.java @@ -26,25 +26,65 @@ public class AIChatOperation extends BaseAIOperation Date: Wed, 20 Aug 2025 21:02:37 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0ai=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=8F=8D=E5=BA=8F=E5=88=97=E5=8C=96=EF=BC=8C=E6=A0=91=E6=89=81?= =?UTF-8?q?=E5=B9=B3=E5=8C=96=E5=BA=8F=E5=88=97=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../constant/QATypeConstant.java | 9 + .../timemachinelab/core/qatree/QaTree.java | 1 - .../core/serializable/AIJsonSerialize.java | 48 +++++ .../core/serializable/QaTreeSerialize.java | 179 ++++++++++++++++++ .../core/serializable/Serialize.java | 9 + 5 files changed, 245 insertions(+), 1 deletion(-) create mode 100644 prompto-lab-app/src/main/java/io/github/timemachinelab/constant/QATypeConstant.java create mode 100644 prompto-lab-app/src/main/java/io/github/timemachinelab/core/serializable/AIJsonSerialize.java create mode 100644 prompto-lab-app/src/main/java/io/github/timemachinelab/core/serializable/QaTreeSerialize.java create mode 100644 prompto-lab-app/src/main/java/io/github/timemachinelab/core/serializable/Serialize.java diff --git a/prompto-lab-app/src/main/java/io/github/timemachinelab/constant/QATypeConstant.java b/prompto-lab-app/src/main/java/io/github/timemachinelab/constant/QATypeConstant.java new file mode 100644 index 0000000..fb9c4e7 --- /dev/null +++ b/prompto-lab-app/src/main/java/io/github/timemachinelab/constant/QATypeConstant.java @@ -0,0 +1,9 @@ +package io.github.timemachinelab.constant; + +public class QATypeConstant { + public static final String FORM_QA = "form"; + public static final String TEXT_QA = "text"; + + + +} diff --git a/prompto-lab-app/src/main/java/io/github/timemachinelab/core/qatree/QaTree.java b/prompto-lab-app/src/main/java/io/github/timemachinelab/core/qatree/QaTree.java index 906e84c..d0d5430 100644 --- a/prompto-lab-app/src/main/java/io/github/timemachinelab/core/qatree/QaTree.java +++ b/prompto-lab-app/src/main/java/io/github/timemachinelab/core/qatree/QaTree.java @@ -1,6 +1,5 @@ package io.github.timemachinelab.core.qatree; -import lombok.Data; import lombok.Getter; import java.util.HashMap; diff --git a/prompto-lab-app/src/main/java/io/github/timemachinelab/core/serializable/AIJsonSerialize.java b/prompto-lab-app/src/main/java/io/github/timemachinelab/core/serializable/AIJsonSerialize.java new file mode 100644 index 0000000..f470e03 --- /dev/null +++ b/prompto-lab-app/src/main/java/io/github/timemachinelab/core/serializable/AIJsonSerialize.java @@ -0,0 +1,48 @@ +package io.github.timemachinelab.core.serializable; + +import com.alibaba.fastjson.JSONObject; + +import io.github.timemachinelab.core.question.*; + +public class AIJsonSerialize implements Serialize { + @Override + public String serialize(BaseQuestion t) { + if (t == null) { + return null; + } + return JSONObject.toJSONString(t); + } + + @Override + public BaseQuestion deserialize(String str) { + JSONObject jsonObject = JSONObject.parseObject(str); + + String typeStr = jsonObject.getString("type"); + if (typeStr == null) { + return null; + } + + QuestionType type = QuestionType.valueOf(typeStr); + BaseQuestion baseQuestion = null; + + switch (type) { + case INPUT: + baseQuestion = jsonObject.toJavaObject(InputQuestion.class); + break; + case SINGLE: + baseQuestion = jsonObject.toJavaObject(SingleChoiceQuestion.class); + break; + case MULTI: + baseQuestion = jsonObject.toJavaObject(MultipleChoiceQuestion.class); + break; + case FORM: + baseQuestion = jsonObject.toJavaObject(FormQuestion.class); + break; + default: + throw new RuntimeException("Unknown question type: " + type); + } + return baseQuestion; + } + + +} diff --git a/prompto-lab-app/src/main/java/io/github/timemachinelab/core/serializable/QaTreeSerialize.java b/prompto-lab-app/src/main/java/io/github/timemachinelab/core/serializable/QaTreeSerialize.java new file mode 100644 index 0000000..33f7449 --- /dev/null +++ b/prompto-lab-app/src/main/java/io/github/timemachinelab/core/serializable/QaTreeSerialize.java @@ -0,0 +1,179 @@ +package io.github.timemachinelab.core.serializable; + +import io.github.timemachinelab.core.qatree.*; +import io.github.timemachinelab.core.question.*; +import io.github.timemachinelab.core.serializable.QaTreeSerialize.JsonNode.JsonNodeBuilder; +import io.netty.handler.codec.json.JsonObjectDecoder; +import lombok.Builder; +import lombok.Data; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.JsonObject; + +import dev.langchain4j.internal.Json; + +import com.alibaba.fastjson2.JSONObject; +import com.fasterxml.jackson.core.JsonProcessingException; + +import java.util.*; + +public class QaTreeSerialize implements Serialize { + + private final ObjectMapper objectMapper = new ObjectMapper(); + + @Override + public String serialize(QaTree t) throws JsonProcessingException { + if (t == null || t.getRoot() == null) { + return "[]"; + } + + List result = new ArrayList<>(); + + firstOrderTraversal(t.getRoot(), null, result); + + try { + return objectMapper.writeValueAsString(result); + } catch (JsonProcessingException e) { + throw new RuntimeException("序列化失败", e); + } + } + + private void firstOrderTraversal(QaTreeNode node, String parentId, List result) throws JsonProcessingException { + if (node == null) { + return; + } + + // 获取子节点列表 + List children = new ArrayList<>(); + + if (node.getChildren() != null) { + children.addAll(node.getChildren().values()); + } + + // 访问当前节点 + JsonNode jsonNode = JsonNode.Convert2JsonNode(node, parentId); + + result.add(jsonNode); + + // 先序遍历 + for (QaTreeNode child : children) { + firstOrderTraversal(child, node.getId(), result); + } + } + + @Override + public QaTree deserialize(String str) { + throw new UnsupportedOperationException("反序列化功能暂未实现"); + } + + /** + * 根据选项id查找对应的标签 + * @param options 选项列表 + * @param id 选项id + * @return 选项标签,如果未找到则返回null + */ + private static String findOptionLabel(List