- 修改RealAIService.submitTextToImageTask使用nano-banana/nano-banana-hd模型 - 支持根据hdMode参数选择模型(标准/高清) - 修复数据库列类型:将result_url等字段改为TEXT类型以支持Base64图片 - 添加数据库修复SQL脚本(fix_database_columns.sql, update_database_schema.sql) - 改进StoryboardVideoService的错误处理和空值检查 - 添加GlobalExceptionHandler全局异常处理 - 优化图片URL提取逻辑,支持url和b64_json两种格式 - 改进响应格式验证,确保data字段不为空
66 lines
2.2 KiB
Java
66 lines
2.2 KiB
Java
import kong.unirest.HttpResponse;
|
|
import kong.unirest.Unirest;
|
|
import kong.unirest.UnirestException;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import java.util.Map;
|
|
|
|
public class TestApiConnection {
|
|
public static void main(String[] args) {
|
|
String apiBaseUrl = "http://116.62.4.26:8081";
|
|
String apiKey = "ak_5f13ec469e6047d5b8155c3cc91350e2";
|
|
|
|
System.out.println("测试API连接...");
|
|
System.out.println("API端点: " + apiBaseUrl);
|
|
System.out.println("API密钥: " + apiKey.substring(0, 10) + "...");
|
|
|
|
try {
|
|
// 测试获取模型列表
|
|
System.out.println("\n1. 测试获取模型列表...");
|
|
HttpResponse<String> modelsResponse = Unirest.get(apiBaseUrl + "/user/ai/models")
|
|
.header("Authorization", "Bearer " + apiKey)
|
|
.asString();
|
|
|
|
System.out.println("状态码: " + modelsResponse.getStatus());
|
|
System.out.println("响应内容: " + modelsResponse.getBody());
|
|
|
|
// 测试提交任务
|
|
System.out.println("\n2. 测试提交文生视频任务...");
|
|
String requestBody = "{\n" +
|
|
" \"modelName\": \"sc_sora2_text_landscape_10s_small\",\n" +
|
|
" \"prompt\": \"一只猫在飞\",\n" +
|
|
" \"aspectRatio\": \"16:9\",\n" +
|
|
" \"imageToVideo\": false\n" +
|
|
"}";
|
|
|
|
HttpResponse<String> submitResponse = Unirest.post(apiBaseUrl + "/user/ai/tasks/submit")
|
|
.header("Content-Type", "application/json")
|
|
.header("Authorization", "Bearer " + apiKey)
|
|
.body(requestBody)
|
|
.asString();
|
|
|
|
System.out.println("状态码: " + submitResponse.getStatus());
|
|
System.out.println("响应内容: " + submitResponse.getBody());
|
|
|
|
} catch (UnirestException e) {
|
|
System.err.println("API调用异常: " + e.getMessage());
|
|
e.printStackTrace();
|
|
} catch (Exception e) {
|
|
System.err.println("其他异常: " + e.getMessage());
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|