Spaces:
Runtime error
Runtime error
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -105,9 +105,9 @@ def generate_onepager(topic, target_audience, key_points, tone, length):
|
|
| 105 |
length_tokens = {"Short": 200, "Medium": 400, "Long": 600}
|
| 106 |
max_tokens = length_tokens.get(length, 400)
|
| 107 |
|
| 108 |
-
# Create an optimized prompt for actual
|
| 109 |
prompt = f"""<|im_start|>system
|
| 110 |
-
You are a business consultant who creates
|
| 111 |
<|im_end|>
|
| 112 |
<|im_start|>user
|
| 113 |
Create a compelling one-page business document about "{topic}" for {target_audience}.
|
|
@@ -116,20 +116,23 @@ Style: {tone.lower()} but action-oriented
|
|
| 116 |
Key points: {key_points}
|
| 117 |
Length: {length}
|
| 118 |
|
| 119 |
-
|
| 120 |
-
-
|
| 121 |
-
-
|
| 122 |
-
-
|
| 123 |
-
-
|
| 124 |
-
-
|
| 125 |
|
| 126 |
-
Make it
|
| 127 |
<|im_end|>
|
| 128 |
<|im_start|>assistant
|
| 129 |
-
{topic.upper()}
|
| 130 |
-
{'=' * len(topic)}
|
| 131 |
|
| 132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
|
| 134 |
"""
|
| 135 |
|
|
@@ -163,49 +166,70 @@ Make it scannable, impactful, and designed to get approval/buy-in.
|
|
| 163 |
return create_structured_onepager(topic, target_audience, key_points, tone)
|
| 164 |
|
| 165 |
def create_structured_onepager(topic, target_audience, key_points, tone):
|
| 166 |
-
"""Create a structured one-pager
|
| 167 |
|
| 168 |
key_points_list = [point.strip() for point in key_points.split(',') if point.strip()]
|
| 169 |
|
| 170 |
-
# Create a
|
| 171 |
-
template = f"""
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
π‘ WHAT IS IT?
|
| 177 |
-
{topic} is a strategic initiative that delivers measurable value through focused implementation and clear outcomes.
|
| 178 |
-
|
| 179 |
-
π KEY BENEFITS:
|
| 180 |
-
{chr(10).join([f" β {point.strip()}" for point in key_points_list[:4]])}
|
| 181 |
-
|
| 182 |
-
π THE OPPORTUNITY:
|
| 183 |
-
β’ Immediate impact on core business objectives
|
| 184 |
-
β’ Scalable solution with long-term benefits
|
| 185 |
-
β’ Competitive advantage in the market
|
| 186 |
-
β’ Risk mitigation and operational efficiency
|
| 187 |
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
|
| 202 |
return template
|
| 203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
# Create the Gradio interface
|
| 205 |
def create_interface():
|
| 206 |
with gr.Blocks(title="One-Pager Generator", theme=gr.themes.Soft()) as demo:
|
| 207 |
gr.Markdown("# π AI One-Pager Generator")
|
| 208 |
-
gr.Markdown("Generate
|
| 209 |
|
| 210 |
with gr.Row():
|
| 211 |
with gr.Column(scale=1):
|
|
|
|
| 105 |
length_tokens = {"Short": 200, "Medium": 400, "Long": 600}
|
| 106 |
max_tokens = length_tokens.get(length, 400)
|
| 107 |
|
| 108 |
+
# Create an optimized prompt for actual business document format
|
| 109 |
prompt = f"""<|im_start|>system
|
| 110 |
+
You are a business consultant who creates professional one-page business documents. Your documents look like real corporate presentations - not markdown. Use ASCII art, boxes, tables, and visual formatting to create documents that look professional when printed or displayed.
|
| 111 |
<|im_end|>
|
| 112 |
<|im_start|>user
|
| 113 |
Create a compelling one-page business document about "{topic}" for {target_audience}.
|
|
|
|
| 116 |
Key points: {key_points}
|
| 117 |
Length: {length}
|
| 118 |
|
| 119 |
+
CRITICAL: Do NOT use markdown formatting (no #, ##, **, etc.). Instead use:
|
| 120 |
+
- ASCII boxes and borders for sections
|
| 121 |
+
- Proper spacing and alignment
|
| 122 |
+
- Visual elements like bullets, arrows, tables
|
| 123 |
+
- Professional document layout
|
| 124 |
+
- Clear headers with borders/lines
|
| 125 |
|
| 126 |
+
Make it look like a real business document that could be printed and presented.
|
| 127 |
<|im_end|>
|
| 128 |
<|im_start|>assistant
|
|
|
|
|
|
|
| 129 |
|
| 130 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 131 |
+
β {topic.upper()} β
|
| 132 |
+
β Business Case & Action Plan β
|
| 133 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 134 |
+
|
| 135 |
+
TARGET AUDIENCE: {target_audience.title()}
|
| 136 |
|
| 137 |
"""
|
| 138 |
|
|
|
|
| 166 |
return create_structured_onepager(topic, target_audience, key_points, tone)
|
| 167 |
|
| 168 |
def create_structured_onepager(topic, target_audience, key_points, tone):
|
| 169 |
+
"""Create a structured one-pager that looks like a real business document"""
|
| 170 |
|
| 171 |
key_points_list = [point.strip() for point in key_points.split(',') if point.strip()]
|
| 172 |
|
| 173 |
+
# Create a visual one-pager that looks professional, not markdown
|
| 174 |
+
template = f"""
|
| 175 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 176 |
+
β {topic.upper()} β
|
| 177 |
+
β Business Case & Action Plan β
|
| 178 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
|
| 180 |
+
TARGET AUDIENCE: {target_audience.title()} DATE: {import_date()}
|
| 181 |
+
|
| 182 |
+
ββ EXECUTIVE SUMMARY ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 183 |
+
β {topic} represents a strategic opportunity to drive significant business β
|
| 184 |
+
β value through focused implementation. This initiative delivers measurable β
|
| 185 |
+
β outcomes with clear ROI and competitive advantages. β
|
| 186 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 187 |
+
|
| 188 |
+
β KEY BENEFITS & VALUE DRIVERS
|
| 189 |
+
|
| 190 |
+
{chr(10).join([f" βͺ {point.strip()}" for point in key_points_list[:4]])}
|
| 191 |
+
|
| 192 |
+
β‘ BUSINESS IMPACT
|
| 193 |
+
|
| 194 |
+
Revenue Growth: 15-30% increase through improved efficiency
|
| 195 |
+
Cost Reduction: 20-25% operational cost savings
|
| 196 |
+
Time to Market: 40-50% faster delivery cycles
|
| 197 |
+
Risk Mitigation: Reduced compliance and operational risks
|
| 198 |
+
|
| 199 |
+
π IMPLEMENTATION ROADMAP
|
| 200 |
+
|
| 201 |
+
Phase 1 (Month 1-2): Assessment & Planning
|
| 202 |
+
Phase 2 (Month 3-4): Core Implementation
|
| 203 |
+
Phase 3 (Month 5-6): Optimization & Scale
|
| 204 |
+
|
| 205 |
+
π΅ INVESTMENT SUMMARY
|
| 206 |
+
|
| 207 |
+
Initial Investment: $XXX,XXX (one-time)
|
| 208 |
+
Annual Operating: $XX,XXX (ongoing)
|
| 209 |
+
Break-even Point: 8-12 months
|
| 210 |
+
3-Year ROI: 250-400%
|
| 211 |
+
|
| 212 |
+
ββ DECISION REQUIRED ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 213 |
+
β APPROVE: Proceed with {topic.lower()} implementation β
|
| 214 |
+
β TIMELINE: Decision needed by [DATE] to meet Q[X] targets β
|
| 215 |
+
β NEXT STEP: Schedule planning session with implementation team β
|
| 216 |
+
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 217 |
+
|
| 218 |
+
Contact: [Implementation Team] | Email: [team@company.com] | Ext: XXXX
|
| 219 |
+
"""
|
| 220 |
|
| 221 |
return template
|
| 222 |
|
| 223 |
+
def import_date():
|
| 224 |
+
"""Get current date for the one-pager"""
|
| 225 |
+
from datetime import datetime
|
| 226 |
+
return datetime.now().strftime("%B %d, %Y")
|
| 227 |
+
|
| 228 |
# Create the Gradio interface
|
| 229 |
def create_interface():
|
| 230 |
with gr.Blocks(title="One-Pager Generator", theme=gr.themes.Soft()) as demo:
|
| 231 |
gr.Markdown("# π AI One-Pager Generator")
|
| 232 |
+
gr.Markdown("Generate professional business documents with visual formatting - NOT markdown! Perfect for printing and presentations.")
|
| 233 |
|
| 234 |
with gr.Row():
|
| 235 |
with gr.Column(scale=1):
|