Package com.bytedesk.ai.springai.ollama
Class SpringAIOllamaService
java.lang.Object
com.bytedesk.ai.springai.base.BaseSpringAIService
com.bytedesk.ai.springai.ollama.SpringAIOllamaService
- All Implemented Interfaces:
SpringAIService
@Service
@ConditionalOnProperty(name="spring.ai.ollama.chat.enabled",
havingValue="true")
public class SpringAIOllamaService
extends BaseSpringAIService
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Optional<org.springframework.ai.ollama.OllamaChatModel>
private final IMessageSendService
Fields inherited from class com.bytedesk.ai.springai.base.BaseSpringAIService
messagePersistCache, robotRestService, springAIVectorService, threadRestService, uidUtils
-
Constructor Summary
ConstructorsConstructorDescriptionSpringAIOllamaService
(Optional<org.springframework.ai.ollama.OllamaChatModel> bytedeskOllamaChatModel, Optional<SpringAIVectorService> springAIVectorService, IMessageSendService messageSendService, UidUtils uidUtils, RobotRestService robotRestService, ThreadRestService threadRestService, MessagePersistCache messagePersistCache) -
Method Summary
Modifier and TypeMethodDescriptionprotected String
generateFaqPairs
(String prompt) Optional<org.springframework.ai.ollama.OllamaChatModel>
获取Ollama所有可用的模型列表boolean
检查Ollama服务是否正常运行protected void
processPrompt
(org.springframework.ai.chat.prompt.Prompt prompt, MessageProtobuf messageProtobuf) protected void
processPromptSSE
(org.springframework.ai.chat.prompt.Prompt prompt, MessageProtobuf messageProtobuf, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) protected String
processPromptSync
(String message) Methods inherited from class com.bytedesk.ai.springai.base.BaseSpringAIService
buildKbPrompt, generateFaqPairsAsync, generateFaqPairsSync, persistMessage, sendSseMessage, sendWebsocketMessage
-
Field Details
-
bytedeskOllamaChatModel
-
messageSendService
-
-
Constructor Details
-
SpringAIOllamaService
public SpringAIOllamaService(@Qualifier("bytedeskOllamaChatModel") Optional<org.springframework.ai.ollama.OllamaChatModel> bytedeskOllamaChatModel, Optional<SpringAIVectorService> springAIVectorService, IMessageSendService messageSendService, UidUtils uidUtils, RobotRestService robotRestService, ThreadRestService threadRestService, MessagePersistCache messagePersistCache)
-
-
Method Details
-
processPrompt
protected void processPrompt(org.springframework.ai.chat.prompt.Prompt prompt, MessageProtobuf messageProtobuf) - Specified by:
processPrompt
in classBaseSpringAIService
-
generateFaqPairs
- Specified by:
generateFaqPairs
in classBaseSpringAIService
-
processPromptSync
- Specified by:
processPromptSync
in classBaseSpringAIService
-
processPromptSSE
protected void processPromptSSE(org.springframework.ai.chat.prompt.Prompt prompt, MessageProtobuf messageProtobuf, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) - Specified by:
processPromptSSE
in classBaseSpringAIService
-
isServiceHealthy
public boolean isServiceHealthy()检查Ollama服务是否正常运行- Returns:
- 如果服务正常运行返回true,否则返回false
-
getOllamaChatModel
获取Ollama所有可用的模型列表- Returns:
- 包含所有可用模型信息的对象
-