@@ -31,11 +31,12 @@ type CreatePPTResponse = {
3131 preview_url : string ;
3232} ;
3333
34+ const CHATPPT_BASE_URL = 'https://saas.api.yoo-ai.com' ;
35+
3436export 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