Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/tool/packages/chatPPT/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineTool({
'zh-CN': '必优ChatPPT',
en: 'ChatPPT'
},
type: ToolTypeEnum.tools,
type: ToolTypeEnum.productivity,
description: {
'zh-CN': '必优ChatPPT,一键生成PPT',
en: 'ChatPPT, one-click generate PPT'
Expand Down
12 changes: 7 additions & 5 deletions modules/tool/packages/chatPPT/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ type CreatePPTResponse = {
preview_url: string;
};

const CHATPPT_BASE_URL = 'https://saas.api.yoo-ai.com';

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

const createPPTRes = await POST<{ data: { id: string } }>(
const { data: createPPTRes } = await POST<{ data: { id: string } }>(
`${CHATPPT_BASE_URL}/apps/ppt-create`,
{
text,
Expand All @@ -48,12 +49,13 @@ export async function tool({ apiKey, text, color }: z.infer<typeof InputType>) {
}
}
);
const id = createPPTRes?.data?.data?.id;

const id = createPPTRes?.data?.id;
if (!id || typeof id !== 'string') {
return Promise.reject('Failed to create PPT: empty id');
}

const getPPTUrlRes = await GET<{ data: CreatePPTResponse }>(
const { data: getPPTUrlRes } = await GET<{ data: CreatePPTResponse }>(
`${CHATPPT_BASE_URL}/apps/ppt-result`,
{
params: {
Expand All @@ -64,7 +66,7 @@ export async function tool({ apiKey, text, color }: z.infer<typeof InputType>) {
}
}
);
const preview_url = getPPTUrlRes?.data?.data?.preview_url;
const preview_url = getPPTUrlRes?.data?.preview_url;
if (!preview_url || typeof preview_url !== 'string') {
return Promise.reject('Failed to fetch PPT preview url');
}
Expand Down