Update app.py
Browse files
app.py
CHANGED
|
@@ -65,6 +65,35 @@ def create_document(text: str, format: str = "docx") -> str:
|
|
| 65 |
except Exception as e:
|
| 66 |
return f"Error creating document: {str(e)}"
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
|
| 70 |
# =========================
|
|
@@ -88,7 +117,8 @@ agent = CodeAgent(
|
|
| 88 |
final_answer,
|
| 89 |
visit_webpage,
|
| 90 |
create_document,
|
| 91 |
-
create_presentation,
|
|
|
|
| 92 |
],
|
| 93 |
max_steps=6,
|
| 94 |
verbosity_level=0,
|
|
|
|
| 65 |
except Exception as e:
|
| 66 |
return f"Error creating document: {str(e)}"
|
| 67 |
|
| 68 |
+
@smol_tool
|
| 69 |
+
def create_presentation_preview(title: str, slides: list[str]) -> list[str]:
|
| 70 |
+
"""
|
| 71 |
+
Create a presentation and return slide previews as images.
|
| 72 |
+
|
| 73 |
+
Args:
|
| 74 |
+
title: Presentation title
|
| 75 |
+
slides: List of slide contents
|
| 76 |
+
|
| 77 |
+
Returns:
|
| 78 |
+
List of image paths (PNG), one per slide
|
| 79 |
+
"""
|
| 80 |
+
from pptx import Presentation
|
| 81 |
+
from PIL import Image, ImageDraw, ImageFont
|
| 82 |
+
import tempfile, os
|
| 83 |
+
|
| 84 |
+
temp_dir = tempfile.mkdtemp()
|
| 85 |
+
image_paths = []
|
| 86 |
+
|
| 87 |
+
for i, slide_text in enumerate(slides, start=1):
|
| 88 |
+
img = Image.new("RGB", (1280, 720), "white")
|
| 89 |
+
draw = ImageDraw.Draw(img)
|
| 90 |
+
draw.text((60, 60), f"Slide {i}\n\n{slide_text}", fill="black")
|
| 91 |
+
|
| 92 |
+
path = os.path.join(temp_dir, f"slide_{i}.png")
|
| 93 |
+
img.save(path)
|
| 94 |
+
image_paths.append(path)
|
| 95 |
+
|
| 96 |
+
return image_paths
|
| 97 |
|
| 98 |
|
| 99 |
# =========================
|
|
|
|
| 117 |
final_answer,
|
| 118 |
visit_webpage,
|
| 119 |
create_document,
|
| 120 |
+
create_presentation,
|
| 121 |
+
create_presentation_preview
|
| 122 |
],
|
| 123 |
max_steps=6,
|
| 124 |
verbosity_level=0,
|