Skip to content

Commit e486e17

Browse files
authored
ppt code (#214)
1 parent fbbba12 commit e486e17

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

modules/tool/packages/chatPPT/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default defineTool({
88
'zh-CN': '必优ChatPPT',
99
en: 'ChatPPT'
1010
},
11-
type: ToolTypeEnum.tools,
11+
type: ToolTypeEnum.productivity,
1212
description: {
1313
'zh-CN': '必优ChatPPT,一键生成PPT',
1414
en: 'ChatPPT, one-click generate PPT'

modules/tool/packages/chatPPT/src/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ type CreatePPTResponse = {
3131
preview_url: string;
3232
};
3333

34+
const CHATPPT_BASE_URL = 'https://saas.api.yoo-ai.com';
35+
3436
export async function tool({ apiKey, text, color }: z.infer<typeof InputType>) {
3537
const token = `Bearer ${apiKey}`;
36-
const CHATPPT_BASE_URL = 'https://saas.api.yoo-ai.com';
3738

38-
const createPPTRes = await POST<{ data: { id: string } }>(
39+
const { data: createPPTRes } = await POST<{ data: { id: string } }>(
3940
`${CHATPPT_BASE_URL}/apps/ppt-create`,
4041
{
4142
text,
@@ -48,12 +49,13 @@ export async function tool({ apiKey, text, color }: z.infer<typeof InputType>) {
4849
}
4950
}
5051
);
51-
const id = createPPTRes?.data?.data?.id;
52+
53+
const id = createPPTRes?.data?.id;
5254
if (!id || typeof id !== 'string') {
5355
return Promise.reject('Failed to create PPT: empty id');
5456
}
5557

56-
const getPPTUrlRes = await GET<{ data: CreatePPTResponse }>(
58+
const { data: getPPTUrlRes } = await GET<{ data: CreatePPTResponse }>(
5759
`${CHATPPT_BASE_URL}/apps/ppt-result`,
5860
{
5961
params: {
@@ -64,7 +66,7 @@ export async function tool({ apiKey, text, color }: z.infer<typeof InputType>) {
6466
}
6567
}
6668
);
67-
const preview_url = getPPTUrlRes?.data?.data?.preview_url;
69+
const preview_url = getPPTUrlRes?.data?.preview_url;
6870
if (!preview_url || typeof preview_url !== 'string') {
6971
return Promise.reject('Failed to fetch PPT preview url');
7072
}

0 commit comments

Comments
 (0)