Spaces:
Runtime error
Runtime error
Update presentation_api.py
Browse files- presentation_api.py +15 -31
presentation_api.py
CHANGED
|
@@ -21,38 +21,22 @@ router = APIRouter(
|
|
| 21 |
tags=["presentation"]
|
| 22 |
)
|
| 23 |
|
|
|
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
"""Input presentation plan with numbered slides and their descriptions.
|
| 40 |
-
Returns a confirmation message indicating that the plan has been created.
|
| 41 |
-
|
| 42 |
-
Args:
|
| 43 |
-
input: PlanInput object containing presentation details
|
| 44 |
-
"""
|
| 45 |
-
return f"Plan created with {len(input)} slides"
|
| 46 |
-
|
| 47 |
-
@tool(parse_docstring=True)
|
| 48 |
-
def create_slide(slideno: int, content: str) -> str:
|
| 49 |
-
"""Create a single presentation slide. Returns a confirmation message indicating that the slide has been created.
|
| 50 |
-
|
| 51 |
-
Args:
|
| 52 |
-
slideno: The slide number to create.
|
| 53 |
-
content: The content for the slide.
|
| 54 |
-
"""
|
| 55 |
-
return f"slide {slideno} created"
|
| 56 |
|
| 57 |
@tool(parse_docstring=True)
|
| 58 |
def execute_python(expression: str) -> str:
|
|
|
|
| 21 |
tags=["presentation"]
|
| 22 |
)
|
| 23 |
|
| 24 |
+
import json
|
| 25 |
|
| 26 |
+
@tool
|
| 27 |
+
def plan(slides_json: str) -> str:
|
| 28 |
+
"""Create a presentation plan from a JSON string of slides (keys=slide numbers, values=content)."""
|
| 29 |
+
try:
|
| 30 |
+
slides = json.loads(slides_json)
|
| 31 |
+
return f"Plan created with {len(slides)} slides: {', '.join(slides.keys())}."
|
| 32 |
+
except json.JSONDecodeError as e:
|
| 33 |
+
return f"Invalid JSON format. Please provide a valid JSON string {str(e)[:100]}."
|
| 34 |
+
|
| 35 |
+
@tool
|
| 36 |
+
def create_slide(slide_number: int, content: str) -> str:
|
| 37 |
+
"""Create a slide with the given number and content."""
|
| 38 |
+
# Integration with slide creation API or template would go here
|
| 39 |
+
return f"Slide {slide_number} created: {content}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
@tool(parse_docstring=True)
|
| 42 |
def execute_python(expression: str) -> str:
|