main
HuangHai 2 months ago
parent 1955fa69a7
commit d3fd9bfda1

@ -1,6 +1,5 @@
package com.dsideal.aiSupport.Util.KeLing;
import cn.hutool.core.io.FileUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONUtil;
@ -13,7 +12,6 @@ import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* AI

@ -3,13 +3,30 @@ package com.dsideal.aiSupport.Util.Liblib;
import cloud.liblibai.client.LibLib;
import cloud.liblibai.openapi.client.ApiException;
import cloud.liblibai.openapi.client.model.*;
import com.dsideal.aiSupport.Plugin.YamlProp;
import com.jfinal.kit.Prop;
import java.util.HashMap;
import java.util.Map;
import static com.dsideal.aiSupport.AiSupportApplication.getEnvPrefix;
public class TextToImage {
// API访问凭证
protected static final String ak; // Access Key
protected static final String sk; // Secret Key
public static Prop PropKit; // 配置文件工具
static {
//加载配置文件
String configFile = "application_{?}.yaml".replace("{?}", getEnvPrefix());
PropKit = new YamlProp(configFile);
ak = PropKit.get("LIBLIB.accessKey"); // 从配置文件获取Access Key
sk = PropKit.get("LIBLIB.secretKey"); // 从配置文件获取Secret Key
}
public static void main(String[] args) throws ApiException, InterruptedException {
LibLib api = new LibLib();
LibLib api = new LibLib(ak, sk);
GetModelVersionRequest getModelVersionRequest = new GetModelVersionRequest();
getModelVersionRequest.setVersionUuid("a57911b5dfe64c6aa78821be99367276");
VersionResponse modelVersion = api.getModelVersion(getModelVersionRequest);
@ -39,9 +56,9 @@ public class TextToImage {
//NOTE(gz): 异步 SDK 调用方法
SubmitResponse submitResponse = api.submitTextToImage(request);
while(true) {
while (true) {
if (submitResponse.getData() == null) {
System.out.println("Error: " + submitResponse.getMsg());
System.out.println("Error: " + submitResponse.getMsg());
break;
}
StatusResponse status = api.getStatus(new StatusRequest().generateUuid(submitResponse.getData().getGenerateUuid()));
@ -52,12 +69,5 @@ public class TextToImage {
}
Thread.sleep(5000);
}
//NOTE(gz): 同步 SDK 调用方法
// StatusResponseData statusResponseData = api.textToImage(request);
// if (statusResponseData.getGenerateStatus() == GenerateStatus.SUCCEED) {
// System.out.println(statusResponseData.getImages());
// }
}
}

@ -24,6 +24,5 @@ public class TextToImageUltra {
}
Thread.sleep(5000);
}
}
}

Loading…
Cancel
Save