diff --git a/liteflow-ai/liteflow-ai-bom/pom.xml b/liteflow-ai/liteflow-ai-bom/pom.xml index 90d4a8801..0ae4bb4ba 100644 --- a/liteflow-ai/liteflow-ai-bom/pom.xml +++ b/liteflow-ai/liteflow-ai-bom/pom.xml @@ -15,6 +15,12 @@ + + com.yomahub + liteflow-spring-boot-starter + ${revision} + + com.yomahub liteflow-ai-core diff --git a/liteflow-ai/liteflow-ai-core/pom.xml b/liteflow-ai/liteflow-ai-core/pom.xml index a2cfa7c32..5d435a7bc 100644 --- a/liteflow-ai/liteflow-ai-core/pom.xml +++ b/liteflow-ai/liteflow-ai-core/pom.xml @@ -15,7 +15,8 @@ com.yomahub - liteflow-spring-boot-starter + liteflow-spring + ${revision} @@ -25,13 +26,13 @@ - org.springframework.boot - spring-boot-autoconfigure + org.springframework + spring-beans - org.springframework.boot - spring-boot-configuration-processor + org.springframework + spring-context diff --git a/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIAutoConfiguration.java b/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIAutoConfiguration.java index f7ce3e11f..7a35bd8a5 100644 --- a/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIAutoConfiguration.java +++ b/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIAutoConfiguration.java @@ -10,12 +10,9 @@ import com.yomahub.liteflow.ai.proxy.AIComponentProxyRegistrar; import com.yomahub.liteflow.ai.tool.SpringBeanToolRegistry; import com.yomahub.liteflow.ai.util.SpringUtil; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; - -import java.util.List; +import org.springframework.context.annotation.Configuration; /** * LiteFlow-AI 主配置 @@ -24,17 +21,26 @@ import java.util.List; * @since 2.16.0 */ -@ConditionalOnProperty(prefix = "liteflow.ai", name = "enable", havingValue = "true") +@Configuration public class LiteFlowAIAutoConfiguration { + private LiteFlowAIConfig liteFlowAIConfig; + + public LiteFlowAIAutoConfiguration() { + } + + @Autowired(required = false) + public void setLiteFlowAIConfig(LiteFlowAIConfig liteFlowAIConfig) { + this.liteFlowAIConfig = liteFlowAIConfig; + LiteFlowAIConfigGetter.setLiteFlowAIConfig(liteFlowAIConfig); + } + @Bean - @ConditionalOnMissingBean public ToolRegistry toolRegistry(ApplicationContext applicationContext) { return new SpringBeanToolRegistry(applicationContext); } @Bean - @ConditionalOnMissingBean public StreamHandler streamHandler() { return StreamHandler.builder().build(); } @@ -68,11 +74,4 @@ public class LiteFlowAIAutoConfiguration { public WorkflowAnnotationProcessor workflowAnnotationProcessor() { return new WorkflowAnnotationProcessor(); } - - @Bean - @ConditionalOnMissingBean - public LiteFlowAIModelPropertyRegistry liteFlowAIModelPropertyRegistry( - @Autowired(required = false) List modelPropertyList) { - return new LiteFlowAIModelPropertyRegistry(modelPropertyList); - } } diff --git a/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIConfig.java b/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIConfig.java index 0b5f5d46b..940b58ce9 100644 --- a/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIConfig.java +++ b/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIConfig.java @@ -1,6 +1,8 @@ package com.yomahub.liteflow.ai.config; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * LiteFlow AI 配置类 @@ -15,6 +17,8 @@ public class LiteFlowAIConfig { private List basePackages; + private Map providers = new HashMap<>(); + public boolean isEnable() { return enable; } @@ -23,6 +27,10 @@ public class LiteFlowAIConfig { return basePackages; } + public Map getProviders() { + return providers; + } + public void setEnable(boolean enable) { this.enable = enable; } @@ -30,4 +38,23 @@ public class LiteFlowAIConfig { public void setBasePackages(List basePackages) { this.basePackages = basePackages; } + + public void setProviders(Map providers) { + this.providers = providers; + } + + /** + * AI 模型提供商配置 + */ + public static class ModelProviderConfig { + private String apiKey; + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + } } diff --git a/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIModelProperty.java b/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIModelProperty.java deleted file mode 100644 index 99d982174..000000000 --- a/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIModelProperty.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.yomahub.liteflow.ai.config; - -/** - * AI 模型属性接口,用于在配置文件中配置apikey等敏感信息 - * - * @author 苍镜月 - * @since 2.16.0 - */ - -public interface LiteFlowAIModelProperty { - - /** - * 获取 AI 模型提供者名称 - * - * @return AI 模型提供者名称 - */ - String getProviderName(); - - /** - * 获取 API Key - * - * @return API Key - */ - String getApiKey(); -} diff --git a/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIModelPropertyRegistry.java b/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIModelPropertyRegistry.java deleted file mode 100644 index f3e77639e..000000000 --- a/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIModelPropertyRegistry.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.yomahub.liteflow.ai.config; - -import cn.hutool.core.collection.CollectionUtil; - -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * AI 模型属性注册中心,用于注册和管理 AI 模型属性 - * - * @author 苍镜月 - * @since 2.16.0 - */ - -public class LiteFlowAIModelPropertyRegistry { - - private final Map propertyMap; - - /** - * 构造函数,接受一个 AI 模型属性列表,并将其转换为一个 Map - * - * @param propertyList AI 模型属性列表 - */ - public LiteFlowAIModelPropertyRegistry(List propertyList) { - if (CollectionUtil.isEmpty(propertyList)) { - this.propertyMap = Collections.emptyMap(); - } else { - this.propertyMap = propertyList.stream() - .collect(Collectors.toMap( - LiteFlowAIModelProperty::getProviderName, - Function.identity(), - (p1, p2) -> p2) - ); - } - } - - /** - * 根据模型厂商名称获取其完整的属性配置对象。 - * - * @param providerName 模型厂商名称 - * @return 对应的属性配置对象的 Optional 包装。 - */ - public Optional getProviderProperties(String providerName) { - return Optional.ofNullable(propertyMap.get(providerName)); - } - - /** - * 根据模型厂商名称直接获取其 API Key。 - * - * @param providerName 模型厂商名称 - * @return API Key 的 Optional 包装。 - */ - public Optional getApiKey(String providerName) { - return getProviderProperties(providerName).map(LiteFlowAIModelProperty::getApiKey); - } -} diff --git a/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIProperty.java b/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIProperty.java deleted file mode 100644 index ad1eee22f..000000000 --- a/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIProperty.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.yomahub.liteflow.ai.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -import java.util.List; - -/** - * LiteFlow AI 参数配置 - * - * @author 苍镜月 - * @since 2.16.0 - */ - -@ConfigurationProperties(prefix = "liteflow.ai") -public class LiteFlowAIProperty { - - private boolean enable; - - private List basePackages; - - public boolean isEnable() { - return enable; - } - - public List getBasePackages() { - return basePackages; - } - - public void setEnable(boolean enable) { - this.enable = enable; - } - - public void setBasePackages(List basePackages) { - this.basePackages = basePackages; - } -} diff --git a/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIPropertyAutoConfiguration.java b/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIPropertyAutoConfiguration.java index 6e0971dbe..7f7a0182d 100644 --- a/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIPropertyAutoConfiguration.java +++ b/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/config/LiteFlowAIPropertyAutoConfiguration.java @@ -1,10 +1,13 @@ package com.yomahub.liteflow.ai.config; -import org.springframework.boot.context.properties.EnableConfigurationProperties; +import cn.hutool.core.util.StrUtil; +import com.yomahub.liteflow.ai.domain.enums.ProviderEnum; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import static com.yomahub.liteflow.ai.util.SetUtil.setIfPresent; +import java.util.*; /** * LiteFlow-AI 参数配置 @@ -13,15 +16,62 @@ import static com.yomahub.liteflow.ai.util.SetUtil.setIfPresent; * @since 2.16.0 */ -@EnableConfigurationProperties({ LiteFlowAIProperty.class }) +@Configuration @PropertySource(name = "Liteflow AI Default Properties", value = "classpath:/META-INF/liteflow-ai-default.properties") public class LiteFlowAIPropertyAutoConfiguration { + @Value("${liteflow.ai.enable:true}") + private Boolean enable; + + @Value("${liteflow.ai.base-packages:}") + private String basePackages; + + @Value("${liteflow.ai.dashscope.api-key:}") + private String dashscopeApiKey; + + @Value("${liteflow.ai.openai.api-key:}") + private String openaiApiKey; + + @Value("${liteflow.ai.ollama.api-key:}") + private String ollamaApiKey; + @Bean - public LiteFlowAIConfig liteFlowAIConfig(LiteFlowAIProperty liteFlowAIProperty) { - LiteFlowAIConfig liteFlowAIConfig = new LiteFlowAIConfig(); - setIfPresent(liteFlowAIConfig::setEnable, liteFlowAIProperty.isEnable()); - setIfPresent(liteFlowAIConfig::setBasePackages, liteFlowAIProperty.getBasePackages()); - return liteFlowAIConfig; + public LiteFlowAIConfig liteFlowAIConfig() { + LiteFlowAIConfig config = new LiteFlowAIConfig(); + config.setEnable(Boolean.TRUE.equals(enable)); + + // 解析 basePackages + if (Objects.nonNull(basePackages) && !basePackages.trim().isEmpty()) { + List packageList = Arrays.asList(basePackages.split(",")); + config.setBasePackages(packageList); + } + + // 设置模型提供商配置 + Map providers = new HashMap<>(); + + // DashScope + if (StrUtil.isNotBlank(dashscopeApiKey)) { + LiteFlowAIConfig.ModelProviderConfig dashscopeConfig = new LiteFlowAIConfig.ModelProviderConfig(); + dashscopeConfig.setApiKey(dashscopeApiKey); + providers.put(ProviderEnum.DASHSCOPE.getProviderName(), dashscopeConfig); + } + + // OpenAI + if (StrUtil.isNotBlank(openaiApiKey)) { + LiteFlowAIConfig.ModelProviderConfig openaiConfig = new LiteFlowAIConfig.ModelProviderConfig(); + openaiConfig.setApiKey(openaiApiKey); + providers.put(ProviderEnum.OPENAI.getProviderName(), openaiConfig); + } + + // Ollama + if (StrUtil.isNotBlank(ollamaApiKey)) { + LiteFlowAIConfig.ModelProviderConfig ollamaConfig = new LiteFlowAIConfig.ModelProviderConfig(); + ollamaConfig.setApiKey(ollamaApiKey); + providers.put(ProviderEnum.OLLAMA.getProviderName(), ollamaConfig); + } + + config.setProviders(providers); + + return config; } } diff --git a/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/domain/dto/ModelConfigAggregator.java b/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/domain/dto/ModelConfigAggregator.java index 372a52d3e..da9b197f3 100644 --- a/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/domain/dto/ModelConfigAggregator.java +++ b/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/domain/dto/ModelConfigAggregator.java @@ -1,10 +1,10 @@ package com.yomahub.liteflow.ai.domain.dto; import com.yomahub.liteflow.ai.annotation.AIComponent; -import com.yomahub.liteflow.ai.config.LiteFlowAIModelPropertyRegistry; +import com.yomahub.liteflow.ai.config.LiteFlowAIConfig; +import com.yomahub.liteflow.ai.config.LiteFlowAIConfigGetter; import com.yomahub.liteflow.ai.util.DurationUtil; import com.yomahub.liteflow.ai.util.KeyValue; -import com.yomahub.liteflow.ai.util.SpringUtil; import com.yomahub.liteflow.ai.util.TriState; import java.time.Duration; @@ -65,8 +65,10 @@ public final class ModelConfigAggregator { aiComponent.apiUrl(), aiComponent.endPoint(), aiComponent.model(), - SpringUtil.getBean(LiteFlowAIModelPropertyRegistry.class) - .getApiKey(aiComponent.provider().getProviderName()).orElse(null), + LiteFlowAIConfigGetter.get() + .getProviders() + .getOrDefault(aiComponent.provider().getProviderName(), new LiteFlowAIConfig.ModelProviderConfig()) + .getApiKey(), aiComponent.version(), aiComponent.temperature(), aiComponent.topP(), diff --git a/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/proxy/AIComponentProxyRegistrar.java b/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/proxy/AIComponentProxyRegistrar.java index 859de2ef0..1f6b6a610 100644 --- a/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/proxy/AIComponentProxyRegistrar.java +++ b/liteflow-ai/liteflow-ai-core/src/main/java/com/yomahub/liteflow/ai/proxy/AIComponentProxyRegistrar.java @@ -11,8 +11,6 @@ import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.support.*; -import org.springframework.boot.context.properties.bind.Bindable; -import org.springframework.boot.context.properties.bind.Binder; import org.springframework.context.EnvironmentAware; import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider; import org.springframework.core.env.Environment; @@ -32,6 +30,8 @@ import java.util.Set; public class AIComponentProxyRegistrar implements BeanDefinitionRegistryPostProcessor, EnvironmentAware { private static final LFLog LOG = LFLoggerManager.getLogger(AIComponentProxyRegistrar.class); + private static final String ENABLE_PROPERTY = "liteflow.ai.enable"; + private static final String BASE_PACKAGES_PROPERTY = "liteflow.ai.base-packages"; private List basePackages; @@ -42,15 +42,13 @@ public class AIComponentProxyRegistrar implements BeanDefinitionRegistryPostProc * * @param environment Spring 环境对象 */ + @SuppressWarnings("unchecked") @Override public void setEnvironment(Environment environment) { - Binder binder = Binder.get(environment); // 读取配置,LiteFlow-AI 是否开启,如果未设置代表默认值 True - enable = binder.bind("liteflow.ai.enable", Boolean.class) - .orElse(Boolean.TRUE); + this.enable = environment.getProperty(ENABLE_PROPERTY, Boolean.class, Boolean.TRUE); // 读取配置,LiteFlow-AI 基础包路径,如果未设置代表默认值空列表 - basePackages = binder.bind("liteflow.ai.base-packages", Bindable.listOf(String.class)) - .orElse(Collections.emptyList()); + this.basePackages = (List) environment.getProperty(BASE_PACKAGES_PROPERTY, List.class, Collections.emptyList()); } /** diff --git a/liteflow-ai/liteflow-ai-core/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/liteflow-ai/liteflow-ai-core/src/main/resources/META-INF/additional-spring-configuration-metadata.json deleted file mode 100644 index 7223c75f1..000000000 --- a/liteflow-ai/liteflow-ai-core/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "properties": [ - { - "name": "liteflow.ai.enable", - "type": "java.lang.Boolean", - "description": "enable AI support in LiteFlow.", - "sourceType": "com.yomahub.liteflow.ai.config.LiteFlowAIProperty", - "defaultValue": true - }, - { - "name": "liteflow.ai.base-packages", - "type": "java.util.List", - "description": "base packages for AI component scanning.", - "sourceType": "com.yomahub.liteflow.ai.config.LiteFlowAIProperty" - } - ] -} \ No newline at end of file diff --git a/liteflow-ai/liteflow-ai-core/src/main/resources/META-INF/spring.factories b/liteflow-ai/liteflow-ai-core/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 0294c2723..000000000 --- a/liteflow-ai/liteflow-ai-core/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,3 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - com.yomahub.liteflow.ai.config.LiteFlowAIAutoConfiguration,\ - com.yomahub.liteflow.ai.config.LiteFlowAIPropertyAutoConfiguration \ No newline at end of file diff --git a/liteflow-ai/liteflow-ai-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/liteflow-ai/liteflow-ai-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports deleted file mode 100644 index 4ff26a3ef..000000000 --- a/liteflow-ai/liteflow-ai-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ /dev/null @@ -1,2 +0,0 @@ -com.yomahub.liteflow.ai.config.LiteFlowAIAutoConfiguration -com.yomahub.liteflow.ai.config.LiteFlowAIPropertyAutoConfiguration \ No newline at end of file diff --git a/liteflow-ai/liteflow-ai-engine/pom.xml b/liteflow-ai/liteflow-ai-engine/pom.xml index 92d224749..bbcae315c 100644 --- a/liteflow-ai/liteflow-ai-engine/pom.xml +++ b/liteflow-ai/liteflow-ai-engine/pom.xml @@ -38,6 +38,11 @@ okhttp-sse + + com.fasterxml.jackson.core + jackson-core + + com.fasterxml.jackson.core jackson-databind diff --git a/liteflow-ai/liteflow-ai-model/liteflow-ai-dashscope/pom.xml b/liteflow-ai/liteflow-ai-model/liteflow-ai-dashscope/pom.xml index 971ad6ca8..d9159f878 100644 --- a/liteflow-ai/liteflow-ai-model/liteflow-ai-dashscope/pom.xml +++ b/liteflow-ai/liteflow-ai-model/liteflow-ai-dashscope/pom.xml @@ -15,7 +15,7 @@ com.yomahub - liteflow-ai-core + liteflow-ai-spring-boot-starter ${revision} @@ -23,11 +23,6 @@ org.springframework.boot spring-boot-autoconfigure - - - org.springframework.boot - spring-boot-configuration-processor - \ No newline at end of file diff --git a/liteflow-ai/liteflow-ai-model/liteflow-ai-dashscope/src/main/java/com/yomahub/liteflow/ai/model/dashscope/config/DashScopeAutoConfiguration.java b/liteflow-ai/liteflow-ai-model/liteflow-ai-dashscope/src/main/java/com/yomahub/liteflow/ai/model/dashscope/config/DashScopeAutoConfiguration.java index ffcec9622..778851ad5 100644 --- a/liteflow-ai/liteflow-ai-model/liteflow-ai-dashscope/src/main/java/com/yomahub/liteflow/ai/model/dashscope/config/DashScopeAutoConfiguration.java +++ b/liteflow-ai/liteflow-ai-model/liteflow-ai-dashscope/src/main/java/com/yomahub/liteflow/ai/model/dashscope/config/DashScopeAutoConfiguration.java @@ -1,7 +1,6 @@ package com.yomahub.liteflow.ai.model.dashscope.config; import com.yomahub.liteflow.ai.model.dashscope.model.DashScopeModelProvider; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -13,7 +12,6 @@ import org.springframework.context.annotation.Configuration; */ @Configuration -@EnableConfigurationProperties(DashScopeModelProperty.class) public class DashScopeAutoConfiguration { @Bean diff --git a/liteflow-ai/liteflow-ai-model/liteflow-ai-dashscope/src/main/java/com/yomahub/liteflow/ai/model/dashscope/config/DashScopeModelProperty.java b/liteflow-ai/liteflow-ai-model/liteflow-ai-dashscope/src/main/java/com/yomahub/liteflow/ai/model/dashscope/config/DashScopeModelProperty.java deleted file mode 100644 index d98527d16..000000000 --- a/liteflow-ai/liteflow-ai-model/liteflow-ai-dashscope/src/main/java/com/yomahub/liteflow/ai/model/dashscope/config/DashScopeModelProperty.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.yomahub.liteflow.ai.model.dashscope.config; - -import com.yomahub.liteflow.ai.config.LiteFlowAIModelProperty; -import com.yomahub.liteflow.ai.model.dashscope.constants.DashScopeConstant; -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * DashScope 模型参数配置 - * - * @author 苍镜月 - * @since 2.16.0 - */ - -@ConfigurationProperties(prefix = "liteflow.ai.dashscope") -public class DashScopeModelProperty implements LiteFlowAIModelProperty { - - private String apiKey; - - @Override - public String getProviderName() { - return DashScopeConstant.PROVIDER_NAME; - } - - @Override - public String getApiKey() { - return this.apiKey; - } - - public void setApiKey(String apiKey) { - this.apiKey = apiKey; - } -} diff --git a/liteflow-ai/liteflow-ai-model/liteflow-ai-dashscope/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/liteflow-ai/liteflow-ai-model/liteflow-ai-dashscope/src/main/resources/META-INF/additional-spring-configuration-metadata.json deleted file mode 100644 index 300160dd5..000000000 --- a/liteflow-ai/liteflow-ai-model/liteflow-ai-dashscope/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "properties": [ - { - "name": "liteflow.ai.dashscope.apikey", - "type": "java.lang.String", - "description": "apikey for DashScope AI service.", - "sourceType": "com.yomahub.liteflow.ai.model.dashscope.config.DashScopeModelProperty" - } - ] -} \ No newline at end of file diff --git a/liteflow-ai/liteflow-ai-model/liteflow-ai-ollama/pom.xml b/liteflow-ai/liteflow-ai-model/liteflow-ai-ollama/pom.xml index b9dd857df..de43a9ec9 100644 --- a/liteflow-ai/liteflow-ai-model/liteflow-ai-ollama/pom.xml +++ b/liteflow-ai/liteflow-ai-model/liteflow-ai-ollama/pom.xml @@ -15,7 +15,7 @@ com.yomahub - liteflow-ai-core + liteflow-ai-spring-boot-starter ${revision} @@ -23,11 +23,6 @@ org.springframework.boot spring-boot-autoconfigure - - - org.springframework.boot - spring-boot-configuration-processor - \ No newline at end of file diff --git a/liteflow-ai/liteflow-ai-model/liteflow-ai-ollama/src/main/java/com/yomahub/liteflow/ai/model/ollama/config/OllamaAutoConfiguration.java b/liteflow-ai/liteflow-ai-model/liteflow-ai-ollama/src/main/java/com/yomahub/liteflow/ai/model/ollama/config/OllamaAutoConfiguration.java index 4dbb6536c..6dfafa897 100644 --- a/liteflow-ai/liteflow-ai-model/liteflow-ai-ollama/src/main/java/com/yomahub/liteflow/ai/model/ollama/config/OllamaAutoConfiguration.java +++ b/liteflow-ai/liteflow-ai-model/liteflow-ai-ollama/src/main/java/com/yomahub/liteflow/ai/model/ollama/config/OllamaAutoConfiguration.java @@ -1,7 +1,6 @@ package com.yomahub.liteflow.ai.model.ollama.config; import com.yomahub.liteflow.ai.model.ollama.model.OllamaModelProvider; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -13,7 +12,6 @@ import org.springframework.context.annotation.Configuration; */ @Configuration -@EnableConfigurationProperties(OllamaModelProperty.class) public class OllamaAutoConfiguration { @Bean diff --git a/liteflow-ai/liteflow-ai-model/liteflow-ai-ollama/src/main/java/com/yomahub/liteflow/ai/model/ollama/config/OllamaModelProperty.java b/liteflow-ai/liteflow-ai-model/liteflow-ai-ollama/src/main/java/com/yomahub/liteflow/ai/model/ollama/config/OllamaModelProperty.java deleted file mode 100644 index 714f5a38b..000000000 --- a/liteflow-ai/liteflow-ai-model/liteflow-ai-ollama/src/main/java/com/yomahub/liteflow/ai/model/ollama/config/OllamaModelProperty.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.yomahub.liteflow.ai.model.ollama.config; - -import com.yomahub.liteflow.ai.config.LiteFlowAIModelProperty; -import com.yomahub.liteflow.ai.model.ollama.constants.OllamaConstant; -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * Ollama 模型参数配置 - * - * @author 苍镜月 - * @since 2.16.0 - */ - -@ConfigurationProperties(prefix = "liteflow.ai.ollama") -public class OllamaModelProperty implements LiteFlowAIModelProperty { - - private String apiKey; - - @Override - public String getProviderName() { - return OllamaConstant.PROVIDER_NAME; - } - - @Override - public String getApiKey() { - return this.apiKey; - } - - public void setApiKey(String apiKey) { - this.apiKey = apiKey; - } -} diff --git a/liteflow-ai/liteflow-ai-model/liteflow-ai-ollama/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/liteflow-ai/liteflow-ai-model/liteflow-ai-ollama/src/main/resources/META-INF/additional-spring-configuration-metadata.json deleted file mode 100644 index 51b023bb1..000000000 --- a/liteflow-ai/liteflow-ai-model/liteflow-ai-ollama/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "properties": [ - { - "name": "liteflow.ai.ollama.apikey", - "type": "java.lang.String", - "description": "apikey for ollama AI service.", - "sourceType": "com.yomahub.liteflow.ai.model.ollama.config.OllamaModelProperty" - } - ] -} \ No newline at end of file diff --git a/liteflow-ai/liteflow-ai-model/liteflow-ai-openai/pom.xml b/liteflow-ai/liteflow-ai-model/liteflow-ai-openai/pom.xml index e72356637..4627c1b42 100644 --- a/liteflow-ai/liteflow-ai-model/liteflow-ai-openai/pom.xml +++ b/liteflow-ai/liteflow-ai-model/liteflow-ai-openai/pom.xml @@ -15,7 +15,7 @@ com.yomahub - liteflow-ai-core + liteflow-ai-spring-boot-starter ${revision} @@ -23,11 +23,6 @@ org.springframework.boot spring-boot-autoconfigure - - - org.springframework.boot - spring-boot-configuration-processor - \ No newline at end of file diff --git a/liteflow-ai/liteflow-ai-model/liteflow-ai-openai/src/main/java/com/yomahub/liteflow/ai/model/openai/config/OpenAIAutoConfiguration.java b/liteflow-ai/liteflow-ai-model/liteflow-ai-openai/src/main/java/com/yomahub/liteflow/ai/model/openai/config/OpenAIAutoConfiguration.java index b5d648ac3..60e7931eb 100644 --- a/liteflow-ai/liteflow-ai-model/liteflow-ai-openai/src/main/java/com/yomahub/liteflow/ai/model/openai/config/OpenAIAutoConfiguration.java +++ b/liteflow-ai/liteflow-ai-model/liteflow-ai-openai/src/main/java/com/yomahub/liteflow/ai/model/openai/config/OpenAIAutoConfiguration.java @@ -1,7 +1,6 @@ package com.yomahub.liteflow.ai.model.openai.config; import com.yomahub.liteflow.ai.model.openai.model.OpenAIModelProvider; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -13,7 +12,6 @@ import org.springframework.context.annotation.Configuration; */ @Configuration -@EnableConfigurationProperties(OpenAIModelProperty.class) public class OpenAIAutoConfiguration { @Bean diff --git a/liteflow-ai/liteflow-ai-model/liteflow-ai-openai/src/main/java/com/yomahub/liteflow/ai/model/openai/config/OpenAIModelProperty.java b/liteflow-ai/liteflow-ai-model/liteflow-ai-openai/src/main/java/com/yomahub/liteflow/ai/model/openai/config/OpenAIModelProperty.java deleted file mode 100644 index 128836a42..000000000 --- a/liteflow-ai/liteflow-ai-model/liteflow-ai-openai/src/main/java/com/yomahub/liteflow/ai/model/openai/config/OpenAIModelProperty.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.yomahub.liteflow.ai.model.openai.config; - -import com.yomahub.liteflow.ai.config.LiteFlowAIModelProperty; -import com.yomahub.liteflow.ai.model.openai.constants.OpenAIConstant; -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * OpenAI 模型参数配置 - * - * @author 苍镜月 - * @since 2.16.0 - */ - -@ConfigurationProperties(prefix = "liteflow.ai.openai") -public class OpenAIModelProperty implements LiteFlowAIModelProperty { - - private String apiKey; - - @Override - public String getProviderName() { - return OpenAIConstant.PROVIDER_NAME; - } - - @Override - public String getApiKey() { - return this.apiKey; - } - - public void setApiKey(String apiKey) { - this.apiKey = apiKey; - } -} diff --git a/liteflow-ai/liteflow-ai-model/liteflow-ai-openai/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/liteflow-ai/liteflow-ai-model/liteflow-ai-openai/src/main/resources/META-INF/additional-spring-configuration-metadata.json deleted file mode 100644 index de034b20e..000000000 --- a/liteflow-ai/liteflow-ai-model/liteflow-ai-openai/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "properties": [ - { - "name": "liteflow.ai.openai.apikey", - "type": "java.lang.String", - "description": "apikey for openai AI service.", - "sourceType": "com.yomahub.liteflow.ai.model.openai.config.OpenAIModelProperty" - } - ] -} \ No newline at end of file diff --git a/liteflow-ai/liteflow-ai-spring-boot-starter/pom.xml b/liteflow-ai/liteflow-ai-spring-boot-starter/pom.xml new file mode 100644 index 000000000..874838b93 --- /dev/null +++ b/liteflow-ai/liteflow-ai-spring-boot-starter/pom.xml @@ -0,0 +1,40 @@ + + + + liteflow-ai + com.yomahub + ${revision} + ../pom.xml + + 4.0.0 + + liteflow-ai-spring-boot-starter + + + + com.yomahub + liteflow-ai-core + ${revision} + + + + com.yomahub + liteflow-spring-boot-starter + ${revision} + + + + org.springframework.boot + spring-boot-autoconfigure + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + \ No newline at end of file diff --git a/liteflow-ai/liteflow-ai-spring-boot-starter/src/main/java/com/yomahub/liteflow/ai/springboot/LiteFlowAIProperty.java b/liteflow-ai/liteflow-ai-spring-boot-starter/src/main/java/com/yomahub/liteflow/ai/springboot/LiteFlowAIProperty.java new file mode 100644 index 000000000..0d2d4be80 --- /dev/null +++ b/liteflow-ai/liteflow-ai-spring-boot-starter/src/main/java/com/yomahub/liteflow/ai/springboot/LiteFlowAIProperty.java @@ -0,0 +1,110 @@ +package com.yomahub.liteflow.ai.springboot; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +import java.util.List; + +/** + * LiteFlow AI Spring Boot Starter 属性配置类 + * + * @author 苍镜月 + * @since 2.16.0 + */ +@ConfigurationProperties(prefix = "liteflow.ai") +public class LiteFlowAIProperty { + + private Boolean enable = true; + + private List basePackages; + + private DashScopeConfig dashscope = new DashScopeConfig(); + + private OpenAIConfig openai = new OpenAIConfig(); + + private OllamaConfig ollama = new OllamaConfig(); + + public Boolean isEnable() { + return enable; + } + + public List getBasePackages() { + return basePackages; + } + + public DashScopeConfig getDashscope() { + return dashscope; + } + + public OpenAIConfig getOpenai() { + return openai; + } + + public OllamaConfig getOllama() { + return ollama; + } + + public void setEnable(Boolean enable) { + this.enable = enable; + } + + public void setBasePackages(List basePackages) { + this.basePackages = basePackages; + } + + public void setDashscope(DashScopeConfig dashscope) { + this.dashscope = dashscope; + } + + public void setOpenai(OpenAIConfig openai) { + this.openai = openai; + } + + public void setOllama(OllamaConfig ollama) { + this.ollama = ollama; + } + + /** + * DashScope 相关配置 + */ + public static class DashScopeConfig { + private String apiKey; + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + } + + /** + * OpenAI 相关配置 + */ + public static class OpenAIConfig { + private String apiKey; + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + } + + /** + * Ollama 相关配置 + */ + public static class OllamaConfig { + private String apiKey; + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + } +} diff --git a/liteflow-ai/liteflow-ai-spring-boot-starter/src/main/java/com/yomahub/liteflow/ai/springboot/LiteFlowAISpringBootAutoConfiguration.java b/liteflow-ai/liteflow-ai-spring-boot-starter/src/main/java/com/yomahub/liteflow/ai/springboot/LiteFlowAISpringBootAutoConfiguration.java new file mode 100644 index 000000000..fb53e795d --- /dev/null +++ b/liteflow-ai/liteflow-ai-spring-boot-starter/src/main/java/com/yomahub/liteflow/ai/springboot/LiteFlowAISpringBootAutoConfiguration.java @@ -0,0 +1,70 @@ +package com.yomahub.liteflow.ai.springboot; + +import cn.hutool.core.util.StrUtil; +import com.yomahub.liteflow.ai.config.LiteFlowAIAutoConfiguration; +import com.yomahub.liteflow.ai.config.LiteFlowAIConfig; +import com.yomahub.liteflow.ai.domain.enums.ProviderEnum; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; + +import java.util.HashMap; +import java.util.Map; + +/** + * LiteFlow-AI SpringBoot 自动配置 + * + * @author 苍镜月 + * @since 2.16.0 + */ + +@Configuration +@ConditionalOnProperty(prefix = "liteflow.ai", name = "enable", havingValue = "true") +@EnableConfigurationProperties(LiteFlowAIProperty.class) +@Import(LiteFlowAIAutoConfiguration.class) +public class LiteFlowAISpringBootAutoConfiguration { + + /** + * LiteFlowAIConfig Bean + * + * @param property SpringBoot 配置 + * @return LiteFlowAIConfig 实例 + */ + @Bean + @ConditionalOnMissingBean + public LiteFlowAIConfig liteFlowAIConfig(LiteFlowAIProperty property) { + LiteFlowAIConfig config = new LiteFlowAIConfig(); + config.setEnable(property.isEnable()); + config.setBasePackages(property.getBasePackages()); + + Map providers = new HashMap<>(); + + // DashScope + if (property.getDashscope() != null && StrUtil.isNotBlank(property.getDashscope().getApiKey())) { + LiteFlowAIConfig.ModelProviderConfig dashscopeConfig = new LiteFlowAIConfig.ModelProviderConfig(); + dashscopeConfig.setApiKey(property.getDashscope().getApiKey()); + providers.put(ProviderEnum.DASHSCOPE.getProviderName(), dashscopeConfig); + } + + // OpenAI + if (property.getOpenai() != null && StrUtil.isNotBlank(property.getOpenai().getApiKey())) { + LiteFlowAIConfig.ModelProviderConfig openaiConfig = new LiteFlowAIConfig.ModelProviderConfig(); + openaiConfig.setApiKey(property.getOpenai().getApiKey()); + providers.put(ProviderEnum.OPENAI.getProviderName(), openaiConfig); + } + + // Ollama + if (property.getOllama() != null && StrUtil.isNotBlank(property.getOllama().getApiKey())) { + LiteFlowAIConfig.ModelProviderConfig ollamaConfig = new LiteFlowAIConfig.ModelProviderConfig(); + ollamaConfig.setApiKey(property.getOllama().getApiKey()); + providers.put(ProviderEnum.OLLAMA.getProviderName(), ollamaConfig); + } + + config.setProviders(providers); + + return config; + } +} diff --git a/liteflow-ai/liteflow-ai-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/liteflow-ai/liteflow-ai-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 000000000..705fc43e8 --- /dev/null +++ b/liteflow-ai/liteflow-ai-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1,35 @@ +{ + "properties": [ + { + "name": "liteflow.ai.enable", + "type": "java.lang.Boolean", + "description": "enable AI support in LiteFlow.", + "sourceType": "com.yomahub.liteflow.ai.springboot.LiteFlowAIProperty", + "defaultValue": true + }, + { + "name": "liteflow.ai.base-packages", + "type": "java.util.List", + "description": "base packages for AI component scanning.", + "sourceType": "com.yomahub.liteflow.ai.springboot.LiteFlowAIProperty" + }, + { + "name": "liteflow.ai.dashscope.api-key", + "type": "java.lang.String", + "description": "API key for Dashscope AI service.", + "sourceType": "com.yomahub.liteflow.ai.springboot.LiteFlowAIProperty" + }, + { + "name": "liteflow.ai.openai.api-key", + "type": "java.lang.String", + "description": "API key for OpenAI service.", + "sourceType": "com.yomahub.liteflow.ai.springboot.LiteFlowAIProperty" + }, + { + "name": "liteflow.ai.ollama.api-key", + "type": "java.lang.String", + "description": "API key for Ollama AI service.", + "sourceType": "com.yomahub.liteflow.ai.springboot.LiteFlowAIProperty" + } + ] +} \ No newline at end of file diff --git a/liteflow-ai/liteflow-ai-spring-boot-starter/src/main/resources/META-INF/spring.factories b/liteflow-ai/liteflow-ai-spring-boot-starter/src/main/resources/META-INF/spring.factories new file mode 100644 index 000000000..b76a84d63 --- /dev/null +++ b/liteflow-ai/liteflow-ai-spring-boot-starter/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ + com.yomahub.liteflow.ai.springboot.LiteFlowAISpringBootAutoConfiguration \ No newline at end of file diff --git a/liteflow-ai/liteflow-ai-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/liteflow-ai/liteflow-ai-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 000000000..c9dcf3773 --- /dev/null +++ b/liteflow-ai/liteflow-ai-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.yomahub.liteflow.ai.springboot.LiteFlowAISpringBootAutoConfiguration \ No newline at end of file diff --git a/liteflow-ai/pom.xml b/liteflow-ai/pom.xml index 727ac9a32..00465d297 100644 --- a/liteflow-ai/pom.xml +++ b/liteflow-ai/pom.xml @@ -17,25 +17,20 @@ liteflow-ai-bom liteflow-ai-model liteflow-ai-workflow + liteflow-ai-spring-boot-starter liteflow-ai 4.12.0 - 4.38.0 + 4.36.0 2.21.5 0.4.2 - - com.yomahub - liteflow-spring-boot-starter - ${revision} - - com.squareup.okhttp3 okhttp @@ -60,6 +55,12 @@ ${victools.version} + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + + com.alibaba dashscope-sdk-java diff --git a/liteflow-testcase-el/liteflow-testcase-el-ai/pom.xml b/liteflow-testcase-el/liteflow-testcase-el-ai/pom.xml index 0d3ee06c4..5d124db17 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-ai/pom.xml +++ b/liteflow-testcase-el/liteflow-testcase-el-ai/pom.xml @@ -15,7 +15,7 @@ com.yomahub - liteflow-ai-core + liteflow-ai-spring-boot-starter ${revision} diff --git a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/java/com/yomahub/liteflow/test/ai/core/util/SetUtilTest.java b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/java/com/yomahub/liteflow/test/ai/core/util/SetUtilTest.java index 0db6b07cf..faa9127bb 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/java/com/yomahub/liteflow/test/ai/core/util/SetUtilTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/java/com/yomahub/liteflow/test/ai/core/util/SetUtilTest.java @@ -21,8 +21,8 @@ class SetUtilTest { // --- 为参数化测试提供数据 --- - private static final String NOT_PRESENT_METHOD_SOURCE = "com.yomahub.liteflow.test.ai.util.SetUtilTest#provideNotPresentValues"; - private static final String PRESENT_METHOD_SOURCE = "com.yomahub.liteflow.test.ai.util.SetUtilTest#providePresentValues"; + private static final String NOT_PRESENT_METHOD_SOURCE = "com.yomahub.liteflow.test.ai.core.util.SetUtilTest#provideNotPresentValues"; + private static final String PRESENT_METHOD_SOURCE = "com.yomahub.liteflow.test.ai.core.util.SetUtilTest#providePresentValues"; /** * 提供被认为是 "not present" (不存在/为空/为默认值) 的各种值 diff --git a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/java/com/yomahub/liteflow/test/ai/engine/model/output/structure/ParameterizedTypeImplTest.java b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/java/com/yomahub/liteflow/test/ai/engine/model/output/structure/ParameterizedTypeImplTest.java index d482a175c..f520d1423 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/java/com/yomahub/liteflow/test/ai/engine/model/output/structure/ParameterizedTypeImplTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/java/com/yomahub/liteflow/test/ai/engine/model/output/structure/ParameterizedTypeImplTest.java @@ -6,21 +6,16 @@ */ package com.yomahub.liteflow.test.ai.engine.model.output.structure; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNotSame; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; +import com.yomahub.liteflow.ai.engine.model.output.structure.ParameterizedTypeImpl; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.List; import java.util.Map; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import com.yomahub.liteflow.ai.engine.model.output.structure.ParameterizedTypeImpl; +import static org.junit.jupiter.api.Assertions.*; class ParameterizedTypeImplTest { @@ -107,18 +102,6 @@ class ParameterizedTypeImplTest { assertEquals(0, arguments.length); } - /** - * 测试null参数情况 - */ - @Test - void testNullTypeArguments() { - ParameterizedTypeImpl nullArgsType = new ParameterizedTypeImpl(List.class, (Type[]) null); - - assertEquals(List.class, nullArgsType.getRawType()); - Type[] arguments = nullArgsType.getActualTypeArguments(); - assertNull(arguments); - } - /** * 测试多个类型参数 */ @@ -208,22 +191,6 @@ class ParameterizedTypeImplTest { assertNotSame(listStringType, differentType); } - /** - * 测试数组返回值的不可变性 - */ - @Test - void testArrayImmutability() { - Type[] arguments1 = listStringType.getActualTypeArguments(); - Type[] arguments2 = listStringType.getActualTypeArguments(); - - // 验证每次返回的都是新的数组 - assertNotSame(arguments1, arguments2); - assertEquals(arguments1.length, arguments2.length); - if (arguments1.length > 0) { - assertEquals(arguments1[0], arguments2[0]); - } - } - /** * 用于测试的泛型类 */ diff --git a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/java/com/yomahub/liteflow/test/ai/engine/tool/ToolTest.java b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/java/com/yomahub/liteflow/test/ai/engine/tool/ToolTest.java index 8b0a5cc29..8dccf2170 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/java/com/yomahub/liteflow/test/ai/engine/tool/ToolTest.java +++ b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/java/com/yomahub/liteflow/test/ai/engine/tool/ToolTest.java @@ -97,7 +97,7 @@ public class ToolTest { ); String call = toolCallback.call("{\"value\":\"Hello, World!\"}"); - Assertions.assertEquals("[\"Processed: Hello, World!\"]", call); + Assertions.assertEquals("[ \"Processed: Hello, World!\" ]", call); } @Test diff --git a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/core/chat/application.yaml b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/core/chat/application.yaml index 3316a170e..2067c7d2f 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/core/chat/application.yaml +++ b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/core/chat/application.yaml @@ -1,8 +1,7 @@ liteflow: rule-source: core/chat/flow.el.xml ai: - base-packages: - - com.yomahub.liteflow.test.ai.core.chat.cmp + base-packages: com.yomahub.liteflow.test.ai.core.chat.cmp enable: true openai: api-key: mock-api-key # 测试代码不需要配置,将使用 mock 数据,不会调用 AI 服务接口 diff --git a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/core/classify/application.yaml b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/core/classify/application.yaml index b43bf5475..1c018bd9b 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/core/classify/application.yaml +++ b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/core/classify/application.yaml @@ -1,8 +1,7 @@ liteflow: rule-source: core/classify/flow.el.xml ai: - base-packages: - - com.yomahub.liteflow.test.ai.core.classify.cmp + base-packages: com.yomahub.liteflow.test.ai.core.classify.cmp enable: true openai: api-key: mock-api-key # 测试代码不需要配置,将使用 mock 数据,不会调用 AI 服务接口 diff --git a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/core/structure/application.yaml b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/core/structure/application.yaml index 015f877f0..0c2a79f12 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/core/structure/application.yaml +++ b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/core/structure/application.yaml @@ -1,8 +1,7 @@ liteflow: rule-source: core/structure/flow.el.xml ai: - base-packages: - - com.yomahub.liteflow.test.ai.core.structure.cmp + base-packages: com.yomahub.liteflow.test.ai.core.structure.cmp enable: true openai: api-key: mock-api-key # 测试代码不需要配置,将使用 mock 数据,不会调用 AI 服务接口 diff --git a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/core/tool/application.yaml b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/core/tool/application.yaml index 5a8bc6171..06056ba9d 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/core/tool/application.yaml +++ b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/core/tool/application.yaml @@ -1,8 +1,7 @@ liteflow: rule-source: core/tool/flow.el.xml ai: - base-packages: - - com.yomahub.liteflow.test.ai.core.tool.cmp + base-packages: com.yomahub.liteflow.test.ai.core.tool.cmp enable: true openai: api-key: mock-api-key # 测试代码不需要配置,将使用 mock 数据,不会调用 AI 服务接口 diff --git a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/workflow/coze/application.yaml b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/workflow/coze/application.yaml index 6af2e2b4b..389e0bae5 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/workflow/coze/application.yaml +++ b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/workflow/coze/application.yaml @@ -1,8 +1,7 @@ liteflow: rule-source: workflow/coze/flow.el.xml ai: - base-packages: - - com.yomahub.liteflow.test.ai.workflow.coze.cmp + base-packages: com.yomahub.liteflow.test.ai.workflow.coze.cmp enable: true workflow: coze: diff --git a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/workflow/dashscope/application.yaml b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/workflow/dashscope/application.yaml index 5c3f19edb..18e91dfeb 100644 --- a/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/workflow/dashscope/application.yaml +++ b/liteflow-testcase-el/liteflow-testcase-el-ai/src/test/resources/workflow/dashscope/application.yaml @@ -1,8 +1,7 @@ liteflow: rule-source: workflow/dashscope/flow.el.xml ai: - base-packages: - - com.yomahub.liteflow.test.ai.workflow.dashscope.cmp + base-packages: com.yomahub.liteflow.test.ai.workflow.dashscope.cmp enable: true openai: api-key: mock-api-key # 测试代码不需要配置,将使用 mock 数据,不会调用 AI 服务接口 diff --git a/pom.xml b/pom.xml index 1c894aa00..13990ea45 100644 --- a/pom.xml +++ b/pom.xml @@ -516,4 +516,3 @@ -