@@ -56,14 +56,41 @@ def create_presentation(
5656 filename : str ,
5757 ) -> str :
5858 r"""Create a PowerPoint presentation (PPTX) file using PptxGenJS.
59+
60+ The filename MUST end with ".pptx". If it does not, the toolkit will
61+ automatically append it, but the agent should strive to provide the
62+ correct extension.
5963
6064 Args:
6165 content (str): The content to write to the PPTX file as a JSON
62- string.
63- filename (str): The name or path of the file.
66+ string. It must be a list of dictionaries representing slides.
67+
68+ JSON Schema Example:
69+ [
70+ {
71+ "title": "Main Title",
72+ "subtitle": "Subtitle text"
73+ },
74+ {
75+ "heading": "Slide Heading",
76+ "bullet_points": [
77+ "Point 1",
78+ "Point 2"
79+ ]
80+ },
81+ {
82+ "heading": "Table Slide",
83+ "table": {
84+ "headers": ["Col 1", "Col 2"],
85+ "rows": [["A", "B"], ["C", "D"]]
86+ }
87+ }
88+ ]
89+ filename (str): The name of the file to save. MUST end in .pptx.
6490
6591 Returns:
66- str: A success message indicating the file was created.
92+ str: A JSON string containing the result status, file path, and
93+ number of slides generated.
6794 """
6895 if not filename .lower ().endswith ('.pptx' ):
6996 filename += '.pptx'
@@ -90,12 +117,20 @@ def create_presentation(
90117 text = True ,
91118 check = True
92119 )
93- res = result .stdout .strip ()
94- return res
120+
121+ # Parse JSON output from script
122+ try :
123+ script_output = json .loads (result .stdout .strip ())
124+ if script_output .get ("success" ):
125+ return f"Presentation created successfully. Path: { script_output .get ('path' )} , Slides: { script_output .get ('slides' )} "
126+ else :
127+ return f"Error creating presentation: { script_output .get ('error' )} "
128+ except json .JSONDecodeError :
129+ return f"Error parsing script output: { result .stdout .strip ()} "
95130
96131 except subprocess .CalledProcessError as e :
97132 logger .error (f"Error creating presentation: { e .stderr } " )
98- return f"Error creating presentation: { e .stderr } "
133+ return f"Error creating presentation subprocess : { e .stderr } "
99134 except Exception as e :
100135 logger .error (f"Error creating presentation: { str (e )} " )
101136 return f"Error creating presentation: { str (e )} "
0 commit comments