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){