From b50047a0529a941b3bf746890480982c5ff3ebd9 Mon Sep 17 00:00:00 2001 From: LuanY77 <2307984361@qq.com> Date: Tue, 29 Jul 2025 22:44:49 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20=E4=BF=AE=E5=A4=8D=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E8=A7=A3=E6=9E=90=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../prompt/resource/impl/TextPromptResource.java | 4 ++-- .../java/com/yomahub/liteflow/test/cmp/AICmp.java | 11 ++++++++++- .../src/test/resources/system_prompt.txt | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/system_prompt.txt diff --git a/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/parse/prompt/resource/impl/TextPromptResource.java b/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/parse/prompt/resource/impl/TextPromptResource.java index 0e49d7b77..dea4d241c 100644 --- a/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/parse/prompt/resource/impl/TextPromptResource.java +++ b/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/parse/prompt/resource/impl/TextPromptResource.java @@ -57,7 +57,7 @@ public class TextPromptResource extends AbstractPromptResource { return Optional .ofNullable(location) .filter(s -> s.startsWith(prefix)) - .map(s -> s.startsWith(prefix) ? s.substring(prefix.length()) : s) - .orElse(""); + .map(s -> s.substring(prefix.length())) + .orElse(location); } } diff --git a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/java/com/yomahub/liteflow/test/cmp/AICmp.java b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/java/com/yomahub/liteflow/test/cmp/AICmp.java index d40fc7274..396074ad3 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/java/com/yomahub/liteflow/test/cmp/AICmp.java +++ b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/java/com/yomahub/liteflow/test/cmp/AICmp.java @@ -2,6 +2,8 @@ package com.yomahub.liteflow.test.cmp; import com.yomahub.liteflow.ai.annotation.AIChat; import com.yomahub.liteflow.ai.annotation.AIComponent; +import com.yomahub.liteflow.ai.annotation.AIInput; +import com.yomahub.liteflow.ai.annotation.InputField; /** * TODO @@ -18,7 +20,14 @@ import com.yomahub.liteflow.ai.annotation.AIComponent; model = "qwen3:32b" ) @AIChat( - userPrompt = "Why sky is blue?" + systemPrompt = "classpath:system_prompt.txt", + userPrompt = "{{question}}, {{answer}}" +) +@AIInput( + mapping = { + @InputField(name = "question", expression = "test", defaultValue = "Why sky is blue?"), + @InputField(name = "answer", expression = "test", defaultValue = "The sky appears blue due to the scattering of sunlight by the atmosphere.") + } ) public interface AICmp { } diff --git a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/system_prompt.txt b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/system_prompt.txt new file mode 100644 index 000000000..0f21b0356 --- /dev/null +++ b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/system_prompt.txt @@ -0,0 +1 @@ +You are a chatbot that helps users with their questions about the LiteFlow framework. \ No newline at end of file