【解决 TODO 】AI PPT:解决一些 TODO

This commit is contained in:
xiaoxin 2025-03-18 14:41:06 +08:00
parent acf68b1cec
commit 270fea0c5d
4 changed files with 89 additions and 94 deletions

View File

@ -24,16 +24,15 @@ import java.util.Objects;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
// TODO @新要不改成 WenDuoDuoPptApi
/** /**
* 文多多 API * 文多多 API
* *
* @see <a href="https://docmee.cn/open-platform/api">PPT 生成 API</a>
*
* @author xiaoxin * @author xiaoxin
* @see <a href="https://docmee.cn/open-platform/api">PPT 生成 API</a>
*/ */
@Slf4j @Slf4j
public class WddPptApi { public class WenDuoDuoPptApi {
public static final String BASE_URL = "https://docmee.cn"; public static final String BASE_URL = "https://docmee.cn";
@ -50,7 +49,7 @@ public class WddPptApi {
}); });
// TODO @新是不是不用 baseUrl // TODO @新是不是不用 baseUrl
public WddPptApi(String baseUrl) { public WenDuoDuoPptApi(String baseUrl) {
this.webClient = WebClient.builder() this.webClient = WebClient.builder()
.baseUrl(baseUrl) .baseUrl(baseUrl)
// TODO @新建议token 作为 defaultHeader // TODO @新建议token 作为 defaultHeader
@ -82,35 +81,14 @@ public class WddPptApi {
.block(); .block();
} }
// TODO @xin是不是给个 API 连接这样 typecontentfiles 都不用写注释太细了
/** /**
* 创建任务 * 创建任务
* *
* @param type 类型 * @param type 类型
* 1.智能生成主题要求
* 2.上传文件生成
* 3.上传思维导图生成
* 4.通过word精准转ppt
* 5.通过网页链接生成
* 6.粘贴文本内容生成
* 7.Markdown大纲生成
* @param content 内容 * @param content 内容
* type=1 用户输入主题或要求不超过1000字符
* type=24 不传
* type=3 幕布等分享链接
* type=5 网页链接地址http/https
* type=6 粘贴文本内容不超过20000字符
* type=7 大纲内容markdown
* @param files 文件列表 * @param files 文件列表
* 文件列表文件数不超过5个总大小不超过50M
* type=1 上传参考文件非必传支持多个
* type=2 上传文件支持多个
* type=3 上传思维导图xmind/mm/md仅支持一个
* type=4 上传word文件仅支持一个
* type=567 不传
* <p>
* 支持格式doc/docx/pdf/ppt/pptx/txt/md/xls/xlsx/csv/html/epub/mobi/xmind/mm
* @return 任务ID * @return 任务ID
* @see <a href="https://docmee.cn/open-platform/api#%E5%88%9B%E5%BB%BA%E4%BB%BB%E5%8A%A1">创建任务</a>
*/ */
public ApiResponse createTask(String token, Integer type, String content, List<MultipartFile> files) { public ApiResponse createTask(String token, Integer type, String content, List<MultipartFile> files) {
MultiValueMap<String, Object> formData = new LinkedMultiValueMap<>(); MultiValueMap<String, Object> formData = new LinkedMultiValueMap<>();
@ -258,7 +236,8 @@ public class WddPptApi {
Integer code, Integer code,
String message, String message,
Map<String, Object> data Map<String, Object> data
) { } ) {
}
/** /**
* 创建任务 * 创建任务
@ -268,7 +247,8 @@ public class WddPptApi {
Integer type, Integer type,
String content, String content,
List<MultipartFile> files List<MultipartFile> files
) { } ) {
}
/** /**
* 生成大纲内容请求 * 生成大纲内容请求
@ -281,7 +261,8 @@ public class WddPptApi {
String audience, String audience,
String lang, String lang,
String prompt String prompt
) { } ) {
}
/** /**
* 修改大纲内容请求 * 修改大纲内容请求
@ -291,7 +272,8 @@ public class WddPptApi {
String id, String id,
String markdown, String markdown,
String question String question
) { } ) {
}
/** /**
* 生成 PPT 请求 * 生成 PPT 请求
@ -302,7 +284,8 @@ public class WddPptApi {
String id, String id,
String templateId, String templateId,
String markdown String markdown
) { } ) {
}
// TODO @新要不写下类注释 // TODO @新要不写下类注释
@JsonInclude(value = JsonInclude.Include.NON_NULL) @JsonInclude(value = JsonInclude.Include.NON_NULL)
@ -323,7 +306,8 @@ public class WddPptApi {
LocalDateTime createTime, LocalDateTime createTime,
String createUser, String createUser,
String updateUser String updateUser
) { } ) {
}
// TODO @新要不写下类注释 // TODO @新要不写下类注释
@JsonInclude(value = JsonInclude.Include.NON_NULL) @JsonInclude(value = JsonInclude.Include.NON_NULL)
@ -339,7 +323,8 @@ public class WddPptApi {
String category, String category,
String style, String style,
String themeColor String themeColor
) { } ) {
}
} }
@ -348,7 +333,8 @@ public class WddPptApi {
public record PagePptTemplateInfo( public record PagePptTemplateInfo(
List<PptTemplateInfo> data, List<PptTemplateInfo> data,
String total String total
) {} ) {
}
// TODO @新要不写下类注释 // TODO @新要不写下类注释
@ -380,6 +366,7 @@ public class WddPptApi {
LocalDateTime createTime, LocalDateTime createTime,
String createUser, String createUser,
String updateUser String updateUser
) { } ) {
}
} }

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.framework.ai.core.model.xinghuo.api; package cn.iocoder.yudao.framework.ai.core.model.xinghuo.api;
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -28,16 +29,16 @@ import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
// TODO @新要不改成 XunFeiPptApi
/** /**
* 讯飞智能 PPT 生成 API * 讯飞智能 PPT 生成 API
* *
* @see <a href="https://www.xfyun.cn/doc/spark/PPTv2.html">智能 PPT 生成 API</a>
*
* @author xiaoxin * @author xiaoxin
* @see <a href="https://www.xfyun.cn/doc/spark/PPTv2.html">智能 PPT 生成 API</a>
*/ */
@Slf4j @Slf4j
public class XunfeiPptApi { public class XunFeiPptApi {
public static final String BASE_URL = "https://zwapi.xfyun.cn/api/ppt/v2"; public static final String BASE_URL = "https://zwapi.xfyun.cn/api/ppt/v2";
@ -54,7 +55,7 @@ public class XunfeiPptApi {
}); });
// TODO @新是不是不用 baseUrl // TODO @新是不是不用 baseUrl
public XunfeiPptApi(String baseUrl, String appId, String apiSecret) { public XunFeiPptApi(String baseUrl, String appId, String apiSecret) {
// TODO @新建议增加 defaultheaders例如说 appid 之类的或者每个请求通过 headers customer 处理 // TODO @新建议增加 defaultheaders例如说 appid 之类的或者每个请求通过 headers customer 处理
this.webClient = WebClient.builder() this.webClient = WebClient.builder()
.baseUrl(baseUrl) .baseUrl(baseUrl)
@ -134,8 +135,7 @@ public class XunfeiPptApi {
SignatureInfo signInfo = getSignature(); SignatureInfo signInfo = getSignature();
Map<String, Object> requestBody = new HashMap<>(); Map<String, Object> requestBody = new HashMap<>();
requestBody.put("style", style); requestBody.put("style", style);
// TODO @新可以使用 ObjUtil.defaultIfNull requestBody.put("pageSize", ObjUtil.defaultIfNull(pageSize, 20));
requestBody.put("pageSize", pageSize != null ? pageSize : 10);
return this.webClient.post() return this.webClient.post()
.uri("/template/list") .uri("/template/list")
.header("appId", signInfo.appId) .header("appId", signInfo.appId)
@ -288,7 +288,8 @@ public class XunfeiPptApi {
String appId, String appId,
String timestamp, String timestamp,
String signature String signature
) { } ) {
}
/** /**
* 模板列表响应 * 模板列表响应
@ -300,7 +301,8 @@ public class XunfeiPptApi {
String desc, String desc,
Integer count, Integer count,
TemplatePageData data TemplatePageData data
) { } ) {
}
/** /**
* 模板列表数据 * 模板列表数据
@ -310,7 +312,8 @@ public class XunfeiPptApi {
String total, String total,
List<TemplateInfo> records, List<TemplateInfo> records,
Integer pageNum Integer pageNum
) { } ) {
}
/** /**
* 模板信息 * 模板信息
@ -324,7 +327,8 @@ public class XunfeiPptApi {
String industry, String industry,
String style, String style,
String detailImage String detailImage
) { } ) {
}
/** /**
* 创建响应 * 创建响应
@ -336,7 +340,8 @@ public class XunfeiPptApi {
String desc, String desc,
Integer count, Integer count,
CreateResponseData data CreateResponseData data
) { } ) {
}
/** /**
* 创建响应数据 * 创建响应数据
@ -348,7 +353,8 @@ public class XunfeiPptApi {
String title, String title,
String subTitle, String subTitle,
OutlineData outline OutlineData outline
) { } ) {
}
/** /**
* 大纲数据结构 * 大纲数据结构
@ -375,7 +381,8 @@ public class XunfeiPptApi {
@JsonInclude(value = JsonInclude.Include.NON_NULL) @JsonInclude(value = JsonInclude.Include.NON_NULL)
public record ChapterContent( public record ChapterContent(
String chapterTitle String chapterTitle
) { } ) {
}
} }
@ -397,7 +404,8 @@ public class XunfeiPptApi {
int code, int code,
String desc, String desc,
ProgressResponseData data ProgressResponseData data
) { } ) {
}
/** /**
* 进度响应数据 * 进度响应数据
@ -407,13 +415,12 @@ public class XunfeiPptApi {
int process, int process,
String pptId, String pptId,
String pptUrl, String pptUrl,
// TODO @新字段注释去掉 String pptStatus,
String pptStatus, // PPT构建状态building构建中done已完成build_failed生成失败 String aiImageStatus,
String aiImageStatus, // ai配图状态building构建中done已完成 String cardNoteStatus,
String cardNoteStatus, // 演讲备注状态building构建中done已完成 String errMsg,
String errMsg, // 生成PPT的失败信息 Integer totalPages,
Integer totalPages, // 生成PPT的总页数 Integer donePages
Integer donePages // 生成PPT的完成页数
) { ) {
/** /**
@ -480,6 +487,7 @@ public class XunfeiPptApi {
} }
// TODO @新这个可以用 lombok 简化么 // TODO @新这个可以用 lombok 简化么
/** /**
* 构建器类 * 构建器类
*/ */

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.framework.ai.ppt.wdd; package cn.iocoder.yudao.framework.ai.ppt.wdd;
import cn.iocoder.yudao.framework.ai.core.model.wenduoduo.api.WddPptApi; import cn.iocoder.yudao.framework.ai.core.model.wenduoduo.api.WenDuoDuoPptApi;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -10,13 +10,13 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
/** /**
* {@link WddPptApi} 集成测试 * {@link WenDuoDuoPptApi} 集成测试
* *
* @author xiaoxin * @author xiaoxin
*/ */
public class WddPptApiTests { public class WenDuoDuoPptApiTests {
private final WddPptApi wddPptApi = new WddPptApi("https://docmee.cn"); private final WenDuoDuoPptApi wenDuoDuoPptApi = new WenDuoDuoPptApi("https://docmee.cn");
private final String token = ""; // API Token private final String token = ""; // API Token
@ -25,9 +25,9 @@ public class WddPptApiTests {
public void testCreateApiToken() { public void testCreateApiToken() {
// 准备参数 // 准备参数
String apiKey = ""; String apiKey = "";
WddPptApi.CreateTokenRequest request = new WddPptApi.CreateTokenRequest(apiKey); WenDuoDuoPptApi.CreateTokenRequest request = new WenDuoDuoPptApi.CreateTokenRequest(apiKey);
// 调用方法 // 调用方法
String token = wddPptApi.createApiToken(request); String token = wenDuoDuoPptApi.createApiToken(request);
// 打印结果 // 打印结果
System.out.println(token); System.out.println(token);
} }
@ -38,7 +38,7 @@ public class WddPptApiTests {
@Test @Test
@Disabled @Disabled
public void testCreateTask() { public void testCreateTask() {
WddPptApi.ApiResponse apiResponse = wddPptApi.createTask(token, 1, "dify 介绍", null); WenDuoDuoPptApi.ApiResponse apiResponse = wenDuoDuoPptApi.createTask(token, 1, "dify 介绍", null);
System.out.println(apiResponse); System.out.println(apiResponse);
} }
@ -46,10 +46,10 @@ public class WddPptApiTests {
@Test // 创建大纲 @Test // 创建大纲
@Disabled @Disabled
public void testGenerateOutlineRequest() { public void testGenerateOutlineRequest() {
WddPptApi.CreateOutlineRequest request = new WddPptApi.CreateOutlineRequest( WenDuoDuoPptApi.CreateOutlineRequest request = new WenDuoDuoPptApi.CreateOutlineRequest(
"1901539019628613632", "medium", null, null, null, null); "1901539019628613632", "medium", null, null, null, null);
// 调用 // 调用
Flux<Map<String, Object>> flux = wddPptApi.createOutline(token, request); Flux<Map<String, Object>> flux = wenDuoDuoPptApi.createOutline(token, request);
StringBuffer contentBuffer = new StringBuffer(); StringBuffer contentBuffer = new StringBuffer();
flux.doOnNext(chunk -> { flux.doOnNext(chunk -> {
contentBuffer.append(chunk.get("text")); contentBuffer.append(chunk.get("text"));
@ -69,10 +69,10 @@ public class WddPptApiTests {
@Test @Test
@Disabled @Disabled
public void testUpdateOutlineRequest() { public void testUpdateOutlineRequest() {
WddPptApi.UpdateOutlineRequest request = new WddPptApi.UpdateOutlineRequest( WenDuoDuoPptApi.UpdateOutlineRequest request = new WenDuoDuoPptApi.UpdateOutlineRequest(
"1901539019628613632", TEST_OUT_LINE_CONTENT, "精简一点,三个章节即可"); "1901539019628613632", TEST_OUT_LINE_CONTENT, "精简一点,三个章节即可");
// 调用 // 调用
Flux<Map<String, Object>> flux = wddPptApi.updateOutline(token, request); Flux<Map<String, Object>> flux = wenDuoDuoPptApi.updateOutline(token, request);
StringBuffer contentBuffer = new StringBuffer(); StringBuffer contentBuffer = new StringBuffer();
flux.doOnNext(chunk -> { flux.doOnNext(chunk -> {
contentBuffer.append(chunk.get("text")); contentBuffer.append(chunk.get("text"));
@ -94,11 +94,11 @@ public class WddPptApiTests {
@Disabled @Disabled
public void testGetPptTemplatePage() { public void testGetPptTemplatePage() {
// 准备参数 // 准备参数
WddPptApi.TemplateQueryRequest.Filter filter = new WddPptApi.TemplateQueryRequest.Filter( WenDuoDuoPptApi.TemplateQueryRequest.Filter filter = new WenDuoDuoPptApi.TemplateQueryRequest.Filter(
1, null, null, null); 1, null, null, null);
WddPptApi.TemplateQueryRequest request = new WddPptApi.TemplateQueryRequest(1, 10, filter); WenDuoDuoPptApi.TemplateQueryRequest request = new WenDuoDuoPptApi.TemplateQueryRequest(1, 10, filter);
// 调用 // 调用
WddPptApi.PagePptTemplateInfo pptTemplatePage = wddPptApi.getTemplatePage(token, request); WenDuoDuoPptApi.PagePptTemplateInfo pptTemplatePage = wenDuoDuoPptApi.getTemplatePage(token, request);
// 打印结果 // 打印结果
System.out.println(pptTemplatePage); System.out.println(pptTemplatePage);
} }
@ -110,9 +110,9 @@ public class WddPptApiTests {
@Disabled @Disabled
public void testGeneratePptx() { public void testGeneratePptx() {
// 准备参数 // 准备参数
WddPptApi.CreatePptRequest request = new WddPptApi.CreatePptRequest("1901539019628613632", "1805081814809960448", TEST_OUT_LINE_CONTENT); WenDuoDuoPptApi.CreatePptRequest request = new WenDuoDuoPptApi.CreatePptRequest("1901539019628613632", "1805081814809960448", TEST_OUT_LINE_CONTENT);
// 调用 // 调用
WddPptApi.PptInfo pptInfo = wddPptApi.create(token, request); WenDuoDuoPptApi.PptInfo pptInfo = wenDuoDuoPptApi.create(token, request);
// 打印结果 // 打印结果
System.out.println(pptInfo); System.out.println(pptInfo);
} }

View File

@ -1,7 +1,7 @@
package cn.iocoder.yudao.framework.ai.ppt.xunfei; package cn.iocoder.yudao.framework.ai.ppt.xunfei;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.api.XunfeiPptApi; import cn.iocoder.yudao.framework.ai.core.model.xinghuo.api.XunFeiPptApi;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -11,17 +11,17 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.File; import java.io.File;
/** /**
* {@link XunfeiPptApi} 集成测试 * {@link XunFeiPptApi} 集成测试
* *
* @author xiaoxin * @author xiaoxin
*/ */
public class XunfeiPptApiTests { public class XunFeiPptApiTests {
// 讯飞 API 配置信息实际使用时请替换为您的应用信息 // 讯飞 API 配置信息实际使用时请替换为您的应用信息
private static final String APP_ID = ""; private static final String APP_ID = "";
private static final String API_SECRET = ""; private static final String API_SECRET = "";
private final XunfeiPptApi xunfeiPptApi = new XunfeiPptApi(XunfeiPptApi.BASE_URL, APP_ID, API_SECRET); private final XunFeiPptApi xunfeiPptApi = new XunFeiPptApi(XunFeiPptApi.BASE_URL, APP_ID, API_SECRET);
/** /**
* 获取 PPT 模板列表 * 获取 PPT 模板列表
@ -30,7 +30,7 @@ public class XunfeiPptApiTests {
@Disabled @Disabled
public void testGetTemplatePage() { public void testGetTemplatePage() {
// 调用方法 // 调用方法
XunfeiPptApi.TemplatePageResponse response = xunfeiPptApi.getTemplatePage("商务", 10); XunFeiPptApi.TemplatePageResponse response = xunfeiPptApi.getTemplatePage("商务", 10);
// 打印结果 // 打印结果
System.out.println("模板列表响应:" + JsonUtils.toJsonString(response)); System.out.println("模板列表响应:" + JsonUtils.toJsonString(response));
@ -41,7 +41,7 @@ public class XunfeiPptApiTests {
// 打印第一个模板的信息如果存在 // 打印第一个模板的信息如果存在
if (!response.data().records().isEmpty()) { if (!response.data().records().isEmpty()) {
XunfeiPptApi.TemplateInfo firstTemplate = response.data().records().get(0); XunFeiPptApi.TemplateInfo firstTemplate = response.data().records().get(0);
System.out.println("模板ID" + firstTemplate.templateIndexId()); System.out.println("模板ID" + firstTemplate.templateIndexId());
System.out.println("模板风格:" + firstTemplate.style()); System.out.println("模板风格:" + firstTemplate.style());
System.out.println("模板颜色:" + firstTemplate.color()); System.out.println("模板颜色:" + firstTemplate.color());
@ -56,7 +56,7 @@ public class XunfeiPptApiTests {
@Test @Test
@Disabled @Disabled
public void testCreateOutline() { public void testCreateOutline() {
XunfeiPptApi.CreateResponse response = getCreateResponse(); XunFeiPptApi.CreateResponse response = getCreateResponse();
// 打印结果 // 打印结果
System.out.println("创建大纲响应:" + JsonUtils.toJsonString(response)); System.out.println("创建大纲响应:" + JsonUtils.toJsonString(response));
@ -77,7 +77,7 @@ public class XunfeiPptApiTests {
* 创建大纲通过文本 * 创建大纲通过文本
* @return 创建大纲响应 * @return 创建大纲响应
*/ */
private XunfeiPptApi.CreateResponse getCreateResponse() { private XunFeiPptApi.CreateResponse getCreateResponse() {
String param = "智能体平台 Dify 介绍"; String param = "智能体平台 Dify 介绍";
return xunfeiPptApi.createOutline(param); return xunfeiPptApi.createOutline(param);
} }
@ -89,9 +89,9 @@ public class XunfeiPptApiTests {
@Disabled @Disabled
public void testCreatePptByOutlineWithFullParams() { public void testCreatePptByOutlineWithFullParams() {
// 创建大纲对象 // 创建大纲对象
XunfeiPptApi.CreateResponse createResponse = getCreateResponse(); XunFeiPptApi.CreateResponse createResponse = getCreateResponse();
// 调用方法 // 调用方法
XunfeiPptApi.CreateResponse response = xunfeiPptApi.createPptByOutline(createResponse.data().outline(), "精简一些不要超过6个章节"); XunFeiPptApi.CreateResponse response = xunfeiPptApi.createPptByOutline(createResponse.data().outline(), "精简一些不要超过6个章节");
// 打印结果 // 打印结果
System.out.println("通过大纲创建 PPT 响应:" + JsonUtils.toJsonString(response)); System.out.println("通过大纲创建 PPT 响应:" + JsonUtils.toJsonString(response));
@ -114,13 +114,13 @@ public class XunfeiPptApiTests {
String sid = "e96dac09f2ec4ee289f029a5fb874ecd"; // 替换为实际的sid String sid = "e96dac09f2ec4ee289f029a5fb874ecd"; // 替换为实际的sid
// 调用方法 // 调用方法
XunfeiPptApi.ProgressResponse response = xunfeiPptApi.checkProgress(sid); XunFeiPptApi.ProgressResponse response = xunfeiPptApi.checkProgress(sid);
// 打印结果 // 打印结果
System.out.println("检查进度响应:" + JsonUtils.toJsonString(response)); System.out.println("检查进度响应:" + JsonUtils.toJsonString(response));
// 安全地访问响应数据 // 安全地访问响应数据
if (response != null && response.data() != null) { if (response != null && response.data() != null) {
XunfeiPptApi.ProgressResponseData data = response.data(); XunFeiPptApi.ProgressResponseData data = response.data();
// 打印PPT生成状态 // 打印PPT生成状态
System.out.println("PPT 构建状态: " + data.pptStatus()); System.out.println("PPT 构建状态: " + data.pptStatus());
@ -171,11 +171,11 @@ public class XunfeiPptApiTests {
System.out.println("" + (i + 1) + "次查询进度..."); System.out.println("" + (i + 1) + "次查询进度...");
// 调用方法 // 调用方法
XunfeiPptApi.ProgressResponse response = xunfeiPptApi.checkProgress(sid); XunFeiPptApi.ProgressResponse response = xunfeiPptApi.checkProgress(sid);
// 安全地访问响应数据 // 安全地访问响应数据
if (response != null && response.data() != null) { if (response != null && response.data() != null) {
XunfeiPptApi.ProgressResponseData data = response.data(); XunFeiPptApi.ProgressResponseData data = response.data();
// 打印进度信息 // 打印进度信息
System.out.println("PPT 构建状态: " + data.pptStatus()); System.out.println("PPT 构建状态: " + data.pptStatus());
@ -218,7 +218,7 @@ public class XunfeiPptApiTests {
String query = "合肥天气趋势分析包括近5年的气温变化、降水量变化、极端天气事件以及对城市生活的影响"; String query = "合肥天气趋势分析包括近5年的气温变化、降水量变化、极端天气事件以及对城市生活的影响";
// 调用方法 // 调用方法
XunfeiPptApi.CreateResponse response = xunfeiPptApi.create(query); XunFeiPptApi.CreateResponse response = xunfeiPptApi.create(query);
// 打印结果 // 打印结果
System.out.println("直接创建 PPT 响应:" + JsonUtils.toJsonString(response)); System.out.println("直接创建 PPT 响应:" + JsonUtils.toJsonString(response));
@ -244,7 +244,7 @@ public class XunfeiPptApiTests {
MultipartFile multipartFile = convertFileToMultipartFile(file); MultipartFile multipartFile = convertFileToMultipartFile(file);
// 调用方法 // 调用方法
XunfeiPptApi.CreateResponse response = xunfeiPptApi.create(multipartFile, file.getName()); XunFeiPptApi.CreateResponse response = xunfeiPptApi.create(multipartFile, file.getName());
// 打印结果 // 打印结果
System.out.println("通过文件创建PPT响应" + JsonUtils.toJsonString(response)); System.out.println("通过文件创建PPT响应" + JsonUtils.toJsonString(response));
@ -269,7 +269,7 @@ public class XunfeiPptApiTests {
String query = "合肥天气趋势分析,包括近 5 年的气温变化、降水量变化、极端天气事件,以及对城市生活的影响"; String query = "合肥天气趋势分析,包括近 5 年的气温变化、降水量变化、极端天气事件,以及对城市生活的影响";
// 创建请求对象 // 创建请求对象
XunfeiPptApi.CreatePptRequest request = XunfeiPptApi.CreatePptRequest.builder() XunFeiPptApi.CreatePptRequest request = XunFeiPptApi.CreatePptRequest.builder()
.query(query) .query(query)
.language("cn") .language("cn")
.isCardNote(true) .isCardNote(true)
@ -280,7 +280,7 @@ public class XunfeiPptApiTests {
.build(); .build();
// 调用方法 // 调用方法
XunfeiPptApi.CreateResponse response = xunfeiPptApi.create(request); XunFeiPptApi.CreateResponse response = xunfeiPptApi.create(request);
// 打印结果 // 打印结果
System.out.println("使用完整参数创建 PPT 响应:" + JsonUtils.toJsonString(response)); System.out.println("使用完整参数创建 PPT 响应:" + JsonUtils.toJsonString(response));
@ -296,9 +296,9 @@ public class XunfeiPptApiTests {
// 立即查询一次进度 // 立即查询一次进度
System.out.println("立即查询进度..."); System.out.println("立即查询进度...");
XunfeiPptApi.ProgressResponse progressResponse = xunfeiPptApi.checkProgress(sid); XunFeiPptApi.ProgressResponse progressResponse = xunfeiPptApi.checkProgress(sid);
if (progressResponse != null && progressResponse.data() != null) { if (progressResponse != null && progressResponse.data() != null) {
XunfeiPptApi.ProgressResponseData progressData = progressResponse.data(); XunFeiPptApi.ProgressResponseData progressData = progressResponse.data();
System.out.println("PPT 构建状态: " + progressData.pptStatus()); System.out.println("PPT 构建状态: " + progressData.pptStatus());
if (progressData.totalPages() != null && progressData.donePages() != null) { if (progressData.totalPages() != null && progressData.donePages() != null) {
System.out.println("完成进度: " + progressData.donePages() + "/" + progressData.totalPages() System.out.println("完成进度: " + progressData.donePages() + "/" + progressData.totalPages()