Spaces:
Sleeping
Sleeping
Upload slide_generator.py with huggingface_hub
Browse files- slide_generator.py +19 -11
slide_generator.py
CHANGED
|
@@ -9,7 +9,7 @@ _api_key = os.environ.get("GROQ_API_KEY") or os.environ.get("HF_TOKEN")
|
|
| 9 |
client = InferenceClient(api_key=_api_key)
|
| 10 |
|
| 11 |
SYSTEM_PROMPT = (
|
| 12 |
-
"You are an expert presentation designer. "
|
| 13 |
"Return only valid JSON — no markdown fences, no extra text."
|
| 14 |
)
|
| 15 |
|
|
@@ -37,7 +37,7 @@ def generate_presentation(topic: str, style: str, num_slides: int,
|
|
| 37 |
f"\nKey points to include: {key_points}" if key_points.strip() else ""
|
| 38 |
)
|
| 39 |
|
| 40 |
-
user_prompt = f"""Create a {style.lower()} presentation about: "{topic}"
|
| 41 |
Target audience: {audience}
|
| 42 |
Number of slides: {num_slides} (including title slide){key_points_section}
|
| 43 |
|
|
@@ -51,25 +51,33 @@ Return a JSON object with this EXACT structure:
|
|
| 51 |
"type": "title",
|
| 52 |
"title": "Presentation Title",
|
| 53 |
"subtitle": "Subtitle or tagline",
|
| 54 |
-
"image_keyword": "relevant
|
| 55 |
-
"speaker_notes": "
|
| 56 |
}},
|
| 57 |
{{
|
| 58 |
"slide_number": 2,
|
| 59 |
"type": "content",
|
| 60 |
"title": "Slide Title",
|
| 61 |
-
"bullets": [
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
}}
|
| 65 |
]
|
| 66 |
}}
|
| 67 |
|
| 68 |
Rules:
|
| 69 |
- First slide must be type "title" with subtitle field
|
| 70 |
-
- All other slides type "content" with bullets array
|
| 71 |
-
-
|
| 72 |
-
-
|
|
|
|
|
|
|
| 73 |
- Total slides: exactly {num_slides}
|
| 74 |
- Return only the JSON object, nothing else
|
| 75 |
"""
|
|
@@ -81,7 +89,7 @@ Rules:
|
|
| 81 |
{"role": "user", "content": user_prompt},
|
| 82 |
],
|
| 83 |
temperature=0.7,
|
| 84 |
-
max_tokens=
|
| 85 |
)
|
| 86 |
|
| 87 |
raw = response.choices[0].message.content
|
|
|
|
| 9 |
client = InferenceClient(api_key=_api_key)
|
| 10 |
|
| 11 |
SYSTEM_PROMPT = (
|
| 12 |
+
"You are an expert presentation designer and subject-matter expert. "
|
| 13 |
"Return only valid JSON — no markdown fences, no extra text."
|
| 14 |
)
|
| 15 |
|
|
|
|
| 37 |
f"\nKey points to include: {key_points}" if key_points.strip() else ""
|
| 38 |
)
|
| 39 |
|
| 40 |
+
user_prompt = f"""Create a detailed, informative {style.lower()} presentation about: "{topic}"
|
| 41 |
Target audience: {audience}
|
| 42 |
Number of slides: {num_slides} (including title slide){key_points_section}
|
| 43 |
|
|
|
|
| 51 |
"type": "title",
|
| 52 |
"title": "Presentation Title",
|
| 53 |
"subtitle": "Subtitle or tagline",
|
| 54 |
+
"image_keyword": "relevant 2-3 word photo search term",
|
| 55 |
+
"speaker_notes": "Detailed opening notes for the presenter, 3-4 sentences."
|
| 56 |
}},
|
| 57 |
{{
|
| 58 |
"slide_number": 2,
|
| 59 |
"type": "content",
|
| 60 |
"title": "Slide Title",
|
| 61 |
+
"bullets": [
|
| 62 |
+
"First key point with sufficient detail and explanation to be meaningful",
|
| 63 |
+
"Second point that elaborates on a core concept with specific data or insight",
|
| 64 |
+
"Third point covering an important aspect with supporting context",
|
| 65 |
+
"Fourth point with actionable information or a compelling statistic",
|
| 66 |
+
"Fifth point summarizing implications or real-world applications"
|
| 67 |
+
],
|
| 68 |
+
"image_keyword": "relevant 2-3 word photo search term for this slide",
|
| 69 |
+
"speaker_notes": "Detailed speaker notes for this slide, 3-4 sentences explaining what to say and emphasize."
|
| 70 |
}}
|
| 71 |
]
|
| 72 |
}}
|
| 73 |
|
| 74 |
Rules:
|
| 75 |
- First slide must be type "title" with subtitle field
|
| 76 |
+
- All other slides type "content" with bullets array
|
| 77 |
+
- Each slide must have EXACTLY 5 bullet points
|
| 78 |
+
- Each bullet point: 15-25 words, informative and specific — include facts, data, or clear explanations. No vague one-liners.
|
| 79 |
+
- image_keyword: 2-3 descriptive words for a real-world photo (e.g. "solar panels field", "brain neuroscience scan", "city skyline night")
|
| 80 |
+
- speaker_notes: 3-4 detailed sentences per slide
|
| 81 |
- Total slides: exactly {num_slides}
|
| 82 |
- Return only the JSON object, nothing else
|
| 83 |
"""
|
|
|
|
| 89 |
{"role": "user", "content": user_prompt},
|
| 90 |
],
|
| 91 |
temperature=0.7,
|
| 92 |
+
max_tokens=6000,
|
| 93 |
)
|
| 94 |
|
| 95 |
raw = response.choices[0].message.content
|