Class SpringAIOllamaService

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

@Service public class SpringAIOllamaService extends BaseSpringAIService
  • Field Details

  • Constructor Details

    • SpringAIOllamaService

      public SpringAIOllamaService()
  • Method Details

    • createOllamaOptions

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

      public org.springframework.ai.ollama.api.OllamaApi createOllamaApi(String apiUrl)
    • createOllamaChatModel

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

      protected void processPromptWebsocket(org.springframework.ai.chat.prompt.Prompt prompt, RobotProtobuf robot, MessageProtobuf messageProtobufQuery, MessageProtobuf messageProtobufReply, String fullPromptContent)
      Description copied from class: BaseSpringAIService
      Token usage data class
      Specified by:
      processPromptWebsocket in class BaseSpringAIService
    • processPromptSync

      protected String processPromptSync(String message, RobotProtobuf robot, String fullPromptContent)
      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, String fullPromptContent)
      Specified by:
      processPromptSse in class BaseSpringAIService
    • isModelExists

      public Boolean isModelExists(OllamaRequest request)
      检查模型是否存在
      Parameters:
      model - 模型名称
      Returns:
      如果模型存在返回true,否则返回false