Commit 270fea0c5dc736a5733611d27f4a4a8783ddfe67
1 parent
acf68b1c
【解决 TODO 】AI PPT:解决一些 TODO
Showing
4 changed files
with
89 additions
and
94 deletions
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/wenduoduo/api/WddPptApi.java renamed to yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/wenduoduo/api/WenDuoDuoPptApi.java
| ... | ... | @@ -24,16 +24,15 @@ import java.util.Objects; |
| 24 | 24 | import java.util.function.Function; |
| 25 | 25 | import java.util.function.Predicate; |
| 26 | 26 | |
| 27 | -// TODO @新:要不改成 WenDuoDuoPptApi | |
| 27 | + | |
| 28 | 28 | /** |
| 29 | 29 | * 文多多 API |
| 30 | 30 | * |
| 31 | - * @see <a href="https://docmee.cn/open-platform/api">PPT 生成 API</a> | |
| 32 | - * | |
| 33 | 31 | * @author xiaoxin |
| 32 | + * @see <a href="https://docmee.cn/open-platform/api">PPT 生成 API</a> | |
| 34 | 33 | */ |
| 35 | 34 | @Slf4j |
| 36 | -public class WddPptApi { | |
| 35 | +public class WenDuoDuoPptApi { | |
| 37 | 36 | |
| 38 | 37 | public static final String BASE_URL = "https://docmee.cn"; |
| 39 | 38 | |
| ... | ... | @@ -50,7 +49,7 @@ public class WddPptApi { |
| 50 | 49 | }); |
| 51 | 50 | |
| 52 | 51 | // TODO @新:是不是不用 baseUrl 哈 |
| 53 | - public WddPptApi(String baseUrl) { | |
| 52 | + public WenDuoDuoPptApi(String baseUrl) { | |
| 54 | 53 | this.webClient = WebClient.builder() |
| 55 | 54 | .baseUrl(baseUrl) |
| 56 | 55 | // TODO @新:建议,token 作为 defaultHeader |
| ... | ... | @@ -82,35 +81,14 @@ public class WddPptApi { |
| 82 | 81 | .block(); |
| 83 | 82 | } |
| 84 | 83 | |
| 85 | - // TODO @xin:是不是给个 API 连接,这样 type、content、files 都不用写注释太细了 | |
| 86 | 84 | /** |
| 87 | 85 | * 创建任务 |
| 88 | 86 | * |
| 89 | 87 | * @param type 类型 |
| 90 | - * 1.智能生成(主题、要求) | |
| 91 | - * 2.上传文件生成 | |
| 92 | - * 3.上传思维导图生成 | |
| 93 | - * 4.通过word精准转ppt | |
| 94 | - * 5.通过网页链接生成 | |
| 95 | - * 6.粘贴文本内容生成 | |
| 96 | - * 7.Markdown大纲生成 | |
| 97 | 88 | * @param content 内容 |
| 98 | - * type=1 用户输入主题或要求(不超过1000字符) | |
| 99 | - * type=2、4 不传 | |
| 100 | - * type=3 幕布等分享链接 | |
| 101 | - * type=5 网页链接地址(http/https) | |
| 102 | - * type=6 粘贴文本内容(不超过20000字符) | |
| 103 | - * type=7 大纲内容(markdown) | |
| 104 | 89 | * @param files 文件列表 |
| 105 | - * 文件列表(文件数不超过5个,总大小不超过50M): | |
| 106 | - * type=1 上传参考文件(非必传,支持多个) | |
| 107 | - * type=2 上传文件(支持多个) | |
| 108 | - * type=3 上传思维导图(xmind/mm/md)(仅支持一个) | |
| 109 | - * type=4 上传word文件(仅支持一个) | |
| 110 | - * type=5、6、7 不传 | |
| 111 | - * <p> | |
| 112 | - * 支持格式:doc/docx/pdf/ppt/pptx/txt/md/xls/xlsx/csv/html/epub/mobi/xmind/mm | |
| 113 | 90 | * @return 任务ID |
| 91 | + * @see <a href="https://docmee.cn/open-platform/api#%E5%88%9B%E5%BB%BA%E4%BB%BB%E5%8A%A1">创建任务</a> | |
| 114 | 92 | */ |
| 115 | 93 | public ApiResponse createTask(String token, Integer type, String content, List<MultipartFile> files) { |
| 116 | 94 | MultiValueMap<String, Object> formData = new LinkedMultiValueMap<>(); |
| ... | ... | @@ -258,7 +236,8 @@ public class WddPptApi { |
| 258 | 236 | Integer code, |
| 259 | 237 | String message, |
| 260 | 238 | Map<String, Object> data |
| 261 | - ) { } | |
| 239 | + ) { | |
| 240 | + } | |
| 262 | 241 | |
| 263 | 242 | /** |
| 264 | 243 | * 创建任务 |
| ... | ... | @@ -268,7 +247,8 @@ public class WddPptApi { |
| 268 | 247 | Integer type, |
| 269 | 248 | String content, |
| 270 | 249 | List<MultipartFile> files |
| 271 | - ) { } | |
| 250 | + ) { | |
| 251 | + } | |
| 272 | 252 | |
| 273 | 253 | /** |
| 274 | 254 | * 生成大纲内容请求 |
| ... | ... | @@ -281,7 +261,8 @@ public class WddPptApi { |
| 281 | 261 | String audience, |
| 282 | 262 | String lang, |
| 283 | 263 | String prompt |
| 284 | - ) { } | |
| 264 | + ) { | |
| 265 | + } | |
| 285 | 266 | |
| 286 | 267 | /** |
| 287 | 268 | * 修改大纲内容请求 |
| ... | ... | @@ -291,7 +272,8 @@ public class WddPptApi { |
| 291 | 272 | String id, |
| 292 | 273 | String markdown, |
| 293 | 274 | String question |
| 294 | - ) { } | |
| 275 | + ) { | |
| 276 | + } | |
| 295 | 277 | |
| 296 | 278 | /** |
| 297 | 279 | * 生成 PPT 请求 |
| ... | ... | @@ -302,7 +284,8 @@ public class WddPptApi { |
| 302 | 284 | String id, |
| 303 | 285 | String templateId, |
| 304 | 286 | String markdown |
| 305 | - ) { } | |
| 287 | + ) { | |
| 288 | + } | |
| 306 | 289 | |
| 307 | 290 | // TODO @新:要不写下类注释 |
| 308 | 291 | @JsonInclude(value = JsonInclude.Include.NON_NULL) |
| ... | ... | @@ -323,7 +306,8 @@ public class WddPptApi { |
| 323 | 306 | LocalDateTime createTime, |
| 324 | 307 | String createUser, |
| 325 | 308 | String updateUser |
| 326 | - ) { } | |
| 309 | + ) { | |
| 310 | + } | |
| 327 | 311 | |
| 328 | 312 | // TODO @新:要不写下类注释 |
| 329 | 313 | @JsonInclude(value = JsonInclude.Include.NON_NULL) |
| ... | ... | @@ -339,7 +323,8 @@ public class WddPptApi { |
| 339 | 323 | String category, |
| 340 | 324 | String style, |
| 341 | 325 | String themeColor |
| 342 | - ) { } | |
| 326 | + ) { | |
| 327 | + } | |
| 343 | 328 | |
| 344 | 329 | } |
| 345 | 330 | |
| ... | ... | @@ -348,7 +333,8 @@ public class WddPptApi { |
| 348 | 333 | public record PagePptTemplateInfo( |
| 349 | 334 | List<PptTemplateInfo> data, |
| 350 | 335 | String total |
| 351 | - ) {} | |
| 336 | + ) { | |
| 337 | + } | |
| 352 | 338 | |
| 353 | 339 | |
| 354 | 340 | // TODO @新:要不写下类注释 |
| ... | ... | @@ -380,6 +366,7 @@ public class WddPptApi { |
| 380 | 366 | LocalDateTime createTime, |
| 381 | 367 | String createUser, |
| 382 | 368 | String updateUser |
| 383 | - ) { } | |
| 369 | + ) { | |
| 370 | + } | |
| 384 | 371 | |
| 385 | 372 | } |
| 386 | 373 | \ No newline at end of file | ... | ... |
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/xinghuo/api/XunfeiPptApi.java renamed to yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/model/xinghuo/api/XunFeiPptApi.java
| 1 | 1 | package cn.iocoder.yudao.framework.ai.core.model.xinghuo.api; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.util.ObjUtil; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 4 | 5 | import com.fasterxml.jackson.annotation.JsonInclude; |
| 5 | 6 | import lombok.extern.slf4j.Slf4j; |
| ... | ... | @@ -28,16 +29,16 @@ import java.util.Map; |
| 28 | 29 | import java.util.function.Function; |
| 29 | 30 | import java.util.function.Predicate; |
| 30 | 31 | |
| 31 | -// TODO @新:要不改成 XunFeiPptApi | |
| 32 | + | |
| 33 | + | |
| 32 | 34 | /** |
| 33 | 35 | * 讯飞智能 PPT 生成 API |
| 34 | 36 | * |
| 35 | - * @see <a href="https://www.xfyun.cn/doc/spark/PPTv2.html">智能 PPT 生成 API</a> | |
| 36 | - * | |
| 37 | 37 | * @author xiaoxin |
| 38 | + * @see <a href="https://www.xfyun.cn/doc/spark/PPTv2.html">智能 PPT 生成 API</a> | |
| 38 | 39 | */ |
| 39 | 40 | @Slf4j |
| 40 | -public class XunfeiPptApi { | |
| 41 | +public class XunFeiPptApi { | |
| 41 | 42 | |
| 42 | 43 | public static final String BASE_URL = "https://zwapi.xfyun.cn/api/ppt/v2"; |
| 43 | 44 | |
| ... | ... | @@ -54,7 +55,7 @@ public class XunfeiPptApi { |
| 54 | 55 | }); |
| 55 | 56 | |
| 56 | 57 | // TODO @新:是不是不用 baseUrl 哈 |
| 57 | - public XunfeiPptApi(String baseUrl, String appId, String apiSecret) { | |
| 58 | + public XunFeiPptApi(String baseUrl, String appId, String apiSecret) { | |
| 58 | 59 | // TODO @新:建议,增加 defaultheaders,例如说 appid 之类的;或者每个请求,通过 headers customer 处理。 |
| 59 | 60 | this.webClient = WebClient.builder() |
| 60 | 61 | .baseUrl(baseUrl) |
| ... | ... | @@ -134,8 +135,7 @@ public class XunfeiPptApi { |
| 134 | 135 | SignatureInfo signInfo = getSignature(); |
| 135 | 136 | Map<String, Object> requestBody = new HashMap<>(); |
| 136 | 137 | requestBody.put("style", style); |
| 137 | - // TODO @新:可以使用 ObjUtil.defaultIfNull | |
| 138 | - requestBody.put("pageSize", pageSize != null ? pageSize : 10); | |
| 138 | + requestBody.put("pageSize", ObjUtil.defaultIfNull(pageSize, 20)); | |
| 139 | 139 | return this.webClient.post() |
| 140 | 140 | .uri("/template/list") |
| 141 | 141 | .header("appId", signInfo.appId) |
| ... | ... | @@ -288,7 +288,8 @@ public class XunfeiPptApi { |
| 288 | 288 | String appId, |
| 289 | 289 | String timestamp, |
| 290 | 290 | String signature |
| 291 | - ) { } | |
| 291 | + ) { | |
| 292 | + } | |
| 292 | 293 | |
| 293 | 294 | /** |
| 294 | 295 | * 模板列表响应 |
| ... | ... | @@ -300,7 +301,8 @@ public class XunfeiPptApi { |
| 300 | 301 | String desc, |
| 301 | 302 | Integer count, |
| 302 | 303 | TemplatePageData data |
| 303 | - ) { } | |
| 304 | + ) { | |
| 305 | + } | |
| 304 | 306 | |
| 305 | 307 | /** |
| 306 | 308 | * 模板列表数据 |
| ... | ... | @@ -310,7 +312,8 @@ public class XunfeiPptApi { |
| 310 | 312 | String total, |
| 311 | 313 | List<TemplateInfo> records, |
| 312 | 314 | Integer pageNum |
| 313 | - ) { } | |
| 315 | + ) { | |
| 316 | + } | |
| 314 | 317 | |
| 315 | 318 | /** |
| 316 | 319 | * 模板信息 |
| ... | ... | @@ -324,7 +327,8 @@ public class XunfeiPptApi { |
| 324 | 327 | String industry, |
| 325 | 328 | String style, |
| 326 | 329 | String detailImage |
| 327 | - ) { } | |
| 330 | + ) { | |
| 331 | + } | |
| 328 | 332 | |
| 329 | 333 | /** |
| 330 | 334 | * 创建响应 |
| ... | ... | @@ -336,7 +340,8 @@ public class XunfeiPptApi { |
| 336 | 340 | String desc, |
| 337 | 341 | Integer count, |
| 338 | 342 | CreateResponseData data |
| 339 | - ) { } | |
| 343 | + ) { | |
| 344 | + } | |
| 340 | 345 | |
| 341 | 346 | /** |
| 342 | 347 | * 创建响应数据 |
| ... | ... | @@ -348,7 +353,8 @@ public class XunfeiPptApi { |
| 348 | 353 | String title, |
| 349 | 354 | String subTitle, |
| 350 | 355 | OutlineData outline |
| 351 | - ) { } | |
| 356 | + ) { | |
| 357 | + } | |
| 352 | 358 | |
| 353 | 359 | /** |
| 354 | 360 | * 大纲数据结构 |
| ... | ... | @@ -375,7 +381,8 @@ public class XunfeiPptApi { |
| 375 | 381 | @JsonInclude(value = JsonInclude.Include.NON_NULL) |
| 376 | 382 | public record ChapterContent( |
| 377 | 383 | String chapterTitle |
| 378 | - ) { } | |
| 384 | + ) { | |
| 385 | + } | |
| 379 | 386 | |
| 380 | 387 | } |
| 381 | 388 | |
| ... | ... | @@ -397,7 +404,8 @@ public class XunfeiPptApi { |
| 397 | 404 | int code, |
| 398 | 405 | String desc, |
| 399 | 406 | ProgressResponseData data |
| 400 | - ) { } | |
| 407 | + ) { | |
| 408 | + } | |
| 401 | 409 | |
| 402 | 410 | /** |
| 403 | 411 | * 进度响应数据 |
| ... | ... | @@ -407,13 +415,12 @@ public class XunfeiPptApi { |
| 407 | 415 | int process, |
| 408 | 416 | String pptId, |
| 409 | 417 | String pptUrl, |
| 410 | - // TODO @新:字段注释,去掉 | |
| 411 | - String pptStatus, // PPT构建状态:building(构建中),done(已完成),build_failed(生成失败) | |
| 412 | - String aiImageStatus, // ai配图状态:building(构建中),done(已完成) | |
| 413 | - String cardNoteStatus, // 演讲备注状态:building(构建中),done(已完成) | |
| 414 | - String errMsg, // 生成PPT的失败信息 | |
| 415 | - Integer totalPages, // 生成PPT的总页数 | |
| 416 | - Integer donePages // 生成PPT的完成页数 | |
| 418 | + String pptStatus, | |
| 419 | + String aiImageStatus, | |
| 420 | + String cardNoteStatus, | |
| 421 | + String errMsg, | |
| 422 | + Integer totalPages, | |
| 423 | + Integer donePages | |
| 417 | 424 | ) { |
| 418 | 425 | |
| 419 | 426 | /** |
| ... | ... | @@ -480,6 +487,7 @@ public class XunfeiPptApi { |
| 480 | 487 | } |
| 481 | 488 | |
| 482 | 489 | // TODO @新:这个可以用 lombok 简化么? |
| 490 | + | |
| 483 | 491 | /** |
| 484 | 492 | * 构建器类 |
| 485 | 493 | */ | ... | ... |
yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/ppt/wdd/WddPptApiTests.java renamed to yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/ppt/wdd/WenDuoDuoPptApiTests.java
| 1 | 1 | package cn.iocoder.yudao.framework.ai.ppt.wdd; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.ai.core.model.wenduoduo.api.WddPptApi; | |
| 3 | +import cn.iocoder.yudao.framework.ai.core.model.wenduoduo.api.WenDuoDuoPptApi; | |
| 4 | 4 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 5 | 5 | import org.junit.jupiter.api.Disabled; |
| 6 | 6 | import org.junit.jupiter.api.Test; |
| ... | ... | @@ -10,13 +10,13 @@ import java.util.Map; |
| 10 | 10 | import java.util.Objects; |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | - * {@link WddPptApi} 集成测试 | |
| 13 | + * {@link WenDuoDuoPptApi} 集成测试 | |
| 14 | 14 | * |
| 15 | 15 | * @author xiaoxin |
| 16 | 16 | */ |
| 17 | -public class WddPptApiTests { | |
| 17 | +public class WenDuoDuoPptApiTests { | |
| 18 | 18 | |
| 19 | - private final WddPptApi wddPptApi = new WddPptApi("https://docmee.cn"); | |
| 19 | + private final WenDuoDuoPptApi wenDuoDuoPptApi = new WenDuoDuoPptApi("https://docmee.cn"); | |
| 20 | 20 | |
| 21 | 21 | private final String token = ""; // API Token |
| 22 | 22 | |
| ... | ... | @@ -25,9 +25,9 @@ public class WddPptApiTests { |
| 25 | 25 | public void testCreateApiToken() { |
| 26 | 26 | // 准备参数 |
| 27 | 27 | String apiKey = ""; |
| 28 | - WddPptApi.CreateTokenRequest request = new WddPptApi.CreateTokenRequest(apiKey); | |
| 28 | + WenDuoDuoPptApi.CreateTokenRequest request = new WenDuoDuoPptApi.CreateTokenRequest(apiKey); | |
| 29 | 29 | // 调用方法 |
| 30 | - String token = wddPptApi.createApiToken(request); | |
| 30 | + String token = wenDuoDuoPptApi.createApiToken(request); | |
| 31 | 31 | // 打印结果 |
| 32 | 32 | System.out.println(token); |
| 33 | 33 | } |
| ... | ... | @@ -38,7 +38,7 @@ public class WddPptApiTests { |
| 38 | 38 | @Test |
| 39 | 39 | @Disabled |
| 40 | 40 | public void testCreateTask() { |
| 41 | - WddPptApi.ApiResponse apiResponse = wddPptApi.createTask(token, 1, "dify 介绍", null); | |
| 41 | + WenDuoDuoPptApi.ApiResponse apiResponse = wenDuoDuoPptApi.createTask(token, 1, "dify 介绍", null); | |
| 42 | 42 | System.out.println(apiResponse); |
| 43 | 43 | } |
| 44 | 44 | |
| ... | ... | @@ -46,10 +46,10 @@ public class WddPptApiTests { |
| 46 | 46 | @Test // 创建大纲 |
| 47 | 47 | @Disabled |
| 48 | 48 | public void testGenerateOutlineRequest() { |
| 49 | - WddPptApi.CreateOutlineRequest request = new WddPptApi.CreateOutlineRequest( | |
| 49 | + WenDuoDuoPptApi.CreateOutlineRequest request = new WenDuoDuoPptApi.CreateOutlineRequest( | |
| 50 | 50 | "1901539019628613632", "medium", null, null, null, null); |
| 51 | 51 | // 调用 |
| 52 | - Flux<Map<String, Object>> flux = wddPptApi.createOutline(token, request); | |
| 52 | + Flux<Map<String, Object>> flux = wenDuoDuoPptApi.createOutline(token, request); | |
| 53 | 53 | StringBuffer contentBuffer = new StringBuffer(); |
| 54 | 54 | flux.doOnNext(chunk -> { |
| 55 | 55 | contentBuffer.append(chunk.get("text")); |
| ... | ... | @@ -69,10 +69,10 @@ public class WddPptApiTests { |
| 69 | 69 | @Test |
| 70 | 70 | @Disabled |
| 71 | 71 | public void testUpdateOutlineRequest() { |
| 72 | - WddPptApi.UpdateOutlineRequest request = new WddPptApi.UpdateOutlineRequest( | |
| 72 | + WenDuoDuoPptApi.UpdateOutlineRequest request = new WenDuoDuoPptApi.UpdateOutlineRequest( | |
| 73 | 73 | "1901539019628613632", TEST_OUT_LINE_CONTENT, "精简一点,三个章节即可"); |
| 74 | 74 | // 调用 |
| 75 | - Flux<Map<String, Object>> flux = wddPptApi.updateOutline(token, request); | |
| 75 | + Flux<Map<String, Object>> flux = wenDuoDuoPptApi.updateOutline(token, request); | |
| 76 | 76 | StringBuffer contentBuffer = new StringBuffer(); |
| 77 | 77 | flux.doOnNext(chunk -> { |
| 78 | 78 | contentBuffer.append(chunk.get("text")); |
| ... | ... | @@ -94,11 +94,11 @@ public class WddPptApiTests { |
| 94 | 94 | @Disabled |
| 95 | 95 | public void testGetPptTemplatePage() { |
| 96 | 96 | // 准备参数 |
| 97 | - WddPptApi.TemplateQueryRequest.Filter filter = new WddPptApi.TemplateQueryRequest.Filter( | |
| 97 | + WenDuoDuoPptApi.TemplateQueryRequest.Filter filter = new WenDuoDuoPptApi.TemplateQueryRequest.Filter( | |
| 98 | 98 | 1, null, null, null); |
| 99 | - WddPptApi.TemplateQueryRequest request = new WddPptApi.TemplateQueryRequest(1, 10, filter); | |
| 99 | + WenDuoDuoPptApi.TemplateQueryRequest request = new WenDuoDuoPptApi.TemplateQueryRequest(1, 10, filter); | |
| 100 | 100 | // 调用 |
| 101 | - WddPptApi.PagePptTemplateInfo pptTemplatePage = wddPptApi.getTemplatePage(token, request); | |
| 101 | + WenDuoDuoPptApi.PagePptTemplateInfo pptTemplatePage = wenDuoDuoPptApi.getTemplatePage(token, request); | |
| 102 | 102 | // 打印结果 |
| 103 | 103 | System.out.println(pptTemplatePage); |
| 104 | 104 | } |
| ... | ... | @@ -110,9 +110,9 @@ public class WddPptApiTests { |
| 110 | 110 | @Disabled |
| 111 | 111 | public void testGeneratePptx() { |
| 112 | 112 | // 准备参数 |
| 113 | - WddPptApi.CreatePptRequest request = new WddPptApi.CreatePptRequest("1901539019628613632", "1805081814809960448", TEST_OUT_LINE_CONTENT); | |
| 113 | + WenDuoDuoPptApi.CreatePptRequest request = new WenDuoDuoPptApi.CreatePptRequest("1901539019628613632", "1805081814809960448", TEST_OUT_LINE_CONTENT); | |
| 114 | 114 | // 调用 |
| 115 | - WddPptApi.PptInfo pptInfo = wddPptApi.create(token, request); | |
| 115 | + WenDuoDuoPptApi.PptInfo pptInfo = wenDuoDuoPptApi.create(token, request); | |
| 116 | 116 | // 打印结果 |
| 117 | 117 | System.out.println(pptInfo); |
| 118 | 118 | } | ... | ... |
yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/ppt/xunfei/XunfeiPptApiTests.java renamed to yudao-module-ai/yudao-spring-boot-starter-ai/src/test/java/cn/iocoder/yudao/framework/ai/ppt/xunfei/XunFeiPptApiTests.java
| 1 | 1 | package cn.iocoder.yudao.framework.ai.ppt.xunfei; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.io.FileUtil; |
| 4 | -import cn.iocoder.yudao.framework.ai.core.model.xinghuo.api.XunfeiPptApi; | |
| 4 | +import cn.iocoder.yudao.framework.ai.core.model.xinghuo.api.XunFeiPptApi; | |
| 5 | 5 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 6 | 6 | import org.junit.jupiter.api.Disabled; |
| 7 | 7 | import org.junit.jupiter.api.Test; |
| ... | ... | @@ -11,17 +11,17 @@ import org.springframework.web.multipart.MultipartFile; |
| 11 | 11 | import java.io.File; |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * {@link XunfeiPptApi} 集成测试 | |
| 14 | + * {@link XunFeiPptApi} 集成测试 | |
| 15 | 15 | * |
| 16 | 16 | * @author xiaoxin |
| 17 | 17 | */ |
| 18 | -public class XunfeiPptApiTests { | |
| 18 | +public class XunFeiPptApiTests { | |
| 19 | 19 | |
| 20 | 20 | // 讯飞 API 配置信息,实际使用时请替换为您的应用信息 |
| 21 | 21 | private static final String APP_ID = ""; |
| 22 | 22 | private static final String API_SECRET = ""; |
| 23 | 23 | |
| 24 | - private final XunfeiPptApi xunfeiPptApi = new XunfeiPptApi(XunfeiPptApi.BASE_URL, APP_ID, API_SECRET); | |
| 24 | + private final XunFeiPptApi xunfeiPptApi = new XunFeiPptApi(XunFeiPptApi.BASE_URL, APP_ID, API_SECRET); | |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * 获取 PPT 模板列表 |
| ... | ... | @@ -30,7 +30,7 @@ public class XunfeiPptApiTests { |
| 30 | 30 | @Disabled |
| 31 | 31 | public void testGetTemplatePage() { |
| 32 | 32 | // 调用方法 |
| 33 | - XunfeiPptApi.TemplatePageResponse response = xunfeiPptApi.getTemplatePage("商务", 10); | |
| 33 | + XunFeiPptApi.TemplatePageResponse response = xunfeiPptApi.getTemplatePage("商务", 10); | |
| 34 | 34 | // 打印结果 |
| 35 | 35 | System.out.println("模板列表响应:" + JsonUtils.toJsonString(response)); |
| 36 | 36 | |
| ... | ... | @@ -41,7 +41,7 @@ public class XunfeiPptApiTests { |
| 41 | 41 | |
| 42 | 42 | // 打印第一个模板的信息(如果存在) |
| 43 | 43 | if (!response.data().records().isEmpty()) { |
| 44 | - XunfeiPptApi.TemplateInfo firstTemplate = response.data().records().get(0); | |
| 44 | + XunFeiPptApi.TemplateInfo firstTemplate = response.data().records().get(0); | |
| 45 | 45 | System.out.println("模板ID:" + firstTemplate.templateIndexId()); |
| 46 | 46 | System.out.println("模板风格:" + firstTemplate.style()); |
| 47 | 47 | System.out.println("模板颜色:" + firstTemplate.color()); |
| ... | ... | @@ -56,7 +56,7 @@ public class XunfeiPptApiTests { |
| 56 | 56 | @Test |
| 57 | 57 | @Disabled |
| 58 | 58 | public void testCreateOutline() { |
| 59 | - XunfeiPptApi.CreateResponse response = getCreateResponse(); | |
| 59 | + XunFeiPptApi.CreateResponse response = getCreateResponse(); | |
| 60 | 60 | // 打印结果 |
| 61 | 61 | System.out.println("创建大纲响应:" + JsonUtils.toJsonString(response)); |
| 62 | 62 | |
| ... | ... | @@ -77,7 +77,7 @@ public class XunfeiPptApiTests { |
| 77 | 77 | * 创建大纲(通过文本) |
| 78 | 78 | * @return 创建大纲响应 |
| 79 | 79 | */ |
| 80 | - private XunfeiPptApi.CreateResponse getCreateResponse() { | |
| 80 | + private XunFeiPptApi.CreateResponse getCreateResponse() { | |
| 81 | 81 | String param = "智能体平台 Dify 介绍"; |
| 82 | 82 | return xunfeiPptApi.createOutline(param); |
| 83 | 83 | } |
| ... | ... | @@ -89,9 +89,9 @@ public class XunfeiPptApiTests { |
| 89 | 89 | @Disabled |
| 90 | 90 | public void testCreatePptByOutlineWithFullParams() { |
| 91 | 91 | // 创建大纲对象 |
| 92 | - XunfeiPptApi.CreateResponse createResponse = getCreateResponse(); | |
| 92 | + XunFeiPptApi.CreateResponse createResponse = getCreateResponse(); | |
| 93 | 93 | // 调用方法 |
| 94 | - XunfeiPptApi.CreateResponse response = xunfeiPptApi.createPptByOutline(createResponse.data().outline(), "精简一些,不要超过6个章节"); | |
| 94 | + XunFeiPptApi.CreateResponse response = xunfeiPptApi.createPptByOutline(createResponse.data().outline(), "精简一些,不要超过6个章节"); | |
| 95 | 95 | // 打印结果 |
| 96 | 96 | System.out.println("通过大纲创建 PPT 响应:" + JsonUtils.toJsonString(response)); |
| 97 | 97 | |
| ... | ... | @@ -114,13 +114,13 @@ public class XunfeiPptApiTests { |
| 114 | 114 | String sid = "e96dac09f2ec4ee289f029a5fb874ecd"; // 替换为实际的sid |
| 115 | 115 | |
| 116 | 116 | // 调用方法 |
| 117 | - XunfeiPptApi.ProgressResponse response = xunfeiPptApi.checkProgress(sid); | |
| 117 | + XunFeiPptApi.ProgressResponse response = xunfeiPptApi.checkProgress(sid); | |
| 118 | 118 | // 打印结果 |
| 119 | 119 | System.out.println("检查进度响应:" + JsonUtils.toJsonString(response)); |
| 120 | 120 | |
| 121 | 121 | // 安全地访问响应数据 |
| 122 | 122 | if (response != null && response.data() != null) { |
| 123 | - XunfeiPptApi.ProgressResponseData data = response.data(); | |
| 123 | + XunFeiPptApi.ProgressResponseData data = response.data(); | |
| 124 | 124 | |
| 125 | 125 | // 打印PPT生成状态 |
| 126 | 126 | System.out.println("PPT 构建状态: " + data.pptStatus()); |
| ... | ... | @@ -171,11 +171,11 @@ public class XunfeiPptApiTests { |
| 171 | 171 | System.out.println("第" + (i + 1) + "次查询进度..."); |
| 172 | 172 | |
| 173 | 173 | // 调用方法 |
| 174 | - XunfeiPptApi.ProgressResponse response = xunfeiPptApi.checkProgress(sid); | |
| 174 | + XunFeiPptApi.ProgressResponse response = xunfeiPptApi.checkProgress(sid); | |
| 175 | 175 | |
| 176 | 176 | // 安全地访问响应数据 |
| 177 | 177 | if (response != null && response.data() != null) { |
| 178 | - XunfeiPptApi.ProgressResponseData data = response.data(); | |
| 178 | + XunFeiPptApi.ProgressResponseData data = response.data(); | |
| 179 | 179 | |
| 180 | 180 | // 打印进度信息 |
| 181 | 181 | System.out.println("PPT 构建状态: " + data.pptStatus()); |
| ... | ... | @@ -218,7 +218,7 @@ public class XunfeiPptApiTests { |
| 218 | 218 | String query = "合肥天气趋势分析,包括近5年的气温变化、降水量变化、极端天气事件,以及对城市生活的影响"; |
| 219 | 219 | |
| 220 | 220 | // 调用方法 |
| 221 | - XunfeiPptApi.CreateResponse response = xunfeiPptApi.create(query); | |
| 221 | + XunFeiPptApi.CreateResponse response = xunfeiPptApi.create(query); | |
| 222 | 222 | // 打印结果 |
| 223 | 223 | System.out.println("直接创建 PPT 响应:" + JsonUtils.toJsonString(response)); |
| 224 | 224 | |
| ... | ... | @@ -244,7 +244,7 @@ public class XunfeiPptApiTests { |
| 244 | 244 | MultipartFile multipartFile = convertFileToMultipartFile(file); |
| 245 | 245 | |
| 246 | 246 | // 调用方法 |
| 247 | - XunfeiPptApi.CreateResponse response = xunfeiPptApi.create(multipartFile, file.getName()); | |
| 247 | + XunFeiPptApi.CreateResponse response = xunfeiPptApi.create(multipartFile, file.getName()); | |
| 248 | 248 | // 打印结果 |
| 249 | 249 | System.out.println("通过文件创建PPT响应:" + JsonUtils.toJsonString(response)); |
| 250 | 250 | |
| ... | ... | @@ -269,7 +269,7 @@ public class XunfeiPptApiTests { |
| 269 | 269 | String query = "合肥天气趋势分析,包括近 5 年的气温变化、降水量变化、极端天气事件,以及对城市生活的影响"; |
| 270 | 270 | |
| 271 | 271 | // 创建请求对象 |
| 272 | - XunfeiPptApi.CreatePptRequest request = XunfeiPptApi.CreatePptRequest.builder() | |
| 272 | + XunFeiPptApi.CreatePptRequest request = XunFeiPptApi.CreatePptRequest.builder() | |
| 273 | 273 | .query(query) |
| 274 | 274 | .language("cn") |
| 275 | 275 | .isCardNote(true) |
| ... | ... | @@ -280,7 +280,7 @@ public class XunfeiPptApiTests { |
| 280 | 280 | .build(); |
| 281 | 281 | |
| 282 | 282 | // 调用方法 |
| 283 | - XunfeiPptApi.CreateResponse response = xunfeiPptApi.create(request); | |
| 283 | + XunFeiPptApi.CreateResponse response = xunfeiPptApi.create(request); | |
| 284 | 284 | // 打印结果 |
| 285 | 285 | System.out.println("使用完整参数创建 PPT 响应:" + JsonUtils.toJsonString(response)); |
| 286 | 286 | |
| ... | ... | @@ -296,9 +296,9 @@ public class XunfeiPptApiTests { |
| 296 | 296 | |
| 297 | 297 | // 立即查询一次进度 |
| 298 | 298 | System.out.println("立即查询进度..."); |
| 299 | - XunfeiPptApi.ProgressResponse progressResponse = xunfeiPptApi.checkProgress(sid); | |
| 299 | + XunFeiPptApi.ProgressResponse progressResponse = xunfeiPptApi.checkProgress(sid); | |
| 300 | 300 | if (progressResponse != null && progressResponse.data() != null) { |
| 301 | - XunfeiPptApi.ProgressResponseData progressData = progressResponse.data(); | |
| 301 | + XunFeiPptApi.ProgressResponseData progressData = progressResponse.data(); | |
| 302 | 302 | System.out.println("PPT 构建状态: " + progressData.pptStatus()); |
| 303 | 303 | if (progressData.totalPages() != null && progressData.donePages() != null) { |
| 304 | 304 | System.out.println("完成进度: " + progressData.donePages() + "/" + progressData.totalPages() | ... | ... |