Package com.bytedesk.ai.springai.base
Class BaseSpringAIService
java.lang.Object
com.bytedesk.ai.springai.base.BaseSpringAIService
- All Implemented Interfaces:
SpringAIService
- Direct Known Subclasses:
SpringAIDashscopeService
,SpringAIDeepseekService
,SpringAIGiteeService
,SpringAIOllamaService
,SpringAISiliconFlowService
,SpringAIZhipuaiService
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final MessagePersistCache
protected final IMessageSendService
protected final RobotRestService
protected final Optional<SpringAIVectorService>
protected final ThreadRestService
protected final UidUtils
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BaseSpringAIService
(Optional<SpringAIVectorService> springAIVectorService, IMessageSendService messageSendService, UidUtils uidUtils, RobotRestService robotRestService, ThreadRestService threadRestService, MessagePersistCache messagePersistCache) -
Method Summary
Modifier and TypeMethodDescriptionbuildKbPrompt
(String systemPrompt, String query, String context) protected abstract String
generateFaqPairs
(String prompt) generateFaqPairsAsync
(String chunk) 异步生成FAQ对void
generateFaqPairsSync
(String chunk) 同步生成FAQ对void
persistMessage
(String messageJson) protected abstract void
processPrompt
(org.springframework.ai.chat.prompt.Prompt prompt, MessageProtobuf messageProtobuf) protected abstract void
processPromptSSE
(org.springframework.ai.chat.prompt.Prompt prompt, MessageProtobuf messageProtobuf, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) protected abstract String
processPromptSync
(String message) void
sendSseMessage
(String query, RobotProtobuf robot, MessageProtobuf messageProtobuf, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) 发送Sse消息void
sendWebsocketMessage
(String query, RobotEntity robot, MessageProtobuf messageProtobuf) 发送websocket消息
-
Field Details
-
springAIVectorService
-
messageSendService
-
uidUtils
-
robotRestService
-
threadRestService
-
messagePersistCache
-
-
Constructor Details
-
BaseSpringAIService
protected BaseSpringAIService(Optional<SpringAIVectorService> springAIVectorService, IMessageSendService messageSendService, UidUtils uidUtils, RobotRestService robotRestService, ThreadRestService threadRestService, MessagePersistCache messagePersistCache)
-
-
Method Details
-
sendWebsocketMessage
Description copied from interface:SpringAIService
发送websocket消息- Specified by:
sendWebsocketMessage
in interfaceSpringAIService
- Parameters:
query
- 用户查询robot
- 机器人实体messageProtobuf
- 消息协议
-
sendSseMessage
public void sendSseMessage(String query, RobotProtobuf robot, MessageProtobuf messageProtobuf, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) Description copied from interface:SpringAIService
发送Sse消息- Specified by:
sendSseMessage
in interfaceSpringAIService
emitter
- SseEmitter
-
generateFaqPairsAsync
Description copied from interface:SpringAIService
异步生成FAQ对- Specified by:
generateFaqPairsAsync
in interfaceSpringAIService
- Parameters:
chunk
- 文本块- Returns:
- 生成的FAQ对
-
generateFaqPairsSync
Description copied from interface:SpringAIService
同步生成FAQ对- Specified by:
generateFaqPairsSync
in interfaceSpringAIService
- Parameters:
chunk
- 文本块
-
persistMessage
- Specified by:
persistMessage
in interfaceSpringAIService
-
buildKbPrompt
-
processPrompt
protected abstract void processPrompt(org.springframework.ai.chat.prompt.Prompt prompt, MessageProtobuf messageProtobuf) -
processPromptSync
-
processPromptSSE
protected abstract void processPromptSSE(org.springframework.ai.chat.prompt.Prompt prompt, MessageProtobuf messageProtobuf, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) -
generateFaqPairs
-