From 7269c19aabce8a810861a310875257d402ac43a3 Mon Sep 17 00:00:00 2001 From: xupei <1779019091@qq.com> Date: Tue, 19 Sep 2023 16:37:23 +0800 Subject: [PATCH] =?UTF-8?q?generate=20=E6=8E=A5=E5=8F=A3=E7=96=8F=E9=80=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/ai/da/python/PythonService.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/ai/da/python/PythonService.java b/src/main/java/com/ai/da/python/PythonService.java index 829a4e4d..16786833 100644 --- a/src/main/java/com/ai/da/python/PythonService.java +++ b/src/main/java/com/ai/da/python/PythonService.java @@ -1638,8 +1638,8 @@ public class PythonService { content.put("category", category); content.put("mode",mode); content.put("str", text); - content.put("version",2); - RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content)); + content.put("version","2"); + RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content,SerializerFeature.WriteMapNullValue)); Request request = new Request.Builder() // .url(accessPythonIp + ":2828/aida/diffusion") // .url("http://18.167.251.121:9992") @@ -1651,7 +1651,7 @@ public class PythonService { Response response = null; String bodyString = null; try { - log.info("generateSketchOrPrint请求入参content###{}", JSON.toJSONString(content)); + log.info("generateSketchOrPrint请求入参content###{}", JSON.toJSONString(content,SerializerFeature.WriteMapNullValue)); response = client.newCall(request).execute(); bodyString = response.body().string(); // bodyString = "{\n" + @@ -1676,12 +1676,12 @@ public class PythonService { JSONObject jsonObject = JSON.parseObject(bodyString); Boolean result = JSON.parseObject(JSON.toJSONString(response)).getBoolean("successful"); // Boolean result = Boolean.TRUE; - if (result) { + if (result && jsonObject.get("code").equals(200)) { return setGenerateImageList(jsonObject.getJSONObject("data")); } log.info("generateSketchOrPrintPrint失败###{}", jsonObject); //生成失败 - throw new BusinessException("generate exception!"); + throw new BusinessException("Generate Exception! Code : " + jsonObject.get("code")); } public String sendPostToModel(Map content,String portAndRoute,String functionName){