Bläddra i källkod

通过接口 获取AI整理的个人信息

zrd 3 månader sedan
förälder
incheckning
b7d250cf9d

+ 8 - 2
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/app/aipromptmanagement/AppAiController.java

@@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.infra.service.aipromptmanagement.utils.FileResp;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import jakarta.annotation.Resource;
+import jakarta.servlet.http.HttpServletRequest;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.http.MediaType;
 import org.springframework.validation.annotation.Validated;
@@ -175,6 +176,7 @@ public class AppAiController {
         Map<String, Object> inputs = new HashMap<>();
         String apiKey = DictFrameworkUtils.parseDictDataValue("ai_key", "多轮对话");
         inputs.put("type", createReqVO.getType());
+        inputs.put("token", createReqVO.getType());
         // Map<String, Object> inputs, String user, String apiKey,String query,String conversationId
         return success(workflowRunService.getDifyMessage(inputs, SecurityFrameworkUtils.getLoginUserId().toString(),
                 apiKey, createReqVO.getQuery(), createReqVO.getConversationId()));
@@ -182,11 +184,15 @@ public class AppAiController {
     
     @PostMapping(value = "/chat-messages-stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
     @Operation(summary = "AI问答(流式)", description = "流式返回,响应较快")
-    public Flux<String> generateMindMap(@RequestBody MessageDifyaiReqVO createReqVO) {
+    public Flux<String> generateMindMap(@RequestBody MessageDifyaiReqVO createReqVO, HttpServletRequest request) {
         String apiKey = DictFrameworkUtils.parseDictDataValue("ai_key", "多轮对话");
         Map<String, Object> inputs = new HashMap<>();
-        inputs.put("type", createReqVO.getType());
         
+        
+        inputs.put("type", createReqVO.getType());
+        String token = SecurityFrameworkUtils.obtainAuthorization(request,
+                "Authorization", "token");
+        inputs.put("token", token);
         return workflowRunService.getDifyMessageStreaming(inputs,
                         SecurityFrameworkUtils.getLoginUserId().toString(),
                         apiKey, createReqVO.getQuery(), createReqVO.getConversationId())