From 42fcb9e16dcd0e47f3c8907b0df37c328dd81f8b Mon Sep 17 00:00:00 2001 From: 0007 <0007@qq.com> Date: Wed, 27 Aug 2025 19:58:02 +0800 Subject: [PATCH] Add File --- .../llm/ollama/OllamaAutoConfiguration.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 agents-flex-spring-boot-starter/src/main/java/com/agentsflex/spring/boot/llm/ollama/OllamaAutoConfiguration.java diff --git a/agents-flex-spring-boot-starter/src/main/java/com/agentsflex/spring/boot/llm/ollama/OllamaAutoConfiguration.java b/agents-flex-spring-boot-starter/src/main/java/com/agentsflex/spring/boot/llm/ollama/OllamaAutoConfiguration.java new file mode 100644 index 0000000..18546fd --- /dev/null +++ b/agents-flex-spring-boot-starter/src/main/java/com/agentsflex/spring/boot/llm/ollama/OllamaAutoConfiguration.java @@ -0,0 +1,33 @@ +package com.agentsflex.spring.boot.llm.ollama; + +import com.agentsflex.llm.ollama.OllamaLlm; +import com.agentsflex.llm.ollama.OllamaLlmConfig; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Agents-Flex Ollama自动配置。 + * + * @author hustlelr + * @since 2025-02-11 + */ +@ConditionalOnClass(OllamaLlm.class) +@Configuration(proxyBeanMethods = false) +@EnableConfigurationProperties(OllamaProperties.class) +public class OllamaAutoConfiguration { + + @Bean + @ConditionalOnMissingBean + public OllamaLlm ollamaLlm(OllamaProperties properties) { + OllamaLlmConfig config = new OllamaLlmConfig(); + config.setApiKey(properties.getApiKey()); + config.setEndpoint(properties.getEndpoint()); + config.setModel(properties.getModel()); + config.setEnableThinking(properties.getThink()); + return new OllamaLlm(config); + } + +}