Class SpringAIOllamaService

java.lang.Object
com.bytedesk.ai.springai.service.BaseSpringAIService
com.bytedesk.ai.springai.providers.ollama.SpringAIOllamaService
All Implemented Interfaces:
SpringAIService

@Service @ConditionalOnProperty(name="spring.ai.ollama.chat.enabled", havingValue="true", matchIfMissing=false) public class SpringAIOllamaService extends BaseSpringAIService
  • Field Details

    • bytedeskOllamaChatModel

      @Autowired(required=false) @Qualifier("bytedeskOllamaChatModel") private org.springframework.ai.ollama.OllamaChatModel bytedeskOllamaChatModel
    • ollamaApi

      @Autowired @Qualifier("bytedeskOllamaApi") private org.springframework.ai.ollama.api.OllamaApi ollamaApi
  • Constructor Details

    • SpringAIOllamaService

      public SpringAIOllamaService()
  • Method Details

    • createDynamicOptions

      private org.springframework.ai.ollama.api.OllamaOptions createDynamicOptions(RobotLlm llm)
      根据机器人配置创建动态的OllamaOptions
      Parameters:
      llm - 机器人LLM配置
      Returns:
      根据机器人配置创建的选项
    • createDynamicChatModel

      private org.springframework.ai.ollama.OllamaChatModel createDynamicChatModel(RobotLlm llm)
      根据机器人配置创建动态的OllamaChatModel
      Parameters:
      llm - 机器人LLM配置
      Returns:
      配置了特定模型的OllamaChatModel
    • processPrompt

      protected void processPrompt(org.springframework.ai.chat.prompt.Prompt prompt, RobotProtobuf robot, MessageProtobuf messageProtobufQuery, MessageProtobuf messageProtobufReply)
      Specified by:
      processPrompt in class BaseSpringAIService
    • generateFaqPairs

      protected String generateFaqPairs(String prompt)
      Specified by:
      generateFaqPairs in class BaseSpringAIService
    • processPromptSync

      protected String processPromptSync(String message)
      Specified by:
      processPromptSync in class BaseSpringAIService
    • processPromptSSE

      protected void processPromptSSE(org.springframework.ai.chat.prompt.Prompt prompt, RobotProtobuf robot, MessageProtobuf messageProtobufQuery, MessageProtobuf messageProtobufReply, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter)
      Specified by:
      processPromptSSE in class BaseSpringAIService
    • configureModelWithTimeout

      private org.springframework.ai.ollama.OllamaChatModel configureModelWithTimeout(org.springframework.ai.ollama.OllamaChatModel model, long timeoutMillis)
    • isServiceHealthy

      public boolean isServiceHealthy()
    • getChatModel

      public org.springframework.ai.ollama.OllamaChatModel getChatModel()