Class RobotService


@Service @Description("Robot Service - AI robot message processing and LLM integration service") public class RobotService extends AbstractRobotService
  • Field Details

  • Constructor Details

    • RobotService

      public RobotService()
  • Method Details

    • getRobotRestService

      protected RobotRestService getRobotRestService()
      Description copied from class: AbstractRobotService
      获取RobotRestService实例,由子类实现
      Specified by:
      getRobotRestService in class AbstractRobotService
    • getSpringAIServiceRegistry

      protected SpringAIServiceRegistry getSpringAIServiceRegistry()
      Description copied from class: AbstractRobotService
      获取SpringAIServiceRegistry实例,由子类实现
      Specified by:
      getSpringAIServiceRegistry in class AbstractRobotService
    • 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

      public MessageProtobuf processSyncVisitorMessage(String messageJson)
    • preprocessAndSegment

      private List<String> preprocessAndSegment(String content)
    • buildExpandedQuery

      private String buildExpandedQuery(String base, List<String> tokens)
      基于分词结果构建扩展查询,提升召回。 - 去重 - 限制最大拼接词数,避免过长
    • queryRewrite

      public String queryRewrite(String content, String orgUid)
      查询重写服务 - 纯文本处理,不需要知识库
    • summaryGeneration

      public String summaryGeneration(String content, String orgUid)
      摘要生成服务 - 纯文本处理,不需要知识库
    • threadTitleGeneration

      public String threadTitleGeneration(String content, String orgUid)
      会话标题生成服务 - 纯文本处理,不需要知识库
    • contextTemplateSummary

      public String contextTemplateSummary(String content, String orgUid)
      上下文模板摘要服务 - 纯文本处理,不需要知识库
    • ocrExtraction

      public String ocrExtraction(String imageUrl, String orgUid)
      OCR文字提取服务 - 图片文字识别,不需要知识库
    • entityExtraction

      public String entityExtraction(String content, String orgUid)
      实体提取服务 - 纯文本处理,不需要知识库
    • relationshipExtraction

      public String relationshipExtraction(String content, String orgUid)
      关系提取服务 - 纯文本处理,不需要知识库
    • questionSuggest

      public String questionSuggest(String content, String orgUid)
      问题建议服务 - 纯文本处理,不需要知识库
    • intentClassification

      public String intentClassification(String content, String orgUid)
      意图识别 - 纯文本处理,不需要知识库
    • emotionAnalysis

      public String emotionAnalysis(String content, String orgUid)
      情绪分析 - 纯文本处理,不需要知识库
    • threadSummary

      public String threadSummary(String content, String orgUid)
      会话小结 - 纯文本处理,不需要知识库
    • fallbackResponse

      public String fallbackResponse(String content, String orgUid)
      备用回复服务 - 可能需要查询知识库作为备用答案
    • validateParameters

      private void validateParameters(String content, String orgUid)
      验证请求参数
    • validateAndParseMessage

      private RobotService.MessageValidationResult validateAndParseMessage(String messageJson)
      验证和解析消息的公共方法
    • resolveRobotContext

      private RobotService.RobotContext resolveRobotContext(String threadTopic)
    • getThreadByTopic

      private ThreadEntity getThreadByTopic(String threadTopic)
    • buildRobotFromThread

      private RobotProtobuf buildRobotFromThread(ThreadEntity thread, String threadTopic)
      根据线程记录构建机器人信息
    • shouldBypassRobotReply

      private boolean shouldBypassRobotReply(ThreadEntity thread)
    • hasAgentAssigned

      private boolean hasAgentAssigned(ThreadEntity thread)
    • sendTransferInterceptionResponse

      private void sendTransferInterceptionResponse(RobotService.MessageValidationResult validationResult, MessageProtobuf messageProtobufReply, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter)
    • getAIProviderName

      private String getAIProviderName(RobotProtobuf robot)
      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逻辑