Package com.bytedesk.ai.robot
Class RobotService
java.lang.Object
com.bytedesk.ai.robot.AbstractRobotService
com.bytedesk.ai.robot.RobotService
@Service
@Description("Robot Service - AI robot message processing and LLM integration service")
public class RobotService
extends AbstractRobotService
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class消息验证和解析的通用方法private static final record -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MessageServiceprivate final RobotRestServiceprivate final SegmentServiceprivate final SpringAIServiceRegistryprivate final SseMessageHelperprivate final ThreadRestService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate StringbuildExpandedQuery(String base, List<String> tokens) 基于分词结果构建扩展查询,提升召回。private RobotProtobufbuildRobotFromThread(ThreadEntity thread, String threadTopic) 根据线程记录构建机器人信息contextTemplateSummary(String content, String orgUid) 上下文模板摘要服务 - 纯文本处理,不需要知识库emotionAnalysis(String content, String orgUid) 情绪分析 - 纯文本处理,不需要知识库entityExtraction(String content, String orgUid) 实体提取服务 - 纯文本处理,不需要知识库fallbackResponse(String content, String orgUid) 备用回复服务 - 可能需要查询知识库作为备用答案private StringgetAIProviderName(RobotProtobuf robot) AI提供商选择和处理的公共方法protected RobotRestService获取RobotRestService实例,由子类实现protected SpringAIServiceRegistry获取SpringAIServiceRegistry实例,由子类实现private ThreadEntitygetThreadByTopic(String threadTopic) private booleanhasAgentAssigned(ThreadEntity thread) intentClassification(String content, String orgUid) 意图识别 - 纯文本处理,不需要知识库ocrExtraction(String imageUrl, String orgUid) OCR文字提取服务 - 图片文字识别,不需要知识库preprocessAndSegment(String content) private voidprocessAIWithFallback(String query, RobotProtobuf robot, MessageProtobuf messageProtobufQuery, MessageProtobuf messageProtobufReply, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) 通用的AI消息处理方法,包含fallback逻辑voidprocessSseMemberMessage(String messageJson, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) voidprocessSseVisitorMessage(String messageJson, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) private StringprocessSyncAIWithFallback(String query, RobotProtobuf robot, MessageProtobuf messageProtobufQuery, MessageProtobuf messageProtobufReply) 通用的同步AI消息处理方法,包含fallback逻辑processSyncVisitorMessage(String messageJson) queryRewrite(String content, String orgUid) 查询重写服务 - 纯文本处理,不需要知识库questionSuggest(String content, String orgUid) 问题建议服务 - 纯文本处理,不需要知识库relationshipExtraction(String content, String orgUid) 关系提取服务 - 纯文本处理,不需要知识库private RobotService.RobotContextresolveRobotContext(String threadTopic) private voidsendTransferInterceptionResponse(RobotService.MessageValidationResult validationResult, MessageProtobuf messageProtobufReply, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) private booleanshouldBypassRobotReply(ThreadEntity thread) summaryGeneration(String content, String orgUid) 摘要生成服务 - 纯文本处理,不需要知识库threadSummary(String content, String orgUid) 会话小结 - 纯文本处理,不需要知识库threadTitleGeneration(String content, String orgUid) 会话标题生成服务 - 纯文本处理,不需要知识库validateAndParseMessage(String messageJson) 验证和解析消息的公共方法private voidvalidateParameters(String content, String orgUid) 验证请求参数Methods inherited from class com.bytedesk.ai.robot.AbstractRobotService
processMultiModalSyncRequest, processSyncRequest, processSyncRequest, processSyncRequest
-
Field Details
-
springAIServiceRegistry
-
threadRestService
-
messageService
-
robotRestService
-
segmentService
-
sseMessageHelper
-
-
Constructor Details
-
RobotService
public RobotService()
-
-
Method Details
-
getRobotRestService
Description copied from class:AbstractRobotService获取RobotRestService实例,由子类实现- Specified by:
getRobotRestServicein classAbstractRobotService
-
getSpringAIServiceRegistry
Description copied from class:AbstractRobotService获取SpringAIServiceRegistry实例,由子类实现- Specified by:
getSpringAIServiceRegistryin classAbstractRobotService
-
processSseMemberMessage
public void processSseMemberMessage(String messageJson, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) -
processSseVisitorMessage
public void processSseVisitorMessage(String messageJson, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) -
processSyncVisitorMessage
-
preprocessAndSegment
-
buildExpandedQuery
基于分词结果构建扩展查询,提升召回。 - 去重 - 限制最大拼接词数,避免过长 -
queryRewrite
查询重写服务 - 纯文本处理,不需要知识库 -
summaryGeneration
摘要生成服务 - 纯文本处理,不需要知识库 -
threadTitleGeneration
会话标题生成服务 - 纯文本处理,不需要知识库 -
contextTemplateSummary
上下文模板摘要服务 - 纯文本处理,不需要知识库 -
ocrExtraction
OCR文字提取服务 - 图片文字识别,不需要知识库 -
entityExtraction
实体提取服务 - 纯文本处理,不需要知识库 -
relationshipExtraction
关系提取服务 - 纯文本处理,不需要知识库 -
questionSuggest
问题建议服务 - 纯文本处理,不需要知识库 -
intentClassification
意图识别 - 纯文本处理,不需要知识库 -
emotionAnalysis
情绪分析 - 纯文本处理,不需要知识库 -
threadSummary
会话小结 - 纯文本处理,不需要知识库 -
fallbackResponse
备用回复服务 - 可能需要查询知识库作为备用答案 -
validateParameters
验证请求参数 -
validateAndParseMessage
验证和解析消息的公共方法 -
resolveRobotContext
-
getThreadByTopic
-
buildRobotFromThread
根据线程记录构建机器人信息 -
shouldBypassRobotReply
-
hasAgentAssigned
-
sendTransferInterceptionResponse
private void sendTransferInterceptionResponse(RobotService.MessageValidationResult validationResult, MessageProtobuf messageProtobufReply, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) -
getAIProviderName
AI提供商选择和处理的公共方法 -
processAIWithFallback
private void processAIWithFallback(String query, RobotProtobuf robot, MessageProtobuf messageProtobufQuery, MessageProtobuf messageProtobufReply, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) 通用的AI消息处理方法,包含fallback逻辑 -
processSyncAIWithFallback
private String processSyncAIWithFallback(String query, RobotProtobuf robot, MessageProtobuf messageProtobufQuery, MessageProtobuf messageProtobufReply) 通用的同步AI消息处理方法,包含fallback逻辑
-