|
@@ -1,8 +1,10 @@
|
|
|
package cn.iocoder.yudao.module.infra.api.ai;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils;
|
|
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
import cn.iocoder.yudao.framework.websocket.core.sender.WebSocketMessageSender;
|
|
|
+import cn.iocoder.yudao.module.infra.api.ai.dto.DifyReqDTO;
|
|
|
import cn.iocoder.yudao.module.infra.api.ai.dto.DifyaiReqDTO;
|
|
|
import cn.iocoder.yudao.module.infra.api.ai.dto.StreamResponseDTO;
|
|
|
import cn.iocoder.yudao.module.infra.service.aipromptmanagement.WorkflowRunService;
|
|
@@ -12,7 +14,9 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import reactor.core.publisher.Flux;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -40,6 +44,37 @@ public class AiApiImpl implements AiApi {
|
|
|
return workflowRunService.getDifyResul(inputs, createReqVO.getType(), apiKey, 1L);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String dataDual(DifyReqDTO createReqVO) {
|
|
|
+ Map<String, Object> inputs = new HashMap<>();
|
|
|
+ String apiKey = DictFrameworkUtils.parseDictDataValue("ai_key", "数据提取");
|
|
|
+ List<Map<String, Object>> images = new ArrayList<>();
|
|
|
+ if (CollUtil.isNotEmpty(createReqVO.getImages())) {
|
|
|
+ for (String image : createReqVO.getImages()) {
|
|
|
+ Map<String, Object> variableValue = new HashMap<>();
|
|
|
+ variableValue.put("transfer_method", "remote_url");
|
|
|
+ variableValue.put("url", image);
|
|
|
+ variableValue.put("type", "image");
|
|
|
+ images.add(variableValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ inputs.put("images", images);
|
|
|
+ }
|
|
|
+ if (CollUtil.isNotEmpty(createReqVO.getDocs())) {
|
|
|
+ for (String image : createReqVO.getImages()) {
|
|
|
+ Map<String, Object> variableValue = new HashMap<>();
|
|
|
+ variableValue.put("transfer_method", "remote_url");
|
|
|
+ variableValue.put("url", image);
|
|
|
+ variableValue.put("type", "document");
|
|
|
+ images.add(variableValue);
|
|
|
+ inputs.put("docs", images);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return workflowRunService.getDifyResul(inputs, "createReqVO.getType()", apiKey, 1L);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public String html(DifyaiReqDTO createReqVO) {
|
|
|
Map<String, Object> inputs = new HashMap<>();
|