gongchunyi
6 天以前 ad65726388fc99ff95db91b4a8a716362cccedd7
src/main/java/com/ruoyi/ai/controller/SalesAiController.java
@@ -8,9 +8,11 @@
import com.ruoyi.ai.store.MongoChatMemoryStore;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.security.LoginUser;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.framework.web.domain.AjaxResult;
import dev.langchain4j.data.message.AiMessage;
import dev.langchain4j.data.message.UserMessage;
import io.swagger.v3.oas.annotations.Operation;
@@ -56,6 +58,7 @@
    }
    @Operation(summary = "销售助手对话")
    @Log(title = "销售智能体对话", businessType = BusinessType.OTHER)
    @PostMapping(value = "/chat", produces = "text/stream;charset=utf-8")
    public Flux<String> chat(@RequestBody ChatForm chatForm) {
        if (!StringUtils.hasText(chatForm.getMemoryId())) {
@@ -99,22 +102,22 @@
    @Operation(summary = "销售助手会话列表")
    @GetMapping("/history/sessions")
    public R<?> listSessions() {
        return R.ok(aiChatSessionService.listCurrentUserSessions(SecurityUtils.getLoginUser()));
    public AjaxResult listSessions() {
        return success(aiChatSessionService.listCurrentUserSessions(SecurityUtils.getLoginUser()));
    }
    @Operation(summary = "销售助手会话消息")
    @GetMapping("/history/messages/{memoryId}")
    public R<?> listMessages(@PathVariable String memoryId) {
        return R.ok(aiChatSessionService.listCurrentUserMessages(memoryId, SecurityUtils.getLoginUser()));
    public AjaxResult listMessages(@PathVariable String memoryId) {
        return success(aiChatSessionService.listCurrentUserMessages(memoryId, SecurityUtils.getLoginUser()));
    }
    @Operation(summary = "删除销售助手会话")
    @Log(title = "删除销售智能体会话", businessType = BusinessType.DELETE)
    @DeleteMapping("/history/{memoryId}")
    public R<?> deleteSession(@PathVariable String memoryId) {
    public AjaxResult deleteSession(@PathVariable String memoryId) {
        aiSessionUserContext.remove(memoryId);
        aiChatSessionService.deleteCurrentUserSession(memoryId, SecurityUtils.getLoginUser());
        return R.ok();
        return toAjax(aiChatSessionService.deleteCurrentUserSession(memoryId, SecurityUtils.getLoginUser()));
    }
    private boolean isBusinessDataIntent(String message) {