|
@@ -352,6 +352,42 @@ public class DifyService {
|
|
.responseMode(ResponseMode.STREAMING)
|
|
.responseMode(ResponseMode.STREAMING)
|
|
.build();
|
|
.build();
|
|
|
|
|
|
|
|
+ if (inputs.containsKey("inputs")) {
|
|
|
|
+ message.setInputs((Map<String, Object>) inputs.get("inputs"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 添加会话id
|
|
|
|
+ if (inputs.containsKey("conversationId")) {
|
|
|
|
+ message.setConversationId(inputs.get("conversationId").toString());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 添加文件
|
|
|
|
+ if (inputs.containsKey("files")) {
|
|
|
|
+ List<FileInfo> infoList = new ArrayList<>();
|
|
|
|
+ JSONArray files = json.getJSONArray("files");
|
|
|
|
+ for (int i = 0; i < files.size(); i++) {
|
|
|
|
+ JSONObject jsonObject = files.getJSONObject(i);
|
|
|
|
+ FileInfo info = new FileInfo();
|
|
|
|
+ String type = jsonObject.getString("type");
|
|
|
|
+ String transfer_method = jsonObject.getString("transfer_method");
|
|
|
|
+ String url = jsonObject.getString("url");
|
|
|
|
+ info.setUrl(url);
|
|
|
|
+ for (FileType fileType : FileType.values()) {
|
|
|
|
+ if(fileType.getValue().equals(type)){
|
|
|
|
+ info.setType(fileType);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for (FileTransferMethod fileTransferMethod : FileTransferMethod.values()) {
|
|
|
|
+ if(fileTransferMethod.getValue().equals(transfer_method)){
|
|
|
|
+ info.setTransferMethod(fileTransferMethod);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ infoList.add(info);
|
|
|
|
+ }
|
|
|
|
+ message.setFiles(infoList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
StringBuilder chatM = new StringBuilder();
|
|
StringBuilder chatM = new StringBuilder();
|
|
|
|
|
|
StringBuilder agentM = new StringBuilder();
|
|
StringBuilder agentM = new StringBuilder();
|
|
@@ -470,21 +506,36 @@ public class DifyService {
|
|
.responseMode(ResponseMode.STREAMING)
|
|
.responseMode(ResponseMode.STREAMING)
|
|
.build();
|
|
.build();
|
|
|
|
|
|
|
|
+ if (inputs.containsKey("inputs")) {
|
|
|
|
+ message.setInputs((Map<String, Object>) inputs.get("inputs"));
|
|
|
|
+ }
|
|
|
|
+
|
|
// 添加会话id
|
|
// 添加会话id
|
|
if (inputs.containsKey("conversationId")) {
|
|
if (inputs.containsKey("conversationId")) {
|
|
message.setConversationId(inputs.get("conversationId").toString());
|
|
message.setConversationId(inputs.get("conversationId").toString());
|
|
}
|
|
}
|
|
|
|
|
|
- // 添加图片
|
|
|
|
|
|
+ // 添加文件
|
|
if (inputs.containsKey("files")) {
|
|
if (inputs.containsKey("files")) {
|
|
List<FileInfo> infoList = new ArrayList<>();
|
|
List<FileInfo> infoList = new ArrayList<>();
|
|
JSONArray files = json.getJSONArray("files");
|
|
JSONArray files = json.getJSONArray("files");
|
|
for (int i = 0; i < files.size(); i++) {
|
|
for (int i = 0; i < files.size(); i++) {
|
|
JSONObject jsonObject = files.getJSONObject(i);
|
|
JSONObject jsonObject = files.getJSONObject(i);
|
|
FileInfo info = new FileInfo();
|
|
FileInfo info = new FileInfo();
|
|
- info.setType(FileType.IMAGE);
|
|
|
|
- info.setTransferMethod(FileTransferMethod.REMOTE_URL);
|
|
|
|
- info.setUrl(jsonObject.getString("url"));
|
|
|
|
|
|
+ String type = jsonObject.getString("type");
|
|
|
|
+ String transfer_method = jsonObject.getString("transfer_method");
|
|
|
|
+ String url = jsonObject.getString("url");
|
|
|
|
+ info.setUrl(url);
|
|
|
|
+ for (FileType fileType : FileType.values()) {
|
|
|
|
+ if(fileType.getValue().equals(type)){
|
|
|
|
+ info.setType(fileType);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for (FileTransferMethod fileTransferMethod : FileTransferMethod.values()) {
|
|
|
|
+ if(fileTransferMethod.getValue().equals(transfer_method)){
|
|
|
|
+ info.setTransferMethod(fileTransferMethod);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
infoList.add(info);
|
|
infoList.add(info);
|
|
}
|
|
}
|
|
message.setFiles(infoList);
|
|
message.setFiles(infoList);
|