openfree commited on
Commit
432e12b
ยท
verified ยท
1 Parent(s): 30a1f94

Upload 3 files

Browse files
Files changed (3) hide show
  1. constants.py +369 -0
  2. content_utils.py +1789 -0
  3. ui_components.py +210 -0
constants.py ADDED
@@ -0,0 +1,369 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # constants.py
2
+ """Constants and configurations for PPT Generator"""
3
+
4
+ # Example templates (English and Korean versions)
5
+ EXAMPLE_TOPICS = {
6
+ "English": {
7
+ "Business Proposal": "AI-powered Customer Service Automation Platform Investment Proposal",
8
+ "Product Launch": "Smart Home IoT Security System New Product Launch",
9
+ "Project Report": "Digital Transformation Project Q3 Performance Report",
10
+ "Strategy Planning": "2025 Global Market Entry Strategy Development"
11
+ },
12
+ "Korean": {
13
+ "Business Proposal": "AI ๊ธฐ๋ฐ˜ ๊ณ ๊ฐ ์„œ๋น„์Šค ์ž๋™ํ™” ํ”Œ๋žซํผ ํˆฌ์ž ์ œ์•ˆ",
14
+ "Product Launch": "์Šค๋งˆํŠธ ํ™ˆ IoT ๋ณด์•ˆ ์‹œ์Šคํ…œ ์‹ ์ œํ’ˆ ๋Ÿฐ์นญ",
15
+ "Project Report": "๋””์ง€ํ„ธ ์ „ํ™˜ ํ”„๋กœ์ ํŠธ 3๋ถ„๊ธฐ ์„ฑ๊ณผ ๋ณด๊ณ ",
16
+ "Strategy Planning": "2025๋…„ ๊ธ€๋กœ๋ฒŒ ์‹œ์žฅ ์ง„์ถœ ์ „๋žต ์ˆ˜๋ฆฝ"
17
+ }
18
+ }
19
+
20
+ # Audience types definition (English)
21
+ AUDIENCE_TYPES = {
22
+ "Executives/C-Level": {
23
+ "description": "C-level executives, decision makers",
24
+ "tone": "Strategic, results-focused, ROI emphasis",
25
+ "focus": "Business value, ROI, strategic impact"
26
+ },
27
+ "Investors": {
28
+ "description": "VCs, angel investors, institutional investors",
29
+ "tone": "Data-driven, growth potential, market opportunities",
30
+ "focus": "Market size, growth rate, competitive advantage, exit strategy"
31
+ },
32
+ "Technical Team": {
33
+ "description": "Developers, engineers, IT professionals",
34
+ "tone": "Technical, specific, practical",
35
+ "focus": "Tech stack, architecture, implementation, performance"
36
+ },
37
+ "General Staff": {
38
+ "description": "Team members, practitioners",
39
+ "tone": "Friendly, practical, collaboration-focused",
40
+ "focus": "Execution plan, roles, processes, collaboration"
41
+ },
42
+ "Customers/Partners": {
43
+ "description": "B2B customers, business partners",
44
+ "tone": "Trustworthy, professional, benefit-focused",
45
+ "focus": "Customer value, benefits, case studies, support"
46
+ },
47
+ "General Public": {
48
+ "description": "B2C customers, general users",
49
+ "tone": "Easy and friendly, easy to understand",
50
+ "focus": "Ease of use, benefits, pricing, differentiation"
51
+ }
52
+ }
53
+
54
+ # Design themes definition
55
+ DESIGN_THEMES = {
56
+ "Minimal Light": {
57
+ "name": "Minimal Light",
58
+ "description": "Bright and clean minimal design",
59
+ "background": (250, 250, 252),
60
+ "title_color": (33, 37, 41),
61
+ "subtitle_color": (52, 58, 64),
62
+ "text_color": (73, 80, 87),
63
+ "accent_color": (0, 123, 255),
64
+ "box_fill": (255, 255, 255),
65
+ "box_opacity": 0.95,
66
+ "shadow": True,
67
+ "gradient": False
68
+ },
69
+ "Modern Gradient": {
70
+ "name": "Modern Gradient",
71
+ "description": "Smooth gradients with modern feel",
72
+ "background": (245, 247, 250),
73
+ "title_color": (25, 42, 86),
74
+ "subtitle_color": (68, 85, 102),
75
+ "text_color": (85, 102, 119),
76
+ "accent_color": (103, 58, 183),
77
+ "box_fill": (249, 250, 251),
78
+ "box_opacity": 0.9,
79
+ "shadow": True,
80
+ "gradient": True
81
+ },
82
+ "Dark Elegance": {
83
+ "name": "Dark Elegance",
84
+ "description": "Sophisticated dark mode design",
85
+ "background": (25, 25, 35),
86
+ "title_color": (240, 240, 245),
87
+ "subtitle_color": (200, 200, 210),
88
+ "text_color": (170, 170, 180),
89
+ "accent_color": (0, 188, 212),
90
+ "box_fill": (35, 35, 45),
91
+ "box_opacity": 0.85,
92
+ "shadow": False,
93
+ "gradient": False
94
+ },
95
+ "Nature Green": {
96
+ "name": "Nature Green",
97
+ "description": "Eco-friendly green theme",
98
+ "background": (242, 248, 244),
99
+ "title_color": (27, 67, 50),
100
+ "subtitle_color": (45, 106, 79),
101
+ "text_color": (64, 125, 98),
102
+ "accent_color": (76, 175, 80),
103
+ "box_fill": (255, 255, 255),
104
+ "box_opacity": 0.92,
105
+ "shadow": True,
106
+ "gradient": False
107
+ },
108
+ "Corporate Blue": {
109
+ "name": "Corporate Blue",
110
+ "description": "Professional business style",
111
+ "background": (244, 247, 252),
112
+ "title_color": (13, 71, 161),
113
+ "subtitle_color": (25, 118, 210),
114
+ "text_color": (42, 63, 84),
115
+ "accent_color": (33, 150, 243),
116
+ "box_fill": (255, 255, 255),
117
+ "box_opacity": 0.95,
118
+ "shadow": True,
119
+ "gradient": False
120
+ }
121
+ }
122
+
123
+ # Style templates definition
124
+ STYLE_TEMPLATES = {
125
+ "Title Slide (Hero)": {
126
+ "name": "Title Slide",
127
+ "description": "Impactful hero image for title slide",
128
+ "use_case": "Cover, Title",
129
+ "example": "A dramatic wide-angle view of a modern glass skyscraper reaching into clouds with golden sunset lighting, symbolizing growth and ambition. Ultra-realistic photography style, cinematic composition, lens flare, professional corporate aesthetic"
130
+ },
131
+ "Thank You Slide": {
132
+ "name": "Closing Slide",
133
+ "description": "Elegant closing slide design with conclusion",
134
+ "use_case": "Presentation closing",
135
+ "example": "Abstract elegant background with soft gradient from deep blue to purple, golden particles floating like celebration confetti, subtle light rays, with space for conclusion text. Minimalist, professional, warm feeling"
136
+ },
137
+ "3D Style (Pixar-like)": {
138
+ "name": "3D Style",
139
+ "description": "Pixar-esque 3D render with volumetric lighting",
140
+ "use_case": "Cover, Vision, Future concept",
141
+ "example": "A fluffy ginger cat wearing a tiny spacesuit, floating amidst a vibrant nebula in a 3D render. The cat is gazing curiously at a swirling planet with rings made of candy. Background is filled with sparkling stars and colorful gas clouds, lit with soft, volumetric lighting. Style: Pixar-esque, highly detailed, playful. Colors: Deep blues, purples, oranges, and pinks. Rendered in Octane, 8k resolution."
142
+ },
143
+ "Elegant SWOT Quadrant": {
144
+ "name": "SWOT Analysis",
145
+ "description": "Flat-design 4-grid layout with minimal shadows",
146
+ "use_case": "Current state analysis, Strategy evaluation",
147
+ "example": "Elegant SWOT quadrant: flat-design 4-grid on matte-white backdrop, thin pastel separators, top-left 'Strengths' panel shows glowing shield icon and subtle motif, top-right 'Weaknesses' panel with cracked chain icon in soft crimson, bottom-left 'Opportunities' panel with sunrise-over-horizon icon in optimistic teal, bottom-right 'Threats' panel with storm-cloud & lightning icon in deep indigo, minimal shadows, no text, no watermark, 16:9, 4K"
148
+ },
149
+ "Colorful Mind Map": {
150
+ "name": "Mind Map",
151
+ "description": "Hand-drawn educational style with vibrant colors",
152
+ "use_case": "Brainstorming, Idea organization",
153
+ "example": "A handrawn colorful mind map diagram: educational style, vibrant colors, clear hierarchy, golden ratio layout. Central concept with branching sub-topics, each branch with unique color coding, organic flowing connections, doodle-style icons for each node"
154
+ },
155
+ "Business Workflow": {
156
+ "name": "Business Process",
157
+ "description": "End-to-end business workflow with clear phases",
158
+ "use_case": "Process explanation, Step-by-step progress",
159
+ "example": "A detailed hand-drawn diagram illustrating an end-to-end business workflow with Market Analysis, Strategy Development, Product Design, Implementation, and Post-Launch Review phases. Clear directional arrows, iconography for each component, vibrant educational yet professional style",
160
+ "is_process_flow": True
161
+ },
162
+ "Industrial Design": {
163
+ "name": "Product Design",
164
+ "description": "Sleek industrial design concept sketch",
165
+ "use_case": "Product introduction, Concept design",
166
+ "example": "A sleek industrial design concept: Curved metallic body with minimal bezel, Touchscreen panel for settings, Modern matte black finish, Hand-drawn concept sketch style with annotations and dimension lines"
167
+ },
168
+ "3D Bubble Chart": {
169
+ "name": "Bubble Chart",
170
+ "description": "Clean 3D bubble visualization",
171
+ "use_case": "Comparative analysis, Positioning",
172
+ "example": "3-D bubble chart on clean white 2ร—2 grid, quadrant titles hidden, four translucent spheres in lime, azure, amber, magenta, gentle depth-of-field, modern consulting aesthetic, no text, 4K"
173
+ },
174
+ "Timeline Ribbon": {
175
+ "name": "Timeline",
176
+ "description": "Horizontal ribbon timeline with cyber-futuristic vibe",
177
+ "use_case": "Schedule, Roadmap, Milestones",
178
+ "example": "Horizontal ribbon timeline, milestone pins glowing hot pink on charcoal, year markers as circles, faint motion streaks, cyber-futuristic vibe, no text, 1920ร—1080"
179
+ },
180
+ "Risk Heat Map": {
181
+ "name": "Heat Map",
182
+ "description": "Risk assessment heat map with gradient colors",
183
+ "use_case": "Risk analysis, Prioritization",
184
+ "example": "Risk Heat Map: square grid, smooth gradient from mint to fire-red, cells beveled, simple legend strip hidden, long subtle shadow, sterile white frame, no text"
185
+ },
186
+ "Pyramid/Funnel": {
187
+ "name": "Funnel Chart",
188
+ "description": "Multi-layer gradient funnel visualization",
189
+ "use_case": "Step-by-step reduction, Core extraction",
190
+ "example": "Pyramid / Funnel: 5-layer gradient funnel narrowing downwards, top vivid sky-blue, mid mint-green, bottom sunset-orange, glass reflection, minimal background, no text"
191
+ },
192
+ "KPI Dashboard": {
193
+ "name": "Dashboard",
194
+ "description": "Dark-mode analytics dashboard with sci-fi interface",
195
+ "use_case": "Performance metrics, Results dashboard",
196
+ "example": "KPI Dashboard: Dark-mode analytic dashboard, three glass speedometers glowing neon lime, two sparkline charts under, black glass background, sci-fi interface, no text, 4K"
197
+ },
198
+ "Value Chain": {
199
+ "name": "Value Chain",
200
+ "description": "Horizontal value chain with industrial look",
201
+ "use_case": "Value chain, Business model",
202
+ "example": "Value Chain Diagram: Horizontal value chain blocks, steel-blue gradient bars with subtle bevel, small gear icons above each segment, sleek industrial look, shadow cast, no text"
203
+ },
204
+ "Gantt Chart": {
205
+ "name": "Gantt Chart",
206
+ "description": "Hand-drawn style Gantt chart with playful colors",
207
+ "use_case": "Project schedule, Task management",
208
+ "example": "Gantt Chart: Hand-drawn style Gantt bars sketched with vibrant markers on dotted grid notebook page, sticky-note color palette, playful yet organized, perspective tilt, no text"
209
+ },
210
+ "Mobile App Mockup": {
211
+ "name": "App Mockup",
212
+ "description": "Clean wireframe for mobile app design",
213
+ "use_case": "App/Web UI, Screen design",
214
+ "example": "MOCKUP DESIGN: A clean hand-drawn style wireframe for a mobile app with Title screen, Login screen, Dashboard with sections, Bottom navigation bar, minimalist design with annotations"
215
+ },
216
+ "Flowchart": {
217
+ "name": "Flowchart",
218
+ "description": "Vibrant flowchart with minimalistic icons",
219
+ "use_case": "Decision making, Process flow",
220
+ "example": "FLOWCHART DESIGN: A hand-drawn style flowchart, vibrant colors, minimalistic icons showing process flow from START to END with decision points, branches, and clear directional arrows",
221
+ "is_process_flow": True
222
+ }
223
+ }
224
+
225
+ # PPT templates definition (English names)
226
+ PPT_TEMPLATES = {
227
+ "Business Proposal": {
228
+ "description": "For investment pitches and business proposals",
229
+ "core_slides": [
230
+ {"title": "Contents", "style": "Flowchart", "prompt_hint": "Presentation structure"},
231
+ {"title": "Problem Definition", "style": "Colorful Mind Map", "prompt_hint": "Current market problems"},
232
+ {"title": "Current Analysis", "style": "Elegant SWOT Quadrant", "prompt_hint": "Strengths, Weaknesses, Opportunities, Threats"},
233
+ {"title": "Solution", "style": "Industrial Design", "prompt_hint": "Product/Service concept"},
234
+ {"title": "Process", "style": "Business Workflow", "prompt_hint": "Implementation steps"},
235
+ {"title": "Timeline", "style": "Timeline Ribbon", "prompt_hint": "Key milestones"}
236
+ ],
237
+ "optional_slides": [
238
+ {"title": "Market Size", "style": "3D Bubble Chart", "prompt_hint": "Market opportunity and growth"},
239
+ {"title": "Competition Analysis", "style": "Risk Heat Map", "prompt_hint": "Competitor positioning"},
240
+ {"title": "Business Model", "style": "Value Chain", "prompt_hint": "Revenue structure"},
241
+ {"title": "Team Introduction", "style": "Colorful Mind Map", "prompt_hint": "Core team and capabilities"},
242
+ {"title": "Financial Plan", "style": "KPI Dashboard", "prompt_hint": "Expected revenue and P&L"},
243
+ {"title": "Risk Management", "style": "Risk Heat Map", "prompt_hint": "Key risks and mitigation"},
244
+ {"title": "Partnership", "style": "Value Chain", "prompt_hint": "Strategic alliances"},
245
+ {"title": "Technology Stack", "style": "Industrial Design", "prompt_hint": "Core technology architecture"},
246
+ {"title": "Customer Cases", "style": "Industrial Design", "prompt_hint": "Success stories"},
247
+ {"title": "Growth Strategy", "style": "Timeline Ribbon", "prompt_hint": "Expansion plan"},
248
+ {"title": "Investment Use", "style": "Pyramid/Funnel", "prompt_hint": "Fund allocation plan"},
249
+ {"title": "Exit Strategy", "style": "Timeline Ribbon", "prompt_hint": "Exit plan"}
250
+ ]
251
+ },
252
+ "Product Launch": {
253
+ "description": "For new product launches and service introductions",
254
+ "core_slides": [
255
+ {"title": "Product Concept", "style": "Industrial Design", "prompt_hint": "Product design"},
256
+ {"title": "User Needs", "style": "Colorful Mind Map", "prompt_hint": "Customer pain points"},
257
+ {"title": "Features", "style": "Mobile App Mockup", "prompt_hint": "UI/UX screens"},
258
+ {"title": "How It Works", "style": "Flowchart", "prompt_hint": "Function flow"},
259
+ {"title": "Market Position", "style": "3D Bubble Chart", "prompt_hint": "Competitor comparison"},
260
+ {"title": "Launch Schedule", "style": "Timeline Ribbon", "prompt_hint": "Launch roadmap"}
261
+ ],
262
+ "optional_slides": [
263
+ {"title": "Target Customers", "style": "Colorful Mind Map", "prompt_hint": "Key customer segments"},
264
+ {"title": "Pricing Strategy", "style": "Pyramid/Funnel", "prompt_hint": "Pricing approach"},
265
+ {"title": "Technical Advantage", "style": "Industrial Design", "prompt_hint": "Core technology"},
266
+ {"title": "Use Scenarios", "style": "Mobile App Mockup", "prompt_hint": "Use cases"},
267
+ {"title": "Customer Reviews", "style": "KPI Dashboard", "prompt_hint": "User feedback"},
268
+ {"title": "Sales Channels", "style": "Value Chain", "prompt_hint": "Distribution strategy"},
269
+ {"title": "Marketing Strategy", "style": "Timeline Ribbon", "prompt_hint": "Promotion plan"},
270
+ {"title": "Performance Comparison", "style": "3D Bubble Chart", "prompt_hint": "Benchmarks"}
271
+ ]
272
+ },
273
+ "Project Report": {
274
+ "description": "For progress and performance reports",
275
+ "core_slides": [
276
+ {"title": "Project Overview", "style": "Business Workflow", "prompt_hint": "Overall process"},
277
+ {"title": "Progress Status", "style": "Gantt Chart", "prompt_hint": "Work schedule"},
278
+ {"title": "Risk Management", "style": "Risk Heat Map", "prompt_hint": "Risk factors"},
279
+ {"title": "Performance Metrics", "style": "KPI Dashboard", "prompt_hint": "Achievement results"},
280
+ {"title": "Future Plans", "style": "Timeline Ribbon", "prompt_hint": "Next steps"}
281
+ ],
282
+ "optional_slides": [
283
+ {"title": "Budget Status", "style": "Pyramid/Funnel", "prompt_hint": "Budget execution"},
284
+ {"title": "Team Performance", "style": "3D Bubble Chart", "prompt_hint": "Team contribution"},
285
+ {"title": "Issue Management", "style": "Risk Heat Map", "prompt_hint": "Key issues"},
286
+ {"title": "Improvements", "style": "Colorful Mind Map", "prompt_hint": "Process improvements"},
287
+ {"title": "Lessons Learned", "style": "Colorful Mind Map", "prompt_hint": "Key learnings"}
288
+ ]
289
+ },
290
+ "Strategy Planning": {
291
+ "description": "For long-term strategy and vision development",
292
+ "core_slides": [
293
+ {"title": "Vision", "style": "3D Style (Pixar-like)", "prompt_hint": "Future vision"},
294
+ {"title": "Environmental Analysis", "style": "Elegant SWOT Quadrant", "prompt_hint": "Internal/External environment"},
295
+ {"title": "Strategy Framework", "style": "Colorful Mind Map", "prompt_hint": "Strategy structure"},
296
+ {"title": "Value Chain", "style": "Value Chain", "prompt_hint": "Business model"},
297
+ {"title": "Implementation Roadmap", "style": "Timeline Ribbon", "prompt_hint": "Phased plan"},
298
+ {"title": "Target Metrics", "style": "KPI Dashboard", "prompt_hint": "KPI targets"}
299
+ ],
300
+ "optional_slides": [
301
+ {"title": "Market Outlook", "style": "3D Bubble Chart", "prompt_hint": "Future market"},
302
+ {"title": "Innovation Direction", "style": "Industrial Design", "prompt_hint": "Innovation strategy"},
303
+ {"title": "Organizational Change", "style": "Value Chain", "prompt_hint": "Org restructuring"},
304
+ {"title": "Digital Transformation", "style": "Industrial Design", "prompt_hint": "DX strategy"},
305
+ {"title": "Sustainability", "style": "Timeline Ribbon", "prompt_hint": "ESG strategy"}
306
+ ]
307
+ },
308
+ "Custom": {
309
+ "description": "Build your own presentation",
310
+ "core_slides": [],
311
+ "optional_slides": []
312
+ }
313
+ }
314
+
315
+ # Korean translations for slide titles
316
+ SLIDE_TITLE_TRANSLATIONS = {
317
+ "Contents": "๋ชฉ์ฐจ",
318
+ "Problem Definition": "๋ฌธ์ œ ์ •์˜",
319
+ "Current Analysis": "ํ˜„ํ™ฉ ๋ถ„์„",
320
+ "Solution": "์†”๋ฃจ์…˜",
321
+ "Process": "ํ”„๋กœ์„ธ์Šค",
322
+ "Timeline": "์ผ์ •",
323
+ "Market Size": "์‹œ์žฅ ๊ทœ๋ชจ",
324
+ "Competition Analysis": "๊ฒฝ์Ÿ ๋ถ„์„",
325
+ "Business Model": "๋น„์ฆˆ๋‹ˆ์Šค ๋ชจ๋ธ",
326
+ "Team Introduction": "ํŒ€ ์†Œ๊ฐœ",
327
+ "Financial Plan": "์žฌ๋ฌด ๊ณ„ํš",
328
+ "Risk Management": "์œ„ํ—˜ ๊ด€๋ฆฌ",
329
+ "Partnership": "ํŒŒํŠธ๋„ˆ์‹ญ",
330
+ "Technology Stack": "๊ธฐ์ˆ  ์Šคํƒ",
331
+ "Customer Cases": "๊ณ ๊ฐ ์‚ฌ๋ก€",
332
+ "Growth Strategy": "์„ฑ์žฅ ์ „๋žต",
333
+ "Investment Use": "ํˆฌ์ž ํ™œ์šฉ",
334
+ "Exit Strategy": "Exit ์ „๋žต",
335
+ "Product Concept": "์ œํ’ˆ ์ปจ์…‰",
336
+ "User Needs": "์‚ฌ์šฉ์ž ๋‹ˆ์ฆˆ",
337
+ "Features": "๊ธฐ๋Šฅ ์†Œ๊ฐœ",
338
+ "How It Works": "์ž‘๋™ ์›๋ฆฌ",
339
+ "Market Position": "์‹œ์žฅ ํฌ์ง€์…˜",
340
+ "Launch Schedule": "์ถœ์‹œ ์ผ์ •",
341
+ "Target Customers": "ํƒ€๊ฒŸ ๊ณ ๊ฐ",
342
+ "Pricing Strategy": "๊ฐ€๊ฒฉ ์ •์ฑ…",
343
+ "Technical Advantage": "๊ธฐ์ˆ  ์šฐ์œ„",
344
+ "Use Scenarios": "์‚ฌ์šฉ ์‹œ๋‚˜๋ฆฌ์˜ค",
345
+ "Customer Reviews": "๊ณ ๊ฐ ํ›„๊ธฐ",
346
+ "Sales Channels": "ํŒ๋งค ์ฑ„๋„",
347
+ "Marketing Strategy": "๋งˆ์ผ€ํŒ… ์ „๋žต",
348
+ "Performance Comparison": "์„ฑ๋Šฅ ๋น„๊ต",
349
+ "Project Overview": "ํ”„๋กœ์ ํŠธ ๊ฐœ์š”",
350
+ "Progress Status": "์ง„ํ–‰ ํ˜„ํ™ฉ",
351
+ "Performance Metrics": "์„ฑ๊ณผ ์ง€ํ‘œ",
352
+ "Future Plans": "ํ–ฅํ›„ ๊ณ„ํš",
353
+ "Budget Status": "์˜ˆ์‚ฐ ํ˜„ํ™ฉ",
354
+ "Team Performance": "ํŒ€ ์„ฑ๊ณผ",
355
+ "Issue Management": "์ด์Šˆ ๊ด€๋ฆฌ",
356
+ "Improvements": "๊ฐœ์„  ์‚ฌํ•ญ",
357
+ "Lessons Learned": "๊ตํ›ˆ",
358
+ "Vision": "๋น„์ „",
359
+ "Environmental Analysis": "ํ™˜๊ฒฝ ๋ถ„์„",
360
+ "Strategy Framework": "์ „๋žต ์ฒด๊ณ„",
361
+ "Value Chain": "๊ฐ€์น˜ ์‚ฌ์Šฌ",
362
+ "Implementation Roadmap": "์‹คํ–‰ ๋กœ๋“œ๋งต",
363
+ "Target Metrics": "๋ชฉํ‘œ ์ง€ํ‘œ",
364
+ "Market Outlook": "์‹œ์žฅ ์ „๋ง",
365
+ "Innovation Direction": "ํ˜์‹  ๋ฐฉํ–ฅ",
366
+ "Organizational Change": "์กฐ์ง ๋ณ€ํ™”",
367
+ "Digital Transformation": "๋””์ง€ํ„ธ ์ „ํ™˜",
368
+ "Sustainability": "์ง€์†๊ฐ€๋Šฅ์„ฑ"
369
+ }
content_utils.py ADDED
@@ -0,0 +1,1789 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # content_utils.py
2
+ """Content generation and utility functions for PPT Generator"""
3
+
4
+ import re
5
+ import requests
6
+ import logging
7
+ import base64
8
+ import time
9
+ import traceback
10
+ from io import BytesIO
11
+ from PIL import Image
12
+ from typing import List, Dict, Tuple
13
+ import PyPDF2
14
+ import pandas as pd
15
+ import chardet
16
+ import replicate
17
+ from bs4 import BeautifulSoup
18
+ from urllib.parse import urlparse
19
+ import urllib.request
20
+ from datetime import datetime
21
+ from pptx import Presentation
22
+ from pptx.util import Inches, Pt
23
+ from pptx.dml.color import RGBColor
24
+ from pptx.enum.text import PP_ALIGN, MSO_ANCHOR
25
+ from pptx.enum.shapes import MSO_SHAPE
26
+
27
+ logger = logging.getLogger(__name__)
28
+
29
+ # Import process flow generator
30
+ try:
31
+ from process_flow_generator import generate_process_flow_for_ppt
32
+ PROCESS_FLOW_AVAILABLE = True
33
+ except ImportError:
34
+ PROCESS_FLOW_AVAILABLE = False
35
+ print("[Warning] Cannot import process_flow_generator. Process flow diagram feature disabled.")
36
+
37
+ def parse_executor_response(executor_response: str, slides_config: List[Dict], language: str = "English") -> Dict[int, Dict]:
38
+ """์‹คํ–‰์ž AI์˜ ์‘๋‹ต์„ ํŒŒ์‹ฑํ•˜์—ฌ ์Šฌ๋ผ์ด๋“œ ๋ฐ์ดํ„ฐ๋กœ ๋ณ€ํ™˜ - ๊ฐœ์„ ๋œ ๋ฒ„์ „"""
39
+ parsed_data = {}
40
+
41
+ # ์Šฌ๋ผ์ด๋“œ ๊ตฌ๋ถ„ ํŒจํ„ด
42
+ slide_patterns = [
43
+ r'\[์Šฌ๋ผ์ด๋“œ\s*(\d+)\]',
44
+ r'\[Slide\s*(\d+)\]',
45
+ r'Slide\s*(\d+):',
46
+ r'#\s*Slide\s*(\d+)',
47
+ r'---\s*\n\s*\[์Šฌ๋ผ์ด๋“œ\s*(\d+)\]',
48
+ r'์Šฌ๋ผ์ด๋“œ\s*(\d+)\.',
49
+ r'Slide\s+(\d+)\s*-',
50
+ r'###\s*์Šฌ๋ผ์ด๋“œ\s*(\d+)',
51
+ r'##\s*\[์Šฌ๋ผ์ด๋“œ\s*(\d+)\]',
52
+ ]
53
+
54
+ # ์ „์ฒด ํ…์ŠคํŠธ์—์„œ ์Šฌ๋ผ์ด๋“œ ์ฐพ๊ธฐ
55
+ all_matches = []
56
+ for pattern in slide_patterns:
57
+ matches = list(re.finditer(pattern, executor_response, re.IGNORECASE | re.MULTILINE))
58
+ for m in matches:
59
+ all_matches.append((m.start(), m))
60
+
61
+ # ์œ„์น˜ ์ˆœ์œผ๋กœ ์ •๋ ฌ
62
+ all_matches.sort(key=lambda x: x[0])
63
+ slide_matches = [m[1] for m in all_matches]
64
+
65
+ # ์Šฌ๋ผ์ด๋“œ๋ณ„๋กœ ๋‚ด์šฉ ํŒŒ์‹ฑ
66
+ for i, match in enumerate(slide_matches):
67
+ try:
68
+ start_pos = match.start()
69
+ end_pos = slide_matches[i + 1].start() if i + 1 < len(slide_matches) else len(executor_response)
70
+
71
+ slide_content = executor_response[start_pos:end_pos]
72
+
73
+ # ์Šฌ๋ผ์ด๋“œ ๋ฒˆํ˜ธ ์ถ”์ถœ
74
+ slide_num = None
75
+ for group in match.groups():
76
+ if group:
77
+ slide_num = int(group)
78
+ break
79
+
80
+ if slide_num is None:
81
+ continue
82
+
83
+ # ์ œ๋ชฉ ์ถ”์ถœ
84
+ title = ""
85
+ title_patterns = [
86
+ r'์ œ๋ชฉ:\s*(.+?)(?=\n|$)',
87
+ r'Title:\s*(.+?)(?=\n|$)',
88
+ r'์ œ๋ชฉ\s*:\s*(.+?)(?=\n|$)',
89
+ ]
90
+ for pattern in title_patterns:
91
+ title_match = re.search(pattern, slide_content, re.MULTILINE)
92
+ if title_match:
93
+ title = title_match.group(1).strip()
94
+ if title:
95
+ break
96
+
97
+ # ๋ถ€์ œ๋ชฉ ์ถ”์ถœ
98
+ subtitle = ""
99
+ subtitle_patterns = [
100
+ r'๋ถ€์ œ๋ชฉ:\s*(.+?)(?=\n|$)',
101
+ r'Subtitle:\s*(.+?)(?=\n|$)',
102
+ r'๋ถ€์ œ\s*:\s*(.+?)(?=\n|$)',
103
+ ]
104
+ for pattern in subtitle_patterns:
105
+ subtitle_match = re.search(pattern, slide_content, re.MULTILINE)
106
+ if subtitle_match:
107
+ subtitle = subtitle_match.group(1).strip()
108
+ if subtitle:
109
+ break
110
+
111
+ # ๋ถˆ๋ฆฟ ํฌ์ธํŠธ ์ถ”์ถœ (์ด๋ชจ์ง€๊ฐ€ ์žˆ๋Š” ๋ผ์ธ๋“ค)
112
+ bullet_points = []
113
+ lines = slide_content.strip().split('\n')
114
+
115
+ for line in lines:
116
+ line = line.strip()
117
+ if not line:
118
+ continue
119
+
120
+ # ์ด๋ชจ์ง€๋กœ ์‹œ์ž‘ํ•˜๊ฑฐ๋‚˜ โ€ข ๋กœ ์‹œ์ž‘ํ•˜๋Š” ๋ผ์ธ ์ฐพ๊ธฐ
121
+ if line.startswith('โ€ข') or (len(line) > 2 and ord(line[0]) >= 0x1F300):
122
+ bullet_points.append(line)
123
+
124
+ # ๋ฐœํ‘œ์ž ๋…ธํŠธ ์ถ”์ถœ - ๊ฐœ์„ ๋œ ํŒจํ„ด
125
+ speaker_notes = ""
126
+ notes_patterns = [
127
+ r'๋ฐœํ‘œ์ž ๋…ธํŠธ:\s*(.+?)(?=\n\n|\n๋ฐœํ‘œ์ž ๋…ธํŠธ:|\n\[์Šฌ๋ผ์ด๋“œ|\Z)',
128
+ r'Speaker Notes:\s*(.+?)(?=\n\n|\nSpeaker Notes:|\n\[Slide|\Z)',
129
+ r'๋ฐœํ‘œ์ž๋…ธํŠธ:\s*(.+?)(?=\n\n|\n๋ฐœํ‘œ์ž๋…ธํŠธ:|\n\[์Šฌ๋ผ์ด๋“œ|\Z)',
130
+ r'Notes:\s*(.+?)(?=\n\n|\nNotes:|\n\[Slide|\Z)',
131
+ ]
132
+
133
+ for pattern in notes_patterns:
134
+ notes_match = re.search(pattern, slide_content, re.DOTALL | re.MULTILINE)
135
+ if notes_match:
136
+ speaker_notes = notes_match.group(1).strip()
137
+ # ์—ฌ๏ฟฝ๏ฟฝ๏ฟฝ ์ค„์˜ ๋…ธํŠธ๋ฅผ ํ•ฉ์น˜๊ธฐ
138
+ speaker_notes = ' '.join(speaker_notes.split('\n'))
139
+ if speaker_notes and len(speaker_notes) > 20: # ์ตœ์†Œ 20์ž ์ด์ƒ์˜ ์˜๋ฏธ์žˆ๋Š” ๋…ธํŠธ
140
+ break
141
+
142
+ # ๋ฐœํ‘œ์ž ๋…ธํŠธ๊ฐ€ ๋„ˆ๋ฌด ์งง์œผ๋ฉด ๋” ์ฐพ๊ธฐ
143
+ if len(speaker_notes) < 50:
144
+ # "๋ฐœํ‘œ์ž ๋…ธํŠธ:" ๋‹ค์Œ์˜ ๋ชจ๋“  ํ…์ŠคํŠธ ์ฐพ๊ธฐ
145
+ notes_start = slide_content.find("๋ฐœํ‘œ์ž ๋…ธํŠธ:")
146
+ if notes_start == -1:
147
+ notes_start = slide_content.find("Speaker Notes:")
148
+ if notes_start == -1:
149
+ notes_start = slide_content.find("๋ฐœํ‘œ์ž๋…ธํŠธ:")
150
+
151
+ if notes_start > -1:
152
+ notes_text = slide_content[notes_start:].split(":", 1)
153
+ if len(notes_text) > 1:
154
+ speaker_notes = notes_text[1].strip()
155
+ # ๋‹ค์Œ ์„น์…˜ ์‹œ์ž‘ ์ „๊นŒ์ง€์˜ ํ…์ŠคํŠธ ๊ฐ€์ ธ์˜ค๊ธฐ
156
+ next_section_markers = ["์‹œ๊ฐ ์ž๋ฃŒ:", "Visual:", "์ œ๋ชฉ:", "Title:", "[์Šฌ๋ผ์ด๋“œ", "[Slide"]
157
+ for marker in next_section_markers:
158
+ marker_pos = speaker_notes.find(marker)
159
+ if marker_pos > 0:
160
+ speaker_notes = speaker_notes[:marker_pos].strip()
161
+ break
162
+ speaker_notes = ' '.join(speaker_notes.split('\n')).strip()
163
+
164
+ parsed_data[slide_num - 1] = {
165
+ "title": title,
166
+ "subtitle": subtitle,
167
+ "bullet_points": bullet_points,
168
+ "speaker_notes": speaker_notes
169
+ }
170
+
171
+ except Exception as e:
172
+ logger.error(f"[Parser] ์Šฌ๋ผ์ด๋“œ ํŒŒ์‹ฑ ์ค‘ ์˜ค๋ฅ˜: {str(e)}")
173
+
174
+ return parsed_data
175
+
176
+ def extract_relevant_content_from_executor(executor_response: str, keywords: List[str], slide_num: int, slide_title: str) -> Dict:
177
+ """์‹คํ–‰์ž ์‘๋‹ต์—์„œ ํŠน์ • ์Šฌ๋ผ์ด๋“œ์™€ ๊ด€๋ จ๋œ ๋‚ด์šฉ ์ถ”์ถœ"""
178
+ try:
179
+ # ์—ฌ๋Ÿฌ ๋ฐฉ๋ฒ•์œผ๋กœ ๊ด€๋ จ ๋‚ด์šฉ ์ฐพ๊ธฐ
180
+
181
+ # 1. ์Šฌ๋ผ์ด๋“œ ๋ฒˆํ˜ธ๋กœ ์ฐพ๊ธฐ
182
+ slide_patterns = [
183
+ f"\\[์Šฌ๋ผ์ด๋“œ\\s*{slide_num}\\]([\\s\\S]*?)(?=\\[์Šฌ๋ผ์ด๋“œ|$)",
184
+ f"\\[Slide\\s*{slide_num}\\]([\\s\\S]*?)(?=\\[Slide|$)",
185
+ f"Slide\\s*{slide_num}:([\\s\\S]*?)(?=Slide\\s*\\d+:|$)"
186
+ ]
187
+
188
+ for pattern in slide_patterns:
189
+ match = re.search(pattern, executor_response, re.IGNORECASE | re.MULTILINE)
190
+ if match:
191
+ section = match.group(1)
192
+ parsed = parse_slide_section(section, slide_title)
193
+ if parsed and len(parsed.get("bullet_points", [])) > 0:
194
+ return parsed
195
+
196
+ # 2. ํ‚ค์›Œ๋“œ๋กœ ์ฐพ๊ธฐ
197
+ for keyword in keywords:
198
+ if not keyword:
199
+ continue
200
+
201
+ # ํ‚ค์›Œ๋“œ ์ฃผ๋ณ€์—์„œ ๋ถˆ๋ฆฟ ํฌ์ธํŠธ ์ฐพ๊ธฐ
202
+ keyword_pos = executor_response.lower().find(keyword.lower())
203
+ if keyword_pos >= 0:
204
+ # ํ‚ค์›Œ๋“œ ์ „ํ›„ 1000์ž ๋ฒ”์œ„์—์„œ ์ฐพ๊ธฐ
205
+ start = max(0, keyword_pos - 300)
206
+ end = min(len(executor_response), keyword_pos + 1000)
207
+ context = executor_response[start:end]
208
+
209
+ # ๋ถˆ๋ฆฟ ํฌ์ธํŠธ ์ถ”์ถœ
210
+ bullet_points = []
211
+ lines = context.split('\n')
212
+
213
+ for line in lines:
214
+ line = line.strip()
215
+ if not line:
216
+ continue
217
+
218
+ # ๋ถˆ๋ฆฟ ํฌ์ธํŠธ ํŒจํ„ด
219
+ if (line.startswith(('โ€ข', '-', '*', 'ยท')) or
220
+ re.match(r'^\d+\.', line) or
221
+ (len(line) > 10 and not ':' in line and not line.startswith(('[', '์ œ๋ชฉ', 'Title', '๋ถ€์ œ', 'Subtitle')))):
222
+
223
+ clean_line = re.sub(r'^[โ€ข\-\*ยท\d+\.]', '', line).strip()
224
+ if clean_line and len(clean_line) > 5 and not any(skip in clean_line for skip in ["Point", "ํฌ์ธํŠธ"]):
225
+ bullet_points.append(f"โ€ข {clean_line}")
226
+
227
+ if len(bullet_points) >= 3:
228
+ return {
229
+ "subtitle": keyword,
230
+ "bullet_points": bullet_points[:5],
231
+ "speaker_notes": f"{slide_title}์— ๋Œ€ํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค."
232
+ }
233
+
234
+ except Exception as e:
235
+ logger.error(f"์‹คํ–‰์ž ์‘๋‹ต์—์„œ ์ฝ˜ํ…์ธ  ์ถ”์ถœ ์ค‘ ์˜ค๋ฅ˜: {str(e)}")
236
+
237
+ return None
238
+
239
+ def extract_slide_section_from_executor(executor_response: str, slide_num: int) -> str:
240
+ """์‹คํ–‰์ž ์‘๋‹ต์—์„œ ํŠน์ • ์Šฌ๋ผ์ด๋“œ ์„น์…˜ ์ถ”์ถœ"""
241
+ try:
242
+ # ๋‹ค์–‘ํ•œ ์Šฌ๋ผ์ด๋“œ ๊ตฌ๋ถ„ ํŒจ๏ฟฝ๏ฟฝ
243
+ patterns = [
244
+ f"\\[์Šฌ๋ผ์ด๋“œ\\s*{slide_num}\\]([\\s\\S]*?)(?=\\[์Šฌ๋ผ์ด๋“œ\\s*{slide_num+1}\\]|$)",
245
+ f"\\[Slide\\s*{slide_num}\\]([\\s\\S]*?)(?=\\[Slide\\s*{slide_num+1}\\]|$)",
246
+ f"Slide\\s*{slide_num}:([\\s\\S]*?)(?=Slide\\s*{slide_num+1}:|$)",
247
+ f"์Šฌ๋ผ์ด๋“œ\\s*{slide_num}\\.([\\s\\S]*?)(?=์Šฌ๋ผ์ด๋“œ\\s*{slide_num+1}\\.|$)"
248
+ ]
249
+
250
+ for pattern in patterns:
251
+ match = re.search(pattern, executor_response, re.IGNORECASE | re.MULTILINE)
252
+ if match:
253
+ return match.group(0) # ์ „์ฒด ๋งค์น˜ ๋ฐ˜ํ™˜ (์Šฌ๋ผ์ด๋“œ ๋ฒˆํ˜ธ ํฌํ•จ)
254
+
255
+ except Exception as e:
256
+ logger.error(f"์Šฌ๋ผ์ด๋“œ ์„น์…˜ ์ถ”์ถœ ์ค‘ ์˜ค๋ฅ˜: {str(e)}")
257
+
258
+ return ""
259
+
260
+ def parse_slide_section(section: str, default_title: str) -> Dict:
261
+ """์Šฌ๋ผ์ด๋“œ ์„น์…˜์—์„œ ์ฝ˜ํ…์ธ  ํŒŒ์‹ฑ"""
262
+ try:
263
+ content = {
264
+ "subtitle": default_title,
265
+ "bullet_points": []
266
+ }
267
+
268
+ lines = section.split('\n')
269
+ in_content_section = False
270
+
271
+ for line in lines:
272
+ line = line.strip()
273
+ if not line:
274
+ continue
275
+
276
+ # ๋ถ€์ œ๋ชฉ ์ฐพ๊ธฐ
277
+ if any(marker in line for marker in ['๋ถ€์ œ๋ชฉ:', 'Subtitle:', '๋ถ€์ œ:']):
278
+ subtitle = line.split(':', 1)[1].strip() if ':' in line else ""
279
+ if subtitle:
280
+ content["subtitle"] = subtitle
281
+
282
+ # ํ•ต์‹ฌ ๋‚ด์šฉ ์„น์…˜ ์‹œ์ž‘
283
+ elif any(marker in line for marker in ['ํ•ต์‹ฌ ๋‚ด์šฉ:', 'Key Points:', '๋‚ด์šฉ:', 'Content:']):
284
+ in_content_section = True
285
+
286
+ # ๋‹ค๋ฅธ ์„น์…˜ ์‹œ์ž‘ ์‹œ ์ค‘๋‹จ
287
+ elif any(marker in line for marker in ['๋ฐœํ‘œ์ž ๋…ธํŠธ:', 'Speaker Notes:', '์‹œ๊ฐ ์ž๋ฃŒ:', 'Visual:']):
288
+ in_content_section = False
289
+
290
+ # ๋ถˆ๋ฆฟ ํฌ์ธํŠธ ์ˆ˜์ง‘
291
+ elif in_content_section or (
292
+ (line.startswith(('โ€ข', '-', '*', 'ยท')) or re.match(r'^\d+\.', line)) and
293
+ len(line) > 10
294
+ ):
295
+ clean_line = re.sub(r'^[โ€ข\-\*ยท\d+\.]', '', line).strip()
296
+ if clean_line and not any(skip in clean_line for skip in ["Point", "ํฌ์ธํŠธ", ":", "์ œ๋ชฉ", "Title"]):
297
+ content["bullet_points"].append(f"โ€ข {clean_line}")
298
+
299
+ return content if len(content["bullet_points"]) > 0 else None
300
+
301
+ except Exception as e:
302
+ logger.error(f"์Šฌ๋ผ์ด๋“œ ์„น์…˜ ํŒŒ์‹ฑ ์ค‘ ์˜ค๋ฅ˜: {str(e)}")
303
+ return None
304
+
305
+ def extract_speaker_notes_from_section(section: str) -> str:
306
+ """์Šฌ๋ผ์ด๋“œ ์„น์…˜์—์„œ ๋ฐœํ‘œ์ž ๋…ธํŠธ ์ถ”์ถœ"""
307
+ try:
308
+ patterns = [
309
+ r'๋ฐœํ‘œ์ž ๋…ธํŠธ:\s*(.+?)(?=์‹œ๊ฐ ์ž๋ฃŒ:|Visual:|\n์ œ๋ชฉ:|\nTitle:|\n\[์Šฌ๋ผ์ด๋“œ|\n\[Slide|$)',
310
+ r'Speaker Notes:\s*(.+?)(?=Visual:|์‹œ๊ฐ ์ž๋ฃŒ:|\nTitle:|\n์ œ๋ชฉ:|\n\[Slide|\n\[์Šฌ๋ผ์ด๋“œ|$)',
311
+ r'Notes:\s*(.+?)(?=Visual:|\nTitle:|$)',
312
+ r'๋ฐœํ‘œ์ž๋…ธํŠธ:\s*(.+?)(?=์‹œ๊ฐ ์ž๋ฃŒ:|Visual:|$)'
313
+ ]
314
+
315
+ for pattern in patterns:
316
+ match = re.search(pattern, section, re.DOTALL | re.MULTILINE)
317
+ if match:
318
+ notes = match.group(1).strip()
319
+ # ์—ฌ๋Ÿฌ ์ค„์˜ ๋…ธํŠธ๋ฅผ ํ•˜๋‚˜๋กœ ํ•ฉ์น˜๊ธฐ
320
+ notes = ' '.join(notes.split('\n')).strip()
321
+ if notes and len(notes) > 20: # ์ตœ์†Œ 20์ž ์ด์ƒ์˜ ์˜๋ฏธ์žˆ๋Š” ๋…ธํŠธ
322
+ return notes
323
+
324
+ # ํŒจํ„ด ๋งค์นญ ์‹คํŒจ์‹œ ๋” ๋„“์€ ๋ฒ”์œ„๋กœ ์ฐพ๊ธฐ
325
+ notes_markers = ["๋ฐœํ‘œ์ž ๋…ธํŠธ:", "Speaker Notes:", "๋ฐœํ‘œ์ž๋…ธํŠธ:", "Notes:"]
326
+ for marker in notes_markers:
327
+ marker_pos = section.find(marker)
328
+ if marker_pos > -1:
329
+ notes_text = section[marker_pos + len(marker):].strip()
330
+ # ๋‹ค์Œ ์„น์…˜ ์‹œ์ž‘ ์ „๊นŒ์ง€์˜ ํ…์ŠคํŠธ ๊ฐ€์ ธ์˜ค๊ธฐ
331
+ end_markers = ["์‹œ๊ฐ ์ž๋ฃŒ:", "Visual:", "์ œ๋ชฉ:", "Title:", "[์Šฌ๋ผ์ด๋“œ", "[Slide", "\n\n"]
332
+ min_end_pos = len(notes_text)
333
+ for end_marker in end_markers:
334
+ end_pos = notes_text.find(end_marker)
335
+ if end_pos > 0 and end_pos < min_end_pos:
336
+ min_end_pos = end_pos
337
+
338
+ notes_text = notes_text[:min_end_pos].strip()
339
+ notes_text = ' '.join(notes_text.split('\n')).strip()
340
+
341
+ if notes_text and len(notes_text) > 20:
342
+ return notes_text
343
+
344
+ except Exception as e:
345
+ logger.error(f"๋ฐœํ‘œ์ž ๋…ธํŠธ ์ถ”์ถœ ์ค‘ ์˜ค๋ฅ˜: {str(e)}")
346
+
347
+ return ""
348
+
349
+ def extract_relevant_content(executor_response: str, keywords: List[str], slide_num: int) -> Dict:
350
+ """์‹คํ–‰์ž ์‘๋‹ต์—์„œ ํŠน์ • ์Šฌ๋ผ์ด๋“œ์™€ ๊ด€๋ จ๋œ ๋‚ด์šฉ ์ถ”์ถœ"""
351
+ try:
352
+ # ํ‚ค์›Œ๋“œ ๊ธฐ๋ฐ˜์œผ๋กœ ๊ด€๋ จ ์„น์…˜ ์ฐพ๊ธฐ
353
+ for keyword in keywords:
354
+ if not keyword:
355
+ continue
356
+
357
+ # ํ‚ค์›Œ๋“œ ์ฃผ๋ณ€ ํ…์ŠคํŠธ ์ฐพ๊ธฐ
358
+ keyword_lower = keyword.lower()
359
+ response_lower = executor_response.lower()
360
+
361
+ if keyword_lower in response_lower:
362
+ # ํ‚ค์›Œ๋“œ ์œ„์น˜ ์ฐพ๊ธฐ
363
+ pos = response_lower.find(keyword_lower)
364
+
365
+ # ์ฃผ๋ณ€ ํ…์ŠคํŠธ ์ถ”์ถœ (์•ž๋’ค 500์ž)
366
+ start = max(0, pos - 200)
367
+ end = min(len(executor_response), pos + 800)
368
+ context = executor_response[start:end]
369
+
370
+ # ๋ถˆ๋ฆฟ ํฌ์ธํŠธ ์ถ”์ถœ
371
+ bullet_points = []
372
+ lines = context.split('\n')
373
+ for line in lines:
374
+ line = line.strip()
375
+ if line.startswith(('โ€ข', '-', '*')) or re.match(r'^\d+\.', line):
376
+ clean_line = re.sub(r'^[โ€ข\-\*\d+\.]', '', line).strip()
377
+ if clean_line and len(clean_line) > 5:
378
+ bullet_points.append(f"โ€ข {clean_line}")
379
+
380
+ if bullet_points:
381
+ return {
382
+ "subtitle": keyword,
383
+ "bullet_points": bullet_points[:5], # ์ตœ๋Œ€ 5๊ฐœ
384
+ "speaker_notes": f"์Šฌ๋ผ์ด๋“œ {slide_num}์— ๋Œ€ํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค."
385
+ }
386
+
387
+ except Exception as e:
388
+ logger.error(f"๊ด€๋ จ ์ฝ˜ํ…์ธ  ์ถ”์ถœ ์ค‘ ์˜ค๋ฅ˜: {str(e)}")
389
+
390
+ return None
391
+
392
+ def read_uploaded_file(file_path: str) -> str:
393
+ """Read uploaded file (PDF, CSV, TXT)"""
394
+ print(f"[File Reading] {file_path}")
395
+
396
+ try:
397
+ ext = file_path.lower().rsplit('.', 1)[-1] if '.' in file_path else ''
398
+
399
+ if ext == 'pdf':
400
+ with open(file_path, 'rb') as file:
401
+ pdf_reader = PyPDF2.PdfReader(file)
402
+ text = ""
403
+ for page in pdf_reader.pages:
404
+ text += page.extract_text() + "\n"
405
+ return text[:5000]
406
+
407
+ elif ext == 'csv':
408
+ with open(file_path, 'rb') as file:
409
+ raw_data = file.read()
410
+ result = chardet.detect(raw_data)
411
+ encoding = result['encoding'] or 'utf-8'
412
+
413
+ df = pd.read_csv(file_path, encoding=encoding)
414
+ return f"CSV Data:\n{df.head(20).to_string()}\n\nSummary: {len(df)} rows, {len(df.columns)} columns"
415
+
416
+ elif ext in ['txt', 'text']:
417
+ with open(file_path, 'rb') as file:
418
+ raw_data = file.read()
419
+ result = chardet.detect(raw_data)
420
+ encoding = result['encoding'] or 'utf-8'
421
+
422
+ with open(file_path, 'r', encoding=encoding) as file:
423
+ return file.read()[:5000]
424
+ else:
425
+ return "Unsupported file format."
426
+
427
+ except Exception as e:
428
+ return f"File reading error: {str(e)}"
429
+
430
+ def generate_dynamic_slides(topic: str, template: Dict, slide_count: int) -> List[Dict]:
431
+ """Dynamically generate slides based on selected count"""
432
+ core_slides = template.get("core_slides", [])
433
+ optional_slides = template.get("optional_slides", [])
434
+
435
+ # Content slide count
436
+ content_slide_count = slide_count
437
+
438
+ # Adjust if core slides exceed requested count
439
+ if len(core_slides) > content_slide_count:
440
+ selected_slides = core_slides[:content_slide_count]
441
+ else:
442
+ # Core slides + optional slides
443
+ selected_slides = core_slides.copy()
444
+ remaining = content_slide_count - len(core_slides)
445
+
446
+ if remaining > 0 and optional_slides:
447
+ # Add from optional slides
448
+ additional = optional_slides[:remaining]
449
+ selected_slides.extend(additional)
450
+
451
+ # Add cover slide (first)
452
+ slides = [{"title": "Cover", "style": "Title Slide (Hero)", "prompt_hint": "Presentation cover"}]
453
+
454
+ # Add content slides
455
+ slides.extend(selected_slides)
456
+
457
+ # Add Thank You slide (last)
458
+ slides.append({"title": "Thank You", "style": "Thank You Slide", "prompt_hint": "Presentation closing and key message"})
459
+
460
+ return slides
461
+
462
+ def brave_search(query: str, api_token: str = None) -> List[Dict]:
463
+ """Web search using Brave Search API"""
464
+ if not api_token:
465
+ print("[Brave Search] No API token, skipping search.")
466
+ return []
467
+
468
+ print(f"[Brave Search] Query: {query}")
469
+
470
+ headers = {
471
+ "Accept": "application/json",
472
+ "X-Subscription-Token": api_token
473
+ }
474
+
475
+ params = {
476
+ "q": query,
477
+ "count": 5
478
+ }
479
+
480
+ try:
481
+ response = requests.get(
482
+ "https://api.search.brave.com/res/v1/web/search",
483
+ headers=headers,
484
+ params=params,
485
+ timeout=10
486
+ )
487
+
488
+ if response.status_code == 200:
489
+ data = response.json()
490
+ results = []
491
+ for item in data.get("web", {}).get("results", [])[:3]:
492
+ results.append({
493
+ "title": item.get("title", ""),
494
+ "description": item.get("description", ""),
495
+ "url": item.get("url", "")
496
+ })
497
+ print(f"[Brave Search] Got {len(results)} results")
498
+ return results
499
+ else:
500
+ print(f"[Brave Search] Error: {response.status_code}")
501
+ return []
502
+ except Exception as e:
503
+ print(f"[Brave Search] Exception: {str(e)}")
504
+ return []
505
+
506
+ def generate_slide_content(topic: str, slide_title: str, slide_context: str, audience_type: str,
507
+ language: str = "English", uploaded_content: str = None,
508
+ web_search_results: List[Dict] = None, friendli_token: str = None,
509
+ api_url: str = None, model_id: str = None,
510
+ audience_types: Dict = None) -> Dict[str, str]:
511
+ """Generate text content for each slide"""
512
+
513
+ audience_info = audience_types.get(audience_type, {}) if audience_types else {}
514
+
515
+ system_prompt = f"""๋‹น์‹ ์€ PPT ์Šฌ๋ผ์ด๋“œ ์ฝ˜ํ…์ธ  ์ž‘์„ฑ ์ „๋ฌธ๊ฐ€์ž…๋‹ˆ๋‹ค.
516
+
517
+ ์ฒญ์ค‘: {audience_type}
518
+ ์–ธ์–ด: {language}
519
+
520
+ ์ž‘์„ฑ ๊ทœ์น™:
521
+ 1. ๋ถ€์ œ๋ชฉ: ์ตœ๋Œ€ 10๋‹จ์–ด
522
+ 2. ๊ฐ ๋ถˆ๋ฆฟ ํฌ์ธํŠธ๋Š” ๋ฐ˜๋“œ์‹œ ๊ด€๋ จ ์ด๋ชจ์ง€๋กœ ์‹œ์ž‘
523
+ 3. ์ด๋ชจ์ง€ ๋‹ค์Œ์— ๋ฐ”๋กœ ๋‚ด์šฉ (โ€ข ๊ธฐํ˜ธ ์ œ์™ธ)
524
+ 4. ๊ฐ ํฌ์ธํŠธ๋Š” 8-12๋‹จ์–ด๋กœ ๊ฐ„๊ฒฐํ•˜๊ฒŒ
525
+ 5. ๋ช…์‚ฌํ˜• ์ข…๊ฒฐ ์‚ฌ์šฉ
526
+
527
+ ์ถœ๋ ฅ ํ˜•์‹:
528
+ Subtitle: [๋ถ€์ œ๋ชฉ]
529
+ ๐ŸŽฏ [์ฒซ ๋ฒˆ์งธ ํฌ์ธํŠธ ๋‚ด์šฉ]
530
+ ๐Ÿ’ก [๋‘ ๋ฒˆ์งธ ํฌ์ธํŠธ ๋‚ด์šฉ]
531
+ ๐Ÿš€ [์„ธ ๋ฒˆ์งธ ํฌ์ธํŠธ ๋‚ด์šฉ]
532
+ โœ… [๋„ค ๋ฒˆ์งธ ํฌ์ธํŠธ ๋‚ด์šฉ]
533
+ ๐Ÿ“Š [๋‹ค์„ฏ ๋ฒˆ์งธ ํฌ์ธํŠธ ๋‚ด์šฉ]
534
+
535
+ ์ฒญ์ค‘๋ณ„ ์ด๋ชจ์ง€ ๊ฐ€์ด๋“œ:
536
+ - ๊ฒฝ์˜์ง„: ๐Ÿ“Š ๐ŸŽฏ ๐Ÿ’ฐ ๐Ÿ† ๐Ÿš€ ๐Ÿ“ˆ ๐Ÿ” ๐Ÿ’ก
537
+ - ํˆฌ์ž์ž: ๐Ÿ’ฐ ๐Ÿ“ˆ ๐Ÿ’Ž ๐Ÿฆ ๐Ÿ’ธ ๐Ÿ“Š ๐Ÿš€ ๐Ÿ”’
538
+ - ๊ธฐ์ˆ ํŒ€: ๐Ÿ”ง ๐Ÿ’ป ๐Ÿ› ๏ธ โš™๏ธ ๐Ÿ” ๐ŸŒ ๐Ÿ“ฑ ๐Ÿค–
539
+ - ์ผ๋ฐ˜์ง์›: ๐Ÿค ๐Ÿ’ก ๐Ÿ“‹ โœ… ๐ŸŽฏ ๐ŸŒŸ ๐Ÿ“… ๐Ÿ’ช
540
+ - ๊ณ ๊ฐ: โญ ๐ŸŽ ๐Ÿ’ ๐Ÿ›ก๏ธ ๐ŸŒŸ โœจ ๐Ÿ… ๐Ÿ‘
541
+ - ์ผ๋ฐ˜๋Œ€์ค‘: ๐Ÿ˜Š ๐Ÿ  ๐ŸŒ โค๏ธ ๐ŸŽ‰ ๐ŸŒˆ โœจ ๐ŸŽฏ"""
542
+
543
+ user_message = f"""Topic: {topic}
544
+ Slide Title: {slide_title}
545
+ Context: {slide_context}
546
+ Target Audience: {audience_type}
547
+ Language: {language}"""
548
+
549
+ if uploaded_content:
550
+ user_message += f"\n\nReference Material:\n{uploaded_content[:1000]}"
551
+
552
+ if web_search_results:
553
+ search_context = "\n\nWeb Search Results:\n"
554
+ try:
555
+ if isinstance(web_search_results, list) and len(web_search_results) > 0:
556
+ for i, result in enumerate(web_search_results[:3]):
557
+ if isinstance(result, dict):
558
+ search_context += f"- {result.get('title', 'N/A')}: {result.get('description', 'N/A')}\n"
559
+ user_message += search_context
560
+ except Exception as e:
561
+ print(f"[Slide Content] Error processing search results: {str(e)}")
562
+
563
+ user_message += f"\n\nCreate compelling content for this presentation slide specifically tailored for {audience_type} in {language}. Remember to write COMPLETE bullet points, NOT placeholders like 'Point 1'!"
564
+
565
+ headers = {
566
+ "Authorization": f"Bearer {friendli_token}",
567
+ "Content-Type": "application/json"
568
+ }
569
+
570
+ payload = {
571
+ "model": model_id,
572
+ "messages": [
573
+ {
574
+ "role": "system",
575
+ "content": system_prompt
576
+ },
577
+ {
578
+ "role": "user",
579
+ "content": user_message
580
+ }
581
+ ],
582
+ "max_tokens": 400,
583
+ "top_p": 0.8,
584
+ "temperature": 0.7,
585
+ "stream": False
586
+ }
587
+
588
+ try:
589
+ response = requests.post(api_url, json=payload, headers=headers, timeout=30)
590
+ if response.status_code == 200:
591
+ result = response.json()
592
+ content = result['choices'][0]['message']['content'].strip()
593
+
594
+ print(f"[Slide Content] LLM Response:\n{content}")
595
+
596
+ # ๊ฐœ์„ ๋œ ํŒŒ์‹ฑ ๋กœ์ง
597
+ lines = content.split('\n')
598
+ subtitle = ""
599
+ bullet_points = []
600
+
601
+ for line in lines:
602
+ line = line.strip()
603
+ if not line:
604
+ continue
605
+
606
+ # Subtitle ํŒŒ์‹ฑ
607
+ if line.lower().startswith("subtitle:") or line.startswith("Subtitle:") or line.startswith("๋ถ€์ œ๋ชฉ:"):
608
+ subtitle = line.split(':', 1)[1].strip()
609
+ # Bullet point ํŒŒ์‹ฑ
610
+ elif line.startswith("โ€ข") or line.startswith("-") or (len(line) > 2 and line[1] in [' ', '\t'] and ord(line[0]) >= 128):
611
+ # ์ด๋ฏธ โ€ข ๋กœ ์‹œ์ž‘ํ•˜์ง€ ์•Š์œผ๋ฉด ์ถ”๊ฐ€
612
+ if not line.startswith("โ€ข"):
613
+ line = "โ€ข " + line.lstrip("- ")
614
+
615
+ # "Point X" ํŒจํ„ด ์ฒดํฌ ๋ฐ ๊ฑฐ๋ถ€
616
+ if not any(placeholder in line for placeholder in ["Point 1", "Point 2", "Point 3", "Point 4", "Point 5", "๐Ÿ“Œ Point"]):
617
+ bullet_points.append(line)
618
+
619
+ # Subtitle์ด ์—†์œผ๋ฉด ๊ธฐ๋ณธ๊ฐ’
620
+ if not subtitle:
621
+ subtitle = f"{slide_title} Overview"
622
+
623
+ # ๋ถˆ๋ฆฟ ํฌ์ธํŠธ๊ฐ€ ๋ถ€์กฑํ•˜๋ฉด ์žฌ์‹œ๋„ ๋˜๋Š” ๊ธฐ๋ณธ๊ฐ’
624
+ if len(bullet_points) < 5:
625
+ print(f"[Slide Content] Warning: Only {len(bullet_points)} bullet points found. Retrying...")
626
+
627
+ # ์žฌ์‹œ๋„๋ฅผ ์œ„ํ•œ ๋” ๋ช…ํ™•ํ•œ ํ”„๋กฌํ”„ํŠธ
628
+ retry_message = f"""The previous response didn't include 5 complete bullet points.
629
+ Please provide EXACTLY 5 bullet points for the slide titled "{slide_title}" about "{topic}".
630
+
631
+ Each bullet must be:
632
+ - A complete, meaningful statement (NOT "Point 1", "Point 2", etc.)
633
+ - 8-12 words long
634
+ - Starting with an emoji
635
+ - Relevant to {audience_type}
636
+ - In {language}
637
+
638
+ Example format:
639
+ - ๐Ÿ“Š Increased efficiency through automated processes
640
+ - ๐Ÿ’ฐ 30% cost reduction in operations
641
+ - ๐Ÿš€ Faster response times for customers
642
+ - ๐Ÿ”ง Seamless integration with existing systems
643
+ - ๐Ÿ“ˆ Measurable ROI within 6 months"""
644
+
645
+ retry_payload = {
646
+ "model": model_id,
647
+ "messages": [
648
+ {"role": "system", "content": system_prompt},
649
+ {"role": "user", "content": retry_message}
650
+ ],
651
+ "max_tokens": 300,
652
+ "temperature": 0.8,
653
+ "stream": False
654
+ }
655
+
656
+ try:
657
+ retry_response = requests.post(api_url, json=retry_payload, headers=headers, timeout=30)
658
+ if retry_response.status_code == 200:
659
+ retry_result = retry_response.json()
660
+ retry_content = retry_result['choices'][0]['message']['content'].strip()
661
+
662
+ # ์žฌ์‹œ๋„ ํŒŒ์‹ฑ
663
+ retry_lines = retry_content.split('\n')
664
+ bullet_points = []
665
+ for line in retry_lines:
666
+ line = line.strip()
667
+ if line and (line.startswith("โ€ข") or line.startswith("-") or (len(line) > 2 and ord(line[0]) >= 128)):
668
+ if not line.startswith("โ€ข"):
669
+ line = "โ€ข " + line.lstrip("- ")
670
+ if not any(placeholder in line for placeholder in ["Point 1", "Point 2", "Point 3", "Point 4", "Point 5"]):
671
+ bullet_points.append(line)
672
+ except:
673
+ pass
674
+
675
+ # ์—ฌ์ „ํžˆ ๋ถ€์กฑํ•˜๋ฉด ์˜๋ฏธ์žˆ๋Š” ๊ธฐ๋ณธ๊ฐ’ ์ƒ์„ฑ
676
+ default_bullets = {
677
+ "English": [
678
+ "โ€ข ๐Ÿ“Š Data-driven insights for better decisions",
679
+ "โ€ข ๐Ÿ’ก Innovative solutions to complex challenges",
680
+ "โ€ข ๐Ÿš€ Accelerated growth through optimization",
681
+ "โ€ข ๐ŸŽฏ Targeted strategies for maximum impact",
682
+ "โ€ข โœ… Proven results with measurable outcomes"
683
+ ],
684
+ "Korean": [
685
+ "โ€ข ๐Ÿ“Š ๋ฐ์ดํ„ฐ ๊ธฐ๋ฐ˜ ์˜์‚ฌ๊ฒฐ์ • ์ง€์›",
686
+ "โ€ข ๐Ÿ’ก ๋ณต์žกํ•œ ๋ฌธ์ œ์— ๋Œ€ํ•œ ํ˜์‹ ์  ํ•ด๊ฒฐ์ฑ…",
687
+ "โ€ข ๐Ÿš€ ์ตœ์ ํ™”๋ฅผ ํ†ตํ•œ ์„ฑ์žฅ ๊ฐ€์†ํ™”",
688
+ "โ€ข ๐ŸŽฏ ์ตœ๋Œ€ ํšจ๊ณผ๋ฅผ ์œ„ํ•œ ํƒ€๊ฒŸ ์ „๋žต",
689
+ "โ€ข โœ… ์ธก์ • ๊ฐ€๋Šฅํ•œ ๊ฒ€์ฆ๋œ ๊ฒฐ๊ณผ"
690
+ ]
691
+ }
692
+
693
+ while len(bullet_points) < 5:
694
+ default_idx = len(bullet_points)
695
+ if default_idx < len(default_bullets.get(language, default_bullets["English"])):
696
+ bullet_points.append(default_bullets[language][default_idx])
697
+ else:
698
+ bullet_points.append(f"โ€ข โšก Key insight {len(bullet_points) + 1}")
699
+
700
+ bullet_points = bullet_points[:5]
701
+
702
+ print(f"[Slide Content] Final subtitle: {subtitle}")
703
+ print(f"[Slide Content] Final bullets: {bullet_points}")
704
+
705
+ return {
706
+ "subtitle": subtitle,
707
+ "bullet_points": bullet_points
708
+ }
709
+ else:
710
+ print(f"[Slide Content] API Error: {response.status_code}")
711
+ return {
712
+ "subtitle": slide_title,
713
+ "bullet_points": [
714
+ "โ€ข ๐Ÿ“Š Strategic insights and analysis",
715
+ "โ€ข ๐Ÿ’ก Innovative approaches and solutions",
716
+ "โ€ข ๐Ÿš€ Growth opportunities identified",
717
+ "โ€ข ๐ŸŽฏ Targeted implementation strategies",
718
+ "โ€ข โœ… Measurable success metrics"
719
+ ]
720
+ }
721
+ except Exception as e:
722
+ print(f"[Slide Content] Error: {str(e)}")
723
+ return {
724
+ "subtitle": slide_title,
725
+ "bullet_points": [
726
+ "โ€ข ๐Ÿ“Š Key strategic insights",
727
+ "โ€ข ๐Ÿ’ก Innovative solutions proposed",
728
+ "โ€ข ๐Ÿš€ Growth acceleration opportunities",
729
+ "โ€ข ๐ŸŽฏ Targeted action plans",
730
+ "โ€ข โœ… Success measurement framework"
731
+ ]
732
+ }
733
+
734
+ def generate_presentation_notes(topic: str, slide_title: str, content: Dict, audience_type: str,
735
+ language: str = "English", friendli_token: str = None,
736
+ api_url: str = None, model_id: str = None,
737
+ audience_types: Dict = None) -> str:
738
+ """Generate speaker notes for each slide"""
739
+ print(f"[Speaker Notes] Generating for {slide_title}...")
740
+
741
+ audience_info = audience_types.get(audience_type, {}) if audience_types else {}
742
+
743
+ headers = {
744
+ "Authorization": f"Bearer {friendli_token}",
745
+ "Content-Type": "application/json"
746
+ }
747
+
748
+ if language == "Korean":
749
+ system_prompt = f"""๋‹น์‹ ์€ ์ž์—ฐ์Šค๋Ÿฌ์šด ํ•œ๊ตญ์–ด ๊ตฌ์–ด์ฒด๋กœ ๋ฐœํ‘œํ•˜๋Š” ์ „๋ฌธ ํ”„๋ ˆ์  ํ„ฐ์ž…๋‹ˆ๋‹ค.
750
+
751
+ ์ฒญ์ค‘: {audience_type} - {audience_info.get('description', '')}
752
+ ์–ธ์–ด: ํ•œ๊ตญ์–ด
753
+
754
+ ๋ฐœํ‘œ์ž ๋…ธํŠธ ์ž‘์„ฑ ๊ทœ์น™:
755
+ 1. ์™„์ „ํ•œ ๊ตฌ์–ด์ฒด๋กœ ์ž‘์„ฑ (๋งˆ์น˜ ์‹ค์ œ๋กœ ๋งํ•˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ)
756
+ 2. ์ฒญ์ค‘๊ณผ ์†Œํ†ตํ•˜๋Š” ๋А๋‚Œ์˜ ์ž์—ฐ์Šค๋Ÿฌ์šด ๋Œ€ํ™”์ฒด
757
+ 3. ๊ฐ ๋ถˆ๋ฆฟ ํฌ์ธํŠธ๋ฅผ ํ’€์–ด์„œ ์„ค๋ช…
758
+ 4. ์ „ํ™˜ ๋ฌธ๊ตฌ์™€ ์—ฐ๊ฒฐ์–ด ํ™œ์šฉ
759
+ 5. 150-200์ž๋กœ ํ’๋ถ€ํ•˜๊ฒŒ ์ž‘์„ฑ
760
+ 6. ์‹ค์ œ ๋ฐœํ‘œ ์‹œ๋‚˜๋ฆฌ์˜ค์ฒ˜๋Ÿผ ์ž‘์„ฑ
761
+
762
+ ์˜ˆ์‹œ:
763
+ "์ž, ์ด์ œ ์šฐ๋ฆฌ๊ฐ€ ์ฃผ๋ชฉํ•ด์•ผ ํ•  ํ•ต์‹ฌ ํฌ์ธํŠธ๋“ค์„ ํ•˜๋‚˜์”ฉ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์ฒซ ๋ฒˆ์งธ๋กœ ๋ณด์‹ค ๋ถ€๋ถ„์€ ๋ฐ”๋กœ ์‹œ์žฅ ๊ทœ๋ชจ์ธ๋ฐ์š”, ํ˜„์žฌ 3.4์กฐ ๋‹ฌ๋Ÿฌ๋ผ๋Š” ์–ด๋งˆ์–ด๋งˆํ•œ ๊ทœ๋ชจ๋กœ ์„ฑ์žฅํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด๊ฒŒ ์–ผ๋งˆ๋‚˜ ํฐ ์ˆซ์ž์ธ์ง€ ๊ฐ์ด ์•ˆ ์˜ค์‹œ์ฃ ? ์šฐ๋ฆฌ๋‚˜๋ผ GDP์˜ ๋‘ ๋ฐฐ๊ฐ€ ๋„˜๋Š” ๊ทœ๋ชจ์ž…๋‹ˆ๋‹ค. ๋‘ ๋ฒˆ์งธ ํฌ์ธํŠธ๋Š”..."
764
+
765
+ ์ง€์‹œ๋ฌธ์ด๋‚˜ ์„ค๋ช… ์ œ์™ธ, ์˜ค์ง ๋ฐœํ‘œ ๋‚ด์šฉ๋งŒ ์ž‘์„ฑํ•˜์„ธ์š”."""
766
+ else:
767
+ system_prompt = f"""You are a professional presentation coach creating natural, conversational speaker notes.
768
+
769
+ Audience: {audience_type} - {audience_info.get('description', '')}
770
+ Tone: {audience_info.get('tone', '')}
771
+ Language: English
772
+
773
+ Create speaker notes that:
774
+ 1. Sound completely natural and conversational (as if actually speaking)
775
+ 2. Expand on each bullet point with context and examples
776
+ 3. Use smooth transitions between points
777
+ 4. Engage the audience with inclusive language ("we", "let's", "as you can see")
778
+ 5. Be 100-150 words long with rich detail
779
+ 6. Include rhetorical questions or audience engagement
780
+ 7. NO stage directions or meta-commentary - only spoken words
781
+
782
+ Example:
783
+ "Now, let's dive into the key points that really matter here. First up, we're looking at a market size of 3.4 trillion dollars. That's trillion with a T! To put that in perspective, that's larger than the GDP of most countries. What's even more exciting is the growth rate - we're seeing 16% year-over-year expansion. Moving to our second point about digital adoption..."
784
+
785
+ Write ONLY what the speaker would say out loud, no instructions or descriptions."""
786
+
787
+ bullet_text = "\n".join(content.get("bullet_points", []))
788
+
789
+ if language == "Korean":
790
+ user_message = f"""์ฃผ์ œ: {topic}
791
+ ์Šฌ๋ผ์ด๋“œ ์ œ๋ชฉ: {slide_title}
792
+ ๋ถ€์ œ๋ชฉ: {content.get('subtitle', '')}
793
+ ๋‚ด์šฉ:
794
+ {bullet_text}
795
+
796
+ ์œ„ ์Šฌ๋ผ์ด๋“œ๋ฅผ {audience_type} ์ฒญ์ค‘์—๊ฒŒ ๋ฐœํ‘œํ•  ๋•Œ ์‚ฌ์šฉํ•  ์ž์—ฐ์Šค๋Ÿฌ์šด ๊ตฌ์–ด์ฒด ๋ฐœํ‘œ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ž‘์„ฑํ•˜์„ธ์š”.
797
+ ๊ฐ ํฌ์ธํŠธ๋ฅผ ํ’€์–ด์„œ ์„ค๋ช…ํ•˜๊ณ , ์ฒญ์ค‘๊ณผ ์†Œํ†ตํ•˜๋Š” ๋А๋‚Œ์œผ๋กœ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”."""
798
+ else:
799
+ user_message = f"""Topic: {topic}
800
+ Slide Title: {slide_title}
801
+ Subtitle: {content.get('subtitle', '')}
802
+ Content:
803
+ {bullet_text}
804
+
805
+ Write natural, conversational speaker notes for presenting this slide to {audience_type}.
806
+ Expand on each point with context and examples, using engaging language that connects with the audience."""
807
+
808
+ payload = {
809
+ "model": model_id,
810
+ "messages": [
811
+ {"role": "system", "content": system_prompt},
812
+ {"role": "user", "content": user_message}
813
+ ],
814
+ "max_tokens": 400,
815
+ "temperature": 0.8,
816
+ "top_p": 0.9,
817
+ "stream": False
818
+ }
819
+
820
+ try:
821
+ response = requests.post(api_url, json=payload, headers=headers, timeout=30)
822
+ if response.status_code == 200:
823
+ result = response.json()
824
+ notes = result['choices'][0]['message']['content'].strip()
825
+
826
+ # ๋…ธํŠธ๊ฐ€ ๋„ˆ๋ฌด ์งง์œผ๋ฉด ์žฌ์‹œ๋„
827
+ if len(notes) < 100:
828
+ print(f"[Speaker Notes] Notes too short ({len(notes)} chars), retrying...")
829
+ retry_message = user_message + f"\n\n์ด์ „ ์‘๋‹ต์ด ๋„ˆ๋ฌด ์งง์•˜์Šต๋‹ˆ๋‹ค. ์ตœ์†Œ 150์ž ์ด์ƒ์œผ๋กœ ๊ฐ ํฌ์ธํŠธ๋ฅผ ์ž์„ธํžˆ ์„ค๋ช…ํ•ด์ฃผ์„ธ์š”." if language == "Korean" else "\n\nThe previous response was too short. Please provide at least 100 words, expanding on each point with specific examples and context."
830
+
831
+ retry_payload = {
832
+ "model": model_id,
833
+ "messages": [
834
+ {"role": "system", "content": system_prompt},
835
+ {"role": "user", "content": retry_message}
836
+ ],
837
+ "max_tokens": 500,
838
+ "temperature": 0.85,
839
+ "stream": False
840
+ }
841
+
842
+ retry_response = requests.post(api_url, json=retry_payload, headers=headers, timeout=30)
843
+ if retry_response.status_code == 200:
844
+ retry_result = retry_response.json()
845
+ notes = retry_result['choices'][0]['message']['content'].strip()
846
+
847
+ return notes
848
+ else:
849
+ print(f"[Speaker Notes] API Error: {response.status_code}")
850
+ if language == "Korean":
851
+ return f"์ž, ์ด์ œ {slide_title}์— ๋Œ€ํ•ด ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ ์šฐ๋ฆฌ๊ฐ€ ์ฃผ๋ชฉํ•ด์•ผ ํ•  ํ•ต์‹ฌ ํฌ์ธํŠธ๋“ค์ด ์žˆ๋Š”๋ฐ์š”, ์ฒซ ๋ฒˆ์งธ๋Š” {content.get('subtitle', '')}์ž…๋‹ˆ๋‹ค. ์ด ๋ถ€๋ถ„์ด ์™œ ์ค‘์š”ํ•œ์ง€ ํ•˜๋‚˜์”ฉ ์งš์–ด๋ณด๋ฉด์„œ ์„ค๋ช…๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค. ํŠนํžˆ ์—ฌ๋Ÿฌ๋ถ„์˜ ๋น„์ฆˆ๋‹ˆ์Šค์— ์–ด๋–ค ์˜ํ–ฅ์„ ๋ฏธ์น  ์ˆ˜ ์žˆ๋Š”์ง€ ํ•จ๊ป˜ ์ƒ๊ฐํ•ด๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค."
852
+ else:
853
+ return f"Now let's explore {slide_title}. What I want to highlight here are the key points about {content.get('subtitle', '')}. Each of these elements plays a crucial role in our overall strategy, and I'll walk you through why they matter for your business. As we go through these points, think about how they might apply to your specific situation."
854
+ except Exception as e:
855
+ print(f"[Speaker Notes] Error: {str(e)}")
856
+ if language == "Korean":
857
+ return f"์ž, ์ด์ œ {slide_title}์— ๋Œ€ํ•ด ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ ์šฐ๋ฆฌ๊ฐ€ ์ฃผ๋ชฉํ•ด์•ผ ํ•  ํ•ต์‹ฌ ํฌ์ธํŠธ๋“ค์ด ์žˆ๋Š”๋ฐ์š”, ์ฒซ ๋ฒˆ์งธ๋Š” {content.get('subtitle', '')}์ž…๋‹ˆ๋‹ค. ์ด ๋ถ€๋ถ„์ด ์™œ ์ค‘์š”ํ•œ์ง€ ํ•˜๋‚˜์”ฉ ์งš์–ด๋ณด๋ฉด์„œ ์„ค๋ช…๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค. ํŠนํžˆ ์—ฌ๋Ÿฌ๋ถ„์˜ ๋น„์ฆˆ๋‹ˆ์Šค์— ์–ด๋–ค ์˜ํ–ฅ์„ ๋ฏธ์น  ์ˆ˜ ์žˆ๋Š”์ง€ ํ•จ๊ป˜ ์ƒ๊ฐํ•ด๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค."
858
+ else:
859
+ return f"Now let's explore {slide_title}. What I want to highlight here are the key points about {content.get('subtitle', '')}. Each of these elements plays a crucial role in our overall strategy, and I'll walk you through why they matter for your business. As we go through these points, think about how they might apply to your specific situation."
860
+
861
+ def generate_closing_notes(topic: str, conclusion_phrase: str, audience_type: str,
862
+ language: str = "English", friendli_token: str = None,
863
+ api_url: str = None, model_id: str = None,
864
+ audience_types: Dict = None) -> str:
865
+ """Generate speaker notes for the closing slide"""
866
+ print(f"[Closing Notes] Generating...")
867
+
868
+ audience_info = audience_types.get(audience_type, {}) if audience_types else {}
869
+
870
+ headers = {
871
+ "Authorization": f"Bearer {friendli_token}",
872
+ "Content-Type": "application/json"
873
+ }
874
+
875
+ if language == "Korean":
876
+ system_prompt = f"""๋‹น์‹ ์€ ํ”„๋ ˆ์  ํ…Œ์ด์…˜์„ ๋งˆ๋ฌด๋ฆฌํ•˜๋Š” ์ „๋ฌธ ๋ฐœํ‘œ์ž์ž…๋‹ˆ๋‹ค.
877
+
878
+ ์ฒญ์ค‘: {audience_type} - {audience_info.get('description', '')}
879
+ ํ†ค: ๋”ฐ๋œปํ•˜๊ณ  ์ „๋ฌธ์ ์ด๋ฉฐ {audience_type}์—๊ฒŒ ์ ํ•ฉํ•œ ์–ด์กฐ
880
+ ์–ธ์–ด: ํ•œ๊ตญ์–ด
881
+
882
+ ๋งˆ๋ฌด๋ฆฌ ๋ฐœํ‘œ ๋…ธํŠธ ์ž‘์„ฑ ๊ทœ์น™:
883
+ 1. ๋ฐœํ‘œ ๋‚ด์šฉ ํ•ต์‹ฌ ์š”์•ฝ (2-3๋ฌธ์žฅ)
884
+ 2. ๊ฒฐ๋ก  ๋ฌธ๊ตฌ๋ฅผ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ํ™œ์šฉ
885
+ 3. ์ฒญ์ค‘์—๊ฒŒ ๊ฐ์‚ฌ ์ธ์‚ฌ
886
+ 4. ์งˆ๋ฌธ ์œ ๋„ ๋˜๋Š” ๋‹ค์Œ ๋‹จ๊ณ„ ์ œ์•ˆ
887
+ 5. 150-200์ž๋กœ ํ’๋ถ€ํ•˜๊ฒŒ ์ž‘์„ฑ
888
+ 6. ์™„์ „ํ•œ ๊ตฌ์–ด์ฒด๋กœ ์ž‘์„ฑ
889
+ 7. ์ง€์‹œ๋ฌธ ์ œ์™ธ, ์˜ค์ง ๋ฐœํ‘œ ๋‚ด์šฉ๋งŒ
890
+
891
+ ์˜ˆ์‹œ:
892
+ "์˜ค๋Š˜ ์šฐ๋ฆฌ๊ฐ€ ํ•จ๊ป˜ ์‚ดํŽด๋ณธ ๋””์ง€ํ„ธ ํŠธ๋žœ์Šคํฌ๋ฉ”์ด์…˜์˜ ํ•ต์‹ฌ์€ ๋ฐ”๋กœ '๊ธฐ์ˆ ์ด ์•„๋‹Œ ์‚ฌ๋žŒ'์ด๋ผ๋Š” ์ ์ž…๋‹ˆ๋‹ค. ์‹œ์žฅ ๊ทœ๋ชจ, ์„ฑ๊ณต ์‚ฌ๋ก€, ๊ทธ๋ฆฌ๊ณ  ์‹คํ–‰ ์ „๋žต๊นŒ์ง€ ๋‹ค์–‘ํ•œ ๊ด€์ ์—์„œ ์ ‘๊ทผํ•ด ๋ณด์•˜๋Š”๋ฐ์š”. ์ œ๊ฐ€ ๋“œ๋ฆฌ๊ณ  ์‹ถ์€ ๋ฉ”์‹œ์ง€๋Š” ๋ช…ํ™•ํ•ฉ๋‹ˆ๋‹ค. 'ํ•จ๊ป˜ ๋งŒ๋“œ๋Š” ๋ฏธ๋ž˜' - ์ด๊ฒƒ์ด ์šฐ๋ฆฌ๊ฐ€ ์ถ”๊ตฌํ•ด์•ผ ํ•  ๋ฐฉํ–ฅ์ž…๋‹ˆ๋‹ค. ๊ธด ์‹œ๊ฐ„ ๊ฒฝ์ฒญํ•ด ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ํ˜น์‹œ ๊ถ๊ธˆํ•˜์‹  ์ ์ด๋‚˜ ๋” ๋…ผ์˜ํ•˜๊ณ  ์‹ถ์€ ๋ถ€๋ถ„์ด ์žˆ์œผ์‹œ๋ฉด ํŽธํ•˜๊ฒŒ ๋ง์”€ํ•ด ์ฃผ์„ธ์š”."
893
+ """
894
+ else:
895
+ system_prompt = f"""You are a professional presenter closing a presentation.
896
+
897
+ Audience: {audience_type} - {audience_info.get('description', '')}
898
+ Tone: Warm, professional, and appropriate for {audience_type}
899
+ Language: English
900
+
901
+ Create closing remarks that:
902
+ 1. Briefly summarize the key takeaways (2-3 sentences)
903
+ 2. Reference the conclusion phrase naturally
904
+ 3. Thank the audience warmly
905
+ 4. Invite questions or suggest next steps
906
+ 5. Be 100-150 words with rich detail
907
+ 6. Sound completely conversational
908
+ 7. NO stage directions - only spoken words
909
+
910
+ Example:
911
+ "So, what we've explored today is truly transformative - from the 3.4 trillion dollar market opportunity to the real-world success stories of Amazon and Starbucks. The key takeaway? Digital transformation isn't about technology, it's about people and culture. That's why our theme 'Building Tomorrow Together' resonates so strongly. Your engagement and questions throughout have been fantastic, and I hope you're as excited about these possibilities as I am. Thank you for your time and attention today. I'd love to hear your thoughts - what aspects resonated most with you? Are there specific areas you'd like to explore further?"
912
+
913
+ Write ONLY what the speaker would say."""
914
+
915
+ if language == "Korean":
916
+ user_message = f"""์ฃผ์ œ: {topic}
917
+ ์ฒญ์ค‘: {audience_type}
918
+ ํ™”๋ฉด์˜ ๊ฒฐ๋ก  ๋ฌธ๊ตฌ: {conclusion_phrase}
919
+
920
+ ์œ„ ์ •๋ณด๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ {audience_type} ์ฒญ์ค‘์„ ์œ„ํ•œ ์ž์—ฐ์Šค๋Ÿฝ๊ณ  ๋”ฐ๋œปํ•œ ๋งˆ๋ฌด๋ฆฌ ๋ฐœํ‘œ ๋…ธํŠธ๋ฅผ ์ž‘์„ฑํ•˜์„ธ์š”.
921
+ ํ•ต์‹ฌ ๋‚ด์šฉ์„ ์š”์•ฝํ•˜๊ณ , ๊ฒฐ๋ก  ๋ฌธ๊ตฌ๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๊ฐ•๋ ฅํ•œ ๋งˆ๋ฌด๋ฆฌ๋ฅผ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š”."""
922
+ else:
923
+ user_message = f"""Topic: {topic}
924
+ Audience: {audience_type}
925
+ Conclusion phrase on screen: {conclusion_phrase}
926
+
927
+ Create natural, warm closing speaker notes for {audience_type} that wrap up the presentation effectively.
928
+ Summarize key points and use the conclusion phrase to create a powerful ending."""
929
+
930
+ payload = {
931
+ "model": model_id,
932
+ "messages": [
933
+ {"role": "system", "content": system_prompt},
934
+ {"role": "user", "content": user_message}
935
+ ],
936
+ "max_tokens": 400,
937
+ "temperature": 0.8,
938
+ "stream": False
939
+ }
940
+
941
+ try:
942
+ response = requests.post(api_url, json=payload, headers=headers, timeout=30)
943
+ if response.status_code == 200:
944
+ result = response.json()
945
+ notes = result['choices'][0]['message']['content'].strip()
946
+
947
+ # ๋…ธํŠธ๊ฐ€ ๋„ˆ๋ฌด ์งง์œผ๋ฉด ์žฌ์‹œ๋„
948
+ if len(notes) < 100:
949
+ print(f"[Closing Notes] Notes too short ({len(notes)} chars), retrying...")
950
+ retry_message = user_message + f"\n\n์ด์ „ ์‘๋‹ต์ด ๋„ˆ๋ฌด ์งง์•˜์Šต๋‹ˆ๋‹ค. ์ตœ์†Œ 150์ž ์ด์ƒ์œผ๋กœ ํ’๋ถ€ํ•˜๊ฒŒ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”." if language == "Korean" else "\n\nThe previous response was too short. Please provide at least 100 words with more detail."
951
+
952
+ retry_payload = {
953
+ "model": model_id,
954
+ "messages": [
955
+ {"role": "system", "content": system_prompt},
956
+ {"role": "user", "content": retry_message}
957
+ ],
958
+ "max_tokens": 500,
959
+ "temperature": 0.85,
960
+ "stream": False
961
+ }
962
+
963
+ retry_response = requests.post(api_url, json=retry_payload, headers=headers, timeout=30)
964
+ if retry_response.status_code == 200:
965
+ retry_result = retry_response.json()
966
+ notes = retry_result['choices'][0]['message']['content'].strip()
967
+
968
+ return notes
969
+ else:
970
+ print(f"[Closing Notes] API Error: {response.status_code}")
971
+ if language == "Korean":
972
+ return f"์˜ค๋Š˜ ์šฐ๋ฆฌ๊ฐ€ ํ•จ๊ป˜ ์‚ดํŽด๋ณธ {topic}์˜ ํ•ต์‹ฌ์€ ๋ฐ”๋กœ ๋ณ€ํ™”์™€ ํ˜์‹ ์ž…๋‹ˆ๋‹ค. ์‹œ์žฅ์˜ ๊ธฐํšŒ๋ถ€ํ„ฐ ์‹คํ–‰ ์ „๋žต๊นŒ์ง€ ๋‹ค์–‘ํ•œ ๊ด€์ ์—์„œ ์ ‘๊ทผํ•ด ๋ณด์•˜๋Š”๋ฐ์š”, ์ œ๊ฐ€ ๋“œ๋ฆฌ๊ณ  ์‹ถ์€ ๋ฉ”์‹œ์ง€๋Š” '{conclusion_phrase}'์ž…๋‹ˆ๋‹ค. ์ด๊ฒƒ์ด ์šฐ๋ฆฌ๊ฐ€ ํ•จ๊ป˜ ์ถ”๊ตฌํ•ด์•ผ ํ•  ๋ฐฉํ–ฅ์ด๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ์˜ค๋Š˜ ์ด ์ž๋ฆฌ์— ํ•จ๊ป˜ํ•ด ์ฃผ์‹  ๋ชจ๋“  ๋ถ„๋“ค๊ป˜ ๊ฐ์‚ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค. ํ˜น์‹œ ๊ถ๊ธˆํ•˜์‹  ์ ์ด๋‚˜ ๋” ๊นŠ์ด ๋…ผ์˜ํ•˜๊ณ  ์‹ถ์€ ๋ถ€๋ถ„์ด ์žˆ์œผ์‹œ๋ฉด ํŽธํ•˜๊ฒŒ ์งˆ๋ฌธํ•ด ์ฃผ์„ธ์š”."
973
+ else:
974
+ return f"What we've explored today about {topic} represents a significant opportunity for transformation. From market insights to execution strategies, we've covered the essential elements you need to succeed. The message I want to leave you with is simple yet powerful: '{conclusion_phrase}'. This encapsulates everything we've discussed today. Thank you all for your attention and engagement. I'm excited to hear your thoughts and answer any questions you might have. What resonated most with you from today's presentation?"
975
+ except Exception as e:
976
+ print(f"[Closing Notes] Error: {str(e)}")
977
+ if language == "Korean":
978
+ return f"์˜ค๋Š˜ ์šฐ๋ฆฌ๊ฐ€ ํ•จ๊ป˜ ์‚ดํŽด๋ณธ {topic}์˜ ํ•ต์‹ฌ์€ ๋ฐ”๋กœ ๋ณ€ํ™”์™€ ํ˜์‹ ์ž…๋‹ˆ๋‹ค. ์‹œ์žฅ์˜ ๊ธฐํšŒ๋ถ€ํ„ฐ ์‹คํ–‰ ์ „๋žต๊นŒ์ง€ ๋‹ค์–‘ํ•œ ๊ด€์ ์—์„œ ์ ‘๊ทผํ•ด ๋ณด์•˜๋Š”๋ฐ์š”, ์ œ๊ฐ€ ๋“œ๋ฆฌ๊ณ  ์‹ถ์€ ๋ฉ”์‹œ์ง€๋Š” '{conclusion_phrase}'์ž…๋‹ˆ๋‹ค. ์ด๊ฒƒ์ด ์šฐ๋ฆฌ๊ฐ€ ํ•จ๊ป˜ ์ถ”๊ตฌํ•ด์•ผ ํ•  ๋ฐฉํ–ฅ์ด๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ์˜ค๋Š˜ ์ด ์ž๋ฆฌ์— ํ•จ๊ป˜ํ•ด ์ฃผ์‹  ๋ชจ๋“  ๋ถ„๋“ค๊ป˜ ๊ฐ์‚ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค. ํ˜น์‹œ ๊ถ๊ธˆํ•˜์‹  ์ ์ด๋‚˜ ๋” ๊นŠ์ด ๋…ผ์˜ํ•˜๊ณ  ๏ฟฝ๏ฟฝ๏ฟฝ์€ ๋ถ€๋ถ„์ด ์žˆ์œผ์‹œ๋ฉด ํŽธํ•˜๊ฒŒ ์งˆ๋ฌธํ•ด ์ฃผ์„ธ์š”."
979
+ else:
980
+ return f"What we've explored today about {topic} represents a significant opportunity for transformation. From market insights to execution strategies, we've covered the essential elements you need to succeed. The message I want to leave you with is simple yet powerful: '{conclusion_phrase}'. This encapsulates everything we've discussed today. Thank you all for your attention and engagement. I'm excited to hear your thoughts and answer any questions you might have. What resonated most with you from today's presentation?"
981
+
982
+ def generate_conclusion_phrase(topic: str, audience_type: str, language: str = "English",
983
+ friendli_token: str = None, api_url: str = None,
984
+ model_id: str = None, audience_types: Dict = None) -> str:
985
+ """Generate a powerful conclusion phrase"""
986
+ print(f"[Conclusion Phrase] Generating...")
987
+
988
+ audience_info = audience_types.get(audience_type, {}) if audience_types else {}
989
+
990
+ headers = {
991
+ "Authorization": f"Bearer {friendli_token}",
992
+ "Content-Type": "application/json"
993
+ }
994
+
995
+ system_prompt = f"""You are a professional copywriter creating powerful closing statements for presentations.
996
+
997
+ The audience is: {audience_type} - {audience_info.get('description', '')}
998
+ Focus on: {audience_info.get('focus', '')}
999
+ Language: {language}
1000
+
1001
+ Create a concise, impactful closing phrase that:
1002
+ 1. Captures the essence of the presentation topic
1003
+ 2. Resonates with {audience_type}
1004
+ 3. Is memorable and inspirational
1005
+ 4. Maximum 5-7 words
1006
+ 5. Uses powerful, action-oriented language appropriate for {audience_type}
1007
+ 6. Leaves a lasting impression
1008
+ 7. Written in {language}
1009
+
1010
+ Examples for different audiences:
1011
+ - For executives: "Excellence Through Strategic Innovation" / "์ „๋žต์  ํ˜์‹ ์„ ํ†ตํ•œ ํƒ์›”ํ•จ"
1012
+ - For investors: "Maximum Returns, Minimal Risk" / "์ตœ๋Œ€ ์ˆ˜์ต, ์ตœ์†Œ ๋ฆฌ์Šคํฌ"
1013
+ - For technical teams: "Code Today, Transform Tomorrow" / "์˜ค๋Š˜์˜ ์ฝ”๋“œ, ๋‚ด์ผ์˜ ๋ณ€ํ™”"
1014
+ - For customers: "Your Success, Our Mission" / "๊ณ ๊ฐ์˜ ์„ฑ๊ณต์ด ์šฐ๋ฆฌ์˜ ์‚ฌ๋ช…"
1015
+
1016
+ Output only the phrase in {language}, no explanation."""
1017
+
1018
+ user_message = f"""Presentation topic: {topic}
1019
+ Target audience: {audience_type}
1020
+ Language: {language}
1021
+
1022
+ Create a powerful closing phrase in {language} that encapsulates the main message for {audience_type}."""
1023
+
1024
+ payload = {
1025
+ "model": model_id,
1026
+ "messages": [
1027
+ {
1028
+ "role": "system",
1029
+ "content": system_prompt
1030
+ },
1031
+ {
1032
+ "role": "user",
1033
+ "content": user_message
1034
+ }
1035
+ ],
1036
+ "max_tokens": 50,
1037
+ "temperature": 0.9,
1038
+ "stream": False
1039
+ }
1040
+
1041
+ try:
1042
+ response = requests.post(api_url, json=payload, headers=headers, timeout=30)
1043
+ if response.status_code == 200:
1044
+ result = response.json()
1045
+ phrase = result['choices'][0]['message']['content'].strip()
1046
+ return phrase
1047
+ else:
1048
+ if language == "Korean":
1049
+ return "ํ•จ๊ป˜ ๋งŒ๋“œ๋Š” ๋ฏธ๋ž˜"
1050
+ else:
1051
+ return "Building Tomorrow Together"
1052
+ except Exception as e:
1053
+ print(f"[Conclusion Phrase] Error: {str(e)}")
1054
+ if language == "Korean":
1055
+ return "ํ•จ๊ป˜ ๋งŒ๋“œ๋Š” ๋ฏธ๋ž˜"
1056
+ else:
1057
+ return "Building Tomorrow Together"
1058
+
1059
+ def translate_to_english(text: str, friendli_token: str = None,
1060
+ api_url: str = None, model_id: str = None) -> str:
1061
+ """Translate Korean text to English"""
1062
+ if not any(ord('๊ฐ€') <= ord(char) <= ord('ํžฃ') for char in text):
1063
+ return text
1064
+
1065
+ print(f"[Translation] Korean detected, translating to English")
1066
+
1067
+ headers = {
1068
+ "Authorization": f"Bearer {friendli_token}",
1069
+ "Content-Type": "application/json"
1070
+ }
1071
+
1072
+ payload = {
1073
+ "model": model_id,
1074
+ "messages": [
1075
+ {
1076
+ "role": "system",
1077
+ "content": "You are a translator. Translate the given Korean text to English. Only return the translation without any explanation."
1078
+ },
1079
+ {
1080
+ "role": "user",
1081
+ "content": text
1082
+ }
1083
+ ],
1084
+ "max_tokens": 500,
1085
+ "top_p": 0.8,
1086
+ "stream": False
1087
+ }
1088
+
1089
+ try:
1090
+ response = requests.post(api_url, json=payload, headers=headers, timeout=30)
1091
+ if response.status_code == 200:
1092
+ result = response.json()
1093
+ translated = result['choices'][0]['message']['content'].strip()
1094
+ print(f"[Translation] Complete")
1095
+ return translated
1096
+ else:
1097
+ print(f"[Translation] Failed, using original")
1098
+ return text
1099
+ except Exception as e:
1100
+ print(f"[Translation] Error: {str(e)}, using original")
1101
+ return text
1102
+
1103
+ def generate_prompt_with_llm(topic: str, style_example: str = None, slide_context: str = None,
1104
+ uploaded_content: str = None, friendli_token: str = None,
1105
+ api_url: str = None, model_id: str = None) -> str:
1106
+ """Generate image prompt using LLM"""
1107
+ print(f"[LLM] Generating prompt: {slide_context}")
1108
+
1109
+ headers = {
1110
+ "Authorization": f"Bearer {friendli_token}",
1111
+ "Content-Type": "application/json"
1112
+ }
1113
+
1114
+ system_prompt = """You are an expert image prompt engineer specializing in creating prompts for professional presentation slides.
1115
+
1116
+ Your task is to create prompts that:
1117
+ 1. Are highly specific and visual, perfect for PPT backgrounds or main visuals
1118
+ 2. Consider the slide's purpose and maintain consistency across a presentation
1119
+ 3. Include style references matching the given example
1120
+ 4. Focus on clean, professional visuals that won't distract from text overlays
1121
+ 5. Ensure high contrast areas for text readability when needed
1122
+ 6. Maintain brand consistency and professional aesthetics
1123
+
1124
+ Important guidelines:
1125
+ - If given a style example, adapt the topic to match that specific visual style
1126
+ - Consider the slide context to create appropriate visuals
1127
+ - Always output ONLY the prompt without any explanation
1128
+ - Keep prompts between 50-150 words for optimal results
1129
+ - Ensure the visual supports rather than overwhelms the slide content"""
1130
+
1131
+ user_message = f"Topic: {topic}"
1132
+ if style_example:
1133
+ user_message += f"\n\nStyle reference to follow:\n{style_example}"
1134
+ if slide_context:
1135
+ user_message += f"\n\nSlide context: {slide_context}"
1136
+ if uploaded_content:
1137
+ user_message += f"\n\nAdditional context from document:\n{uploaded_content[:500]}"
1138
+
1139
+ payload = {
1140
+ "model": model_id,
1141
+ "messages": [
1142
+ {
1143
+ "role": "system",
1144
+ "content": system_prompt
1145
+ },
1146
+ {
1147
+ "role": "user",
1148
+ "content": user_message
1149
+ }
1150
+ ],
1151
+ "max_tokens": 300,
1152
+ "top_p": 0.8,
1153
+ "temperature": 0.7,
1154
+ "stream": False
1155
+ }
1156
+
1157
+ try:
1158
+ response = requests.post(api_url, json=payload, headers=headers, timeout=30)
1159
+ if response.status_code == 200:
1160
+ result = response.json()
1161
+ prompt = result['choices'][0]['message']['content'].strip()
1162
+ print(f"[LLM] Prompt generated: {prompt[:50]}...")
1163
+ return prompt
1164
+ else:
1165
+ error_msg = f"Prompt generation failed: {response.status_code}"
1166
+ print(f"[LLM] {error_msg}")
1167
+ return error_msg
1168
+ except Exception as e:
1169
+ error_msg = f"Prompt generation error: {str(e)}"
1170
+ print(f"[LLM] {error_msg}")
1171
+ return error_msg
1172
+
1173
+ def generate_image(prompt: str, seed: int = 10, slide_info: str = "",
1174
+ replicate_token: str = None, current_topic: str = "",
1175
+ current_language: str = "English", friendli_token: str = None,
1176
+ api_url: str = None, model_id: str = None) -> Tuple[Image.Image, str]:
1177
+ """Generate image using Replicate API or process flow diagram"""
1178
+ print(f"\n[Image Generation] {slide_info}")
1179
+ print(f"[Image Generation] Prompt: {prompt[:50]}...")
1180
+
1181
+ # Check if process flow diagram should be generated
1182
+ should_generate_process_flow = False
1183
+
1184
+ # Extract slide title
1185
+ slide_title = ""
1186
+ if ":" in slide_info:
1187
+ parts = slide_info.split(":")
1188
+ if len(parts) >= 2:
1189
+ slide_title = parts[1].strip()
1190
+
1191
+ print(f"[Image Generation] Extracted slide title: '{slide_title}'")
1192
+
1193
+ # Process keywords for both English and Korean
1194
+ process_keywords_en = [
1195
+ "process", "workflow", "flow", "procedure", "steps", "phases", "overview"
1196
+ ]
1197
+ process_keywords_kr = [
1198
+ "ํ”„๋กœ์„ธ์Šค", "์ž‘๋™", "ํ”Œ๋กœ์šฐ", "ํ๋ฆ„", "์›Œํฌํ”Œ๋กœ์šฐ",
1199
+ "์ ˆ์ฐจ", "๋‹จ๊ณ„", "์ฒ˜๋ฆฌ", "์ง„ํ–‰", "๊ฐœ์š”"
1200
+ ]
1201
+
1202
+ # Check if workflow style
1203
+ is_workflow_style = False
1204
+ if any(style in prompt for style in ["Business Workflow", "Flowchart", "Business Process"]):
1205
+ is_workflow_style = True
1206
+ print(f"[Image Generation] Business Workflow or Flowchart style detected")
1207
+
1208
+ # Check title for process keywords
1209
+ title_has_process = any(keyword in slide_title.lower() for keyword in process_keywords_en) or \
1210
+ any(keyword in slide_title for keyword in process_keywords_kr)
1211
+ prompt_has_process = any(keyword in prompt.lower() for keyword in ["process", "flow", "workflow"])
1212
+
1213
+ print(f"[Image Generation] Title has process keyword: {title_has_process}")
1214
+ print(f"[Image Generation] Workflow style: {is_workflow_style}")
1215
+ print(f"[Image Generation] Prompt has process keyword: {prompt_has_process}")
1216
+
1217
+ if title_has_process and (is_workflow_style or prompt_has_process):
1218
+ should_generate_process_flow = True
1219
+ print(f"[Image Generation] โœ… Process flow diagram conditions met!")
1220
+
1221
+ # Special case: exclude table of contents
1222
+ if "Contents" in slide_title or "๋ชฉ์ฐจ" in slide_title:
1223
+ should_generate_process_flow = False
1224
+ print(f"[Image Generation] Table of contents excluded from process flow")
1225
+
1226
+ # Generate process flow diagram
1227
+ if PROCESS_FLOW_AVAILABLE and should_generate_process_flow:
1228
+ try:
1229
+ print("[Image Generation] ๐Ÿ”ง Generating process flow diagram...")
1230
+
1231
+ # Use current language setting
1232
+ use_korean = (current_language == "Korean")
1233
+
1234
+ img = generate_process_flow_for_ppt(
1235
+ topic=current_topic,
1236
+ context=slide_info,
1237
+ style="Business Workflow",
1238
+ use_korean=use_korean
1239
+ )
1240
+
1241
+ if isinstance(img, Image.Image):
1242
+ print("[Image Generation] โœ… Process flow diagram generated successfully!")
1243
+ return img, f"Process flow diagram generated with {current_language} support"
1244
+ else:
1245
+ print("[Image Generation] โŒ Process flow generation failed, falling back to regular image")
1246
+ except Exception as e:
1247
+ print(f"[Image Generation] โŒ Process flow generation error: {str(e)}")
1248
+ import traceback
1249
+ traceback.print_exc()
1250
+ else:
1251
+ if not PROCESS_FLOW_AVAILABLE:
1252
+ print("[Image Generation] โš ๏ธ Process flow generator not available")
1253
+ else:
1254
+ print("[Image Generation] โ„น๏ธ Process flow conditions not met, generating regular image")
1255
+
1256
+ # Generate regular image
1257
+ try:
1258
+ english_prompt = translate_to_english(prompt, friendli_token, api_url, model_id)
1259
+
1260
+ if not replicate_token:
1261
+ error_msg = "RAPI_TOKEN environment variable not set."
1262
+ print(f"[Image Generation] Error: {error_msg}")
1263
+ return None, error_msg
1264
+
1265
+ print(f"[Image Generation] Calling Replicate API...")
1266
+ client = replicate.Client(api_token=replicate_token)
1267
+
1268
+ input_params = {
1269
+ "seed": seed,
1270
+ "prompt": english_prompt,
1271
+ "speed_mode": "Extra Juiced ๐Ÿš€ (even more speed)",
1272
+ "output_quality": 100
1273
+ }
1274
+
1275
+ start_time = time.time()
1276
+ output = client.run(
1277
+ "prunaai/hidream-l1-fast:17c237d753218fed0ed477cb553902b6b75735f48c128537ab829096ef3d3645",
1278
+ input=input_params
1279
+ )
1280
+
1281
+ elapsed = time.time() - start_time
1282
+ print(f"[Image Generation] API response received ({elapsed:.1f}s)")
1283
+
1284
+ if output:
1285
+ if isinstance(output, str) and output.startswith('http'):
1286
+ print(f"[Image Generation] Downloading image from URL...")
1287
+ response = requests.get(output, timeout=30)
1288
+ img = Image.open(BytesIO(response.content))
1289
+ print(f"[Image Generation] Complete!")
1290
+ return img, english_prompt
1291
+ else:
1292
+ print(f"[Image Generation] Processing binary data...")
1293
+ img = Image.open(BytesIO(output.read()))
1294
+ print(f"[Image Generation] Complete!")
1295
+ return img, english_prompt
1296
+ else:
1297
+ error_msg = "Image generation failed - empty response"
1298
+ print(f"[Image Generation] {error_msg}")
1299
+ return None, error_msg
1300
+
1301
+ except Exception as e:
1302
+ error_msg = f"Error: {str(e)}"
1303
+ print(f"[Image Generation] {error_msg}")
1304
+ print(f"[Image Generation] Detailed error:\n{traceback.format_exc()}")
1305
+ return None, error_msg
1306
+
1307
+ def create_slide_preview_html(slide_data: Dict) -> str:
1308
+ """Create 16:9 ratio slide preview HTML"""
1309
+
1310
+ # Encode image to base64
1311
+ img_base64 = ""
1312
+ if slide_data.get("image"):
1313
+ buffered = BytesIO()
1314
+ slide_data["image"].save(buffered, format="PNG")
1315
+ img_base64 = base64.b64encode(buffered.getvalue()).decode()
1316
+
1317
+ # Get text content
1318
+ subtitle = slide_data.get("subtitle", "")
1319
+ bullet_points = slide_data.get("bullet_points", [])
1320
+
1321
+ # Generate HTML
1322
+ html = f"""
1323
+ <div class="slide-container" style="
1324
+ width: 100%;
1325
+ max-width: 1200px;
1326
+ margin: 20px auto;
1327
+ background: white;
1328
+ border-radius: 12px;
1329
+ box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
1330
+ overflow: hidden;
1331
+ ">
1332
+ <div class="slide-header" style="
1333
+ background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
1334
+ color: white;
1335
+ padding: 15px 30px;
1336
+ font-size: 18px;
1337
+ font-weight: bold;
1338
+ ">
1339
+ Slide {slide_data.get('slide_number', '')}: {slide_data.get('title', '')}
1340
+ </div>
1341
+
1342
+ <div class="slide-content" style="
1343
+ display: flex;
1344
+ height: 0;
1345
+ padding-bottom: 56.25%; /* 16:9 ratio */
1346
+ position: relative;
1347
+ background: #fafbfc;
1348
+ ">
1349
+ <div class="slide-inner" style="
1350
+ position: absolute;
1351
+ top: 0;
1352
+ left: 0;
1353
+ width: 100%;
1354
+ height: 100%;
1355
+ display: flex;
1356
+ padding: 20px;
1357
+ gap: 20px;
1358
+ ">
1359
+ """
1360
+
1361
+ # Title and Thank You slides use full screen images
1362
+ if slide_data.get('title') in ['Cover', 'Thank You', 'ํ‘œ์ง€']:
1363
+ html += f"""
1364
+ <!-- Full screen image -->
1365
+ <div style="
1366
+ width: 100%;
1367
+ height: 100%;
1368
+ position: relative;
1369
+ background: #e9ecef;
1370
+ border-radius: 12px;
1371
+ overflow: hidden;
1372
+ ">
1373
+ """
1374
+
1375
+ if img_base64:
1376
+ html += f"""
1377
+ <img src="data:image/png;base64,{img_base64}" style="
1378
+ width: 100%;
1379
+ height: 100%;
1380
+ object-fit: cover;
1381
+ " alt="Slide Image">
1382
+ <div style="
1383
+ position: absolute;
1384
+ top: 50%;
1385
+ left: 50%;
1386
+ transform: translate(-50%, -50%);
1387
+ text-align: center;
1388
+ background: rgba(255, 255, 255, 0.9);
1389
+ padding: 30px 60px;
1390
+ border-radius: 20px;
1391
+ box-shadow: 0 10px 40px rgba(0,0,0,0.3);
1392
+ backdrop-filter: blur(10px);
1393
+ ">
1394
+ """
1395
+
1396
+ if slide_data.get('title') in ['Cover', 'ํ‘œ์ง€']:
1397
+ html += f"""
1398
+ <h1 style="font-size: 48px; margin-bottom: 10px; color: #000000; font-weight: 700;">{slide_data.get('topic', '')}</h1>
1399
+ <h2 style="font-size: 24px; margin-top: 0; color: #212529; font-weight: 400;">{subtitle}</h2>
1400
+ """
1401
+ else: # Thank You
1402
+ html += f"""
1403
+ <h1 style="font-size: 42px; color: #000000; font-weight: 700; line-height: 1.2;">{subtitle}</h1>
1404
+ """
1405
+
1406
+ html += """
1407
+ </div>
1408
+ """
1409
+
1410
+ html += """
1411
+ </div>
1412
+ """
1413
+ else:
1414
+ # Regular slide layout
1415
+ html += f"""
1416
+ <!-- Text area (left) -->
1417
+ <div class="text-area" style="
1418
+ flex: 1;
1419
+ padding: 30px;
1420
+ display: flex;
1421
+ flex-direction: column;
1422
+ justify-content: center;
1423
+ background: rgba(255, 255, 255, 0.95);
1424
+ border-radius: 12px;
1425
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
1426
+ ">
1427
+ <h2 style="
1428
+ color: #212529;
1429
+ font-size: 28px;
1430
+ margin-bottom: 30px;
1431
+ font-weight: 600;
1432
+ ">{subtitle}</h2>
1433
+
1434
+ <ul style="
1435
+ list-style: none;
1436
+ padding: 0;
1437
+ margin: 0;
1438
+ ">
1439
+ """
1440
+
1441
+ for point in bullet_points:
1442
+ clean_point = point.replace('โ€ข', '').strip()
1443
+ html += f"""
1444
+ <li style="
1445
+ margin-bottom: 16px;
1446
+ padding-left: 28px;
1447
+ position: relative;
1448
+ color: #495057;
1449
+ font-size: 16px;
1450
+ line-height: 1.6;
1451
+ ">
1452
+ <span style="
1453
+ position: absolute;
1454
+ left: 0;
1455
+ color: #007bff;
1456
+ font-size: 18px;
1457
+ ">โ€ข</span>
1458
+ {clean_point}
1459
+ </li>
1460
+ """
1461
+
1462
+ html += f"""
1463
+ </ul>
1464
+ </div>
1465
+
1466
+ <!-- Image area (right) -->
1467
+ <div class="image-area" style="
1468
+ flex: 1;
1469
+ display: flex;
1470
+ align-items: center;
1471
+ justify-content: center;
1472
+ padding: 20px;
1473
+ ">
1474
+ """
1475
+
1476
+ if img_base64:
1477
+ html += f"""
1478
+ <img src="data:image/png;base64,{img_base64}" style="
1479
+ max-width: 100%;
1480
+ max-height: 100%;
1481
+ object-fit: contain;
1482
+ border-radius: 8px;
1483
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
1484
+ " alt="Slide Image">
1485
+ """
1486
+ else:
1487
+ html += """
1488
+ <div style="
1489
+ color: #6c757d;
1490
+ text-align: center;
1491
+ ">
1492
+ <div style="font-size: 48px;">๐Ÿ–ผ๏ธ</div>
1493
+ <p>Generating image...</p>
1494
+ </div>
1495
+ """
1496
+
1497
+ html += """
1498
+ </div>
1499
+ """
1500
+
1501
+ html += """
1502
+ </div>
1503
+ </div>
1504
+ </div>
1505
+ """
1506
+
1507
+ return html
1508
+
1509
+ def create_pptx_file(results: List[Dict], topic: str, template_name: str,
1510
+ theme_name: str = "Minimal Light", design_themes: Dict = None) -> str:
1511
+ """Create PPTX file with speaker notes"""
1512
+ print(f"[PPTX] Creating file... Theme: {theme_name}")
1513
+
1514
+ # Create presentation (16:9 ratio)
1515
+ prs = Presentation()
1516
+ prs.slide_width = Inches(16)
1517
+ prs.slide_height = Inches(9)
1518
+
1519
+ # Get selected theme
1520
+ theme = design_themes.get(theme_name, design_themes["Minimal Light"]) if design_themes else {}
1521
+
1522
+ # Add slides
1523
+ for i, result in enumerate(results):
1524
+ if not result.get("success", False):
1525
+ continue
1526
+
1527
+ slide_data = result.get("slide_data", {})
1528
+
1529
+ # Use blank layout
1530
+ blank_layout = prs.slide_layouts[6]
1531
+ slide = prs.slides.add_slide(blank_layout)
1532
+
1533
+ # Title slide
1534
+ if slide_data.get('title') in ['Cover', 'ํ‘œ์ง€']:
1535
+ # Add background image
1536
+ if slide_data.get('image'):
1537
+ try:
1538
+ img_buffer = BytesIO()
1539
+ slide_data['image'].save(img_buffer, format='PNG')
1540
+ img_buffer.seek(0)
1541
+
1542
+ # Full screen background image
1543
+ pic = slide.shapes.add_picture(
1544
+ img_buffer,
1545
+ 0, 0,
1546
+ width=prs.slide_width,
1547
+ height=prs.slide_height
1548
+ )
1549
+ # Send to back
1550
+ slide.shapes._spTree.remove(pic._element)
1551
+ slide.shapes._spTree.insert(2, pic._element)
1552
+ except Exception as e:
1553
+ print(f"[PPTX] Failed to add title image: {str(e)}")
1554
+
1555
+ # Title background box (semi-transparent)
1556
+ title_bg = slide.shapes.add_shape(
1557
+ MSO_SHAPE.ROUNDED_RECTANGLE,
1558
+ Inches(2), Inches(2.8),
1559
+ Inches(12), Inches(3.2)
1560
+ )
1561
+ title_bg.fill.solid()
1562
+ title_bg.fill.fore_color.rgb = RGBColor(255, 255, 255)
1563
+ title_bg.fill.transparency = 0.8
1564
+ title_bg.line.fill.background()
1565
+
1566
+ # Shadow effect
1567
+ shadow = title_bg.shadow
1568
+ shadow.visible = True
1569
+ shadow.distance = Pt(6)
1570
+ shadow.size = 100
1571
+ shadow.blur_radius = Pt(12)
1572
+ shadow.transparency = 0.8
1573
+ shadow.angle = 45
1574
+
1575
+ # Title text
1576
+ title_box = slide.shapes.add_textbox(
1577
+ Inches(2), Inches(3.2),
1578
+ Inches(12), Inches(1.5)
1579
+ )
1580
+ title_frame = title_box.text_frame
1581
+ title_frame.text = topic
1582
+ title_para = title_frame.paragraphs[0]
1583
+ title_para.font.size = Pt(48)
1584
+ title_para.font.bold = True
1585
+ title_para.font.color.rgb = RGBColor(0, 0, 0)
1586
+ title_para.alignment = PP_ALIGN.CENTER
1587
+
1588
+ # Subtitle
1589
+ subtitle_box = slide.shapes.add_textbox(
1590
+ Inches(2), Inches(4.3),
1591
+ Inches(12), Inches(1.0)
1592
+ )
1593
+ subtitle_frame = subtitle_box.text_frame
1594
+ subtitle_frame.text = slide_data.get('subtitle', f'{template_name} - AI Presentation')
1595
+ subtitle_para = subtitle_frame.paragraphs[0]
1596
+ subtitle_para.font.size = Pt(28)
1597
+ subtitle_para.font.color.rgb = RGBColor(33, 37, 41)
1598
+ subtitle_para.alignment = PP_ALIGN.CENTER
1599
+
1600
+ # Thank You slide
1601
+ elif slide_data.get('title') == 'Thank You':
1602
+ # Add background image
1603
+ if slide_data.get('image'):
1604
+ try:
1605
+ img_buffer = BytesIO()
1606
+ slide_data['image'].save(img_buffer, format='PNG')
1607
+ img_buffer.seek(0)
1608
+
1609
+ # Full screen background image
1610
+ pic = slide.shapes.add_picture(
1611
+ img_buffer,
1612
+ 0, 0,
1613
+ width=prs.slide_width,
1614
+ height=prs.slide_height
1615
+ )
1616
+ # Send to back
1617
+ slide.shapes._spTree.remove(pic._element)
1618
+ slide.shapes._spTree.insert(2, pic._element)
1619
+ except Exception as e:
1620
+ print(f"[PPTX] Failed to add Thank You image: {str(e)}")
1621
+
1622
+ # Thank You background box
1623
+ thanks_bg = slide.shapes.add_shape(
1624
+ MSO_SHAPE.ROUNDED_RECTANGLE,
1625
+ Inches(2), Inches(3.5),
1626
+ Inches(12), Inches(2.5)
1627
+ )
1628
+ thanks_bg.fill.solid()
1629
+ thanks_bg.fill.fore_color.rgb = RGBColor(255, 255, 255)
1630
+ thanks_bg.fill.transparency = 0.8
1631
+ thanks_bg.line.fill.background()
1632
+
1633
+ # Shadow effect
1634
+ shadow = thanks_bg.shadow
1635
+ shadow.visible = True
1636
+ shadow.distance = Pt(6)
1637
+ shadow.size = 100
1638
+ shadow.blur_radius = Pt(12)
1639
+ shadow.transparency = 0.8
1640
+ shadow.angle = 45
1641
+
1642
+ # Thank You text (conclusion phrase)
1643
+ thanks_box = slide.shapes.add_textbox(
1644
+ Inches(2), Inches(4),
1645
+ Inches(12), Inches(1.5)
1646
+ )
1647
+ thanks_frame = thanks_box.text_frame
1648
+ thanks_frame.text = slide_data.get('subtitle', 'Thank You')
1649
+ thanks_para = thanks_frame.paragraphs[0]
1650
+ thanks_para.font.size = Pt(42)
1651
+ thanks_para.font.bold = True
1652
+ thanks_para.font.color.rgb = RGBColor(0, 0, 0)
1653
+ thanks_para.alignment = PP_ALIGN.CENTER
1654
+
1655
+ # Regular slides
1656
+ else:
1657
+ # Background color
1658
+ background = slide.background
1659
+ fill = background.fill
1660
+ fill.solid()
1661
+ fill.fore_color.rgb = theme.get("background", RGBColor(250, 250, 252))
1662
+
1663
+ # Slide title background box
1664
+ title_box_bg = slide.shapes.add_shape(
1665
+ MSO_SHAPE.ROUNDED_RECTANGLE,
1666
+ Inches(0.3), Inches(0.2),
1667
+ Inches(15.4), Inches(1.0)
1668
+ )
1669
+ title_box_bg.fill.solid()
1670
+ title_box_bg.fill.fore_color.rgb = theme.get("box_fill", RGBColor(255, 255, 255))
1671
+ title_box_bg.fill.transparency = 1 - theme.get("box_opacity", 0.95)
1672
+
1673
+ # Shadow effect
1674
+ if theme.get("shadow", True):
1675
+ shadow = title_box_bg.shadow
1676
+ shadow.visible = True
1677
+ shadow.distance = Pt(4)
1678
+ shadow.size = 100
1679
+ shadow.blur_radius = Pt(8)
1680
+ shadow.transparency = 0.75
1681
+ shadow.angle = 45
1682
+
1683
+ title_box_bg.line.fill.background()
1684
+
1685
+ # Slide title
1686
+ title_box = slide.shapes.add_textbox(
1687
+ Inches(0.5), Inches(0.3),
1688
+ Inches(15), Inches(0.8)
1689
+ )
1690
+ title_frame = title_box.text_frame
1691
+ title_frame.text = f"{slide_data.get('title', '')}"
1692
+ title_para = title_frame.paragraphs[0]
1693
+ title_para.font.size = Pt(28)
1694
+ title_para.font.bold = True
1695
+ title_para.font.color.rgb = theme.get("title_color", RGBColor(33, 37, 41))
1696
+
1697
+ # Left text area background box
1698
+ text_box_bg = slide.shapes.add_shape(
1699
+ MSO_SHAPE.ROUNDED_RECTANGLE,
1700
+ Inches(0.3), Inches(1.4),
1701
+ Inches(7.8), Inches(6.8)
1702
+ )
1703
+ text_box_bg.fill.solid()
1704
+ text_box_bg.fill.fore_color.rgb = theme.get("box_fill", RGBColor(255, 255, 255))
1705
+ text_box_bg.fill.transparency = 1 - theme.get("box_opacity", 0.95)
1706
+
1707
+ if theme.get("shadow", True):
1708
+ shadow = text_box_bg.shadow
1709
+ shadow.visible = True
1710
+ shadow.distance = Pt(5)
1711
+ shadow.size = 100
1712
+ shadow.blur_radius = Pt(10)
1713
+ shadow.transparency = 0.7
1714
+ shadow.angle = 45
1715
+
1716
+ text_box_bg.line.fill.background()
1717
+
1718
+ # Left text area
1719
+ text_box = slide.shapes.add_textbox(
1720
+ Inches(0.8), Inches(1.8),
1721
+ Inches(7.0), Inches(6.0)
1722
+ )
1723
+ text_frame = text_box.text_frame
1724
+ text_frame.word_wrap = True
1725
+
1726
+ # Subtitle
1727
+ subtitle_para = text_frame.paragraphs[0]
1728
+ subtitle_para.text = slide_data.get('subtitle', '')
1729
+ subtitle_para.font.size = Pt(20)
1730
+ subtitle_para.font.bold = True
1731
+ subtitle_para.font.color.rgb = theme.get("subtitle_color", RGBColor(52, 58, 64))
1732
+ subtitle_para.space_after = Pt(20)
1733
+
1734
+ # Bullet points
1735
+ bullet_points = slide_data.get('bullet_points', [])
1736
+ for point in bullet_points:
1737
+ p = text_frame.add_paragraph()
1738
+ # Remove โ€ข and add text only (keep emojis)
1739
+ clean_text = point.replace('โ€ข', '').strip()
1740
+ p.text = clean_text
1741
+ p.font.size = Pt(16)
1742
+ p.font.color.rgb = theme.get("text_color", RGBColor(73, 80, 87))
1743
+ p.level = 0
1744
+ p.space_after = Pt(12)
1745
+ p.line_spacing = 1.5
1746
+ p.left_indent = Pt(0)
1747
+
1748
+ # Right image
1749
+ if slide_data.get('image'):
1750
+ try:
1751
+ img_buffer = BytesIO()
1752
+ slide_data['image'].save(img_buffer, format='PNG')
1753
+ img_buffer.seek(0)
1754
+
1755
+ pic = slide.shapes.add_picture(
1756
+ img_buffer,
1757
+ Inches(8.5), Inches(1.6),
1758
+ width=Inches(6.8), height=Inches(6.4)
1759
+ )
1760
+
1761
+ pic.line.fill.background()
1762
+
1763
+ except Exception as e:
1764
+ print(f"[PPTX] Failed to add image: {str(e)}")
1765
+
1766
+ # Page number
1767
+ page_num = slide.shapes.add_textbox(
1768
+ Inches(15), Inches(8.5),
1769
+ Inches(1), Inches(0.5)
1770
+ )
1771
+ page_frame = page_num.text_frame
1772
+ page_frame.text = str(i + 1)
1773
+ page_para = page_frame.paragraphs[0]
1774
+ page_para.font.size = Pt(12)
1775
+ page_para.font.color.rgb = theme.get("text_color", RGBColor(73, 80, 87))
1776
+ page_para.alignment = PP_ALIGN.RIGHT
1777
+
1778
+ # Add speaker notes
1779
+ notes_slide = slide.notes_slide
1780
+ notes_slide.notes_text_frame.text = slide_data.get('speaker_notes', '')
1781
+
1782
+ # Save file
1783
+ timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
1784
+ filename = f"presentation_{timestamp}.pptx"
1785
+ filepath = os.path.join("/tmp", filename)
1786
+ prs.save(filepath)
1787
+
1788
+ print(f"[PPTX] File created: {filename}")
1789
+ return filepath
ui_components.py ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ui_components.py
2
+ """UI components and helper functions for PPT Generator"""
3
+
4
+ import gradio as gr
5
+ from typing import List, Dict, Tuple
6
+ from constants import STYLE_TEMPLATES, PPT_TEMPLATES, DESIGN_THEMES, EXAMPLE_TOPICS, AUDIENCE_TYPES
7
+ from content_utils import generate_dynamic_slides
8
+
9
+ def create_custom_slides_ui(initial_count=5):
10
+ """Custom slides configuration UI (3-20 slides)"""
11
+ slides = []
12
+ for i in range(20): # Max 20 slides
13
+ row = gr.Row(visible=(i < initial_count))
14
+ with row:
15
+ with gr.Column(scale=2):
16
+ title = gr.Textbox(
17
+ label=f"Slide {i+1} Title",
18
+ placeholder="e.g., Current Analysis, Solution, Roadmap...",
19
+ )
20
+ with gr.Column(scale=3):
21
+ style = gr.Dropdown(
22
+ choices=list(STYLE_TEMPLATES.keys()),
23
+ label=f"Style Selection",
24
+ value="Colorful Mind Map"
25
+ )
26
+ with gr.Column(scale=3):
27
+ hint = gr.Textbox(
28
+ label=f"Prompt Hint",
29
+ placeholder="Content to express in this slide"
30
+ )
31
+ slides.append({"title": title, "style": style, "hint": hint, "row": row})
32
+ return slides
33
+
34
+ def load_example(template_name, language):
35
+ """Load example topic for template"""
36
+ lang_key = "Korean" if language == "Korean" else "English"
37
+ example_topic = EXAMPLE_TOPICS[lang_key].get(template_name, "")
38
+ return example_topic
39
+
40
+ def update_audience_info(audience_type):
41
+ """Display audience information"""
42
+ info = AUDIENCE_TYPES.get(audience_type, {})
43
+ return f"""**{info.get('description', '')}**
44
+ - Tone: {info.get('tone', '')}
45
+ - Focus: {info.get('focus', '')}"""
46
+
47
+ def update_theme_preview(theme_name):
48
+ """Generate theme preview HTML"""
49
+ theme = DESIGN_THEMES.get(theme_name, DESIGN_THEMES["Minimal Light"])
50
+
51
+ # Convert RGB to hex
52
+ def rgb_to_hex(rgb_color):
53
+ return f"#{rgb_color[0]:02x}{rgb_color[1]:02x}{rgb_color[2]:02x}"
54
+
55
+ bg_hex = rgb_to_hex(theme["background"])
56
+ box_hex = rgb_to_hex(theme["box_fill"])
57
+ title_hex = rgb_to_hex(theme["title_color"])
58
+ text_hex = rgb_to_hex(theme["text_color"])
59
+ accent_hex = rgb_to_hex(theme["accent_color"])
60
+
61
+ preview_html = f"""
62
+ <div style="
63
+ background: {bg_hex};
64
+ padding: 20px;
65
+ border-radius: 8px;
66
+ margin: 10px 0;
67
+ ">
68
+ <div style="
69
+ background: {box_hex};
70
+ opacity: {theme['box_opacity']};
71
+ padding: 15px;
72
+ border-radius: 12px;
73
+ margin-bottom: 10px;
74
+ {'box-shadow: 0 4px 8px rgba(0,0,0,0.1);' if theme['shadow'] else ''}
75
+ ">
76
+ <h4 style="color: {title_hex}; margin: 0 0 10px 0;">{theme['name']}</h4>
77
+ <p style="color: {text_hex}; margin: 0; font-size: 14px;">
78
+ {theme['description']}
79
+ </p>
80
+ <div style="
81
+ width: 40px;
82
+ height: 4px;
83
+ background: {accent_hex};
84
+ margin-top: 10px;
85
+ border-radius: 2px;
86
+ "></div>
87
+ </div>
88
+ </div>
89
+ """
90
+ return preview_html
91
+
92
+ def update_template_info(template_name, slide_count):
93
+ is_custom = template_name == "Custom"
94
+ info = ""
95
+
96
+ if not is_custom and template_name in PPT_TEMPLATES:
97
+ template = PPT_TEMPLATES[template_name]
98
+ info = f"**{template['description']}**\n\n"
99
+
100
+ # Show dynamically generated slide composition
101
+ slides = generate_dynamic_slides("", template, slide_count)
102
+ info += f"Slides to be generated ({len(slides)} total):\n"
103
+ for i, slide in enumerate(slides):
104
+ style_info = STYLE_TEMPLATES.get(slide['style'], {})
105
+ info += f"{i+1}. {slide['title']} - {style_info.get('use_case', '')}"
106
+ if style_info.get('is_process_flow'):
107
+ info += " ๐Ÿ”ง"
108
+ info += "\n"
109
+ elif is_custom:
110
+ info = "**Custom Template**\n\nConfigure your slides directly in the 'Custom Slide Configuration' section below."
111
+
112
+ # Hide slide count selection for custom template
113
+ slide_count_visible = not is_custom
114
+ custom_accordion_open = is_custom
115
+
116
+ return info, gr.update(visible=slide_count_visible), gr.update(open=custom_accordion_open)
117
+
118
+ def update_custom_slides_visibility(count):
119
+ """Update UI visibility based on custom slide count"""
120
+ updates = []
121
+ for i in range(20):
122
+ updates.append(gr.update(visible=(i < count))) # row
123
+ return updates
124
+
125
+ def clear_all():
126
+ """๋ชจ๋“  ๋‚ด์šฉ ์ดˆ๊ธฐํ™”"""
127
+ return "", "", "", None, "๐Ÿ”„ ์ดˆ๊ธฐํ™”๋˜์—ˆ์Šต๋‹ˆ๋‹ค."
128
+
129
+ def get_css():
130
+ """Get custom CSS for the interface"""
131
+ return """
132
+ .preview-container { max-width: 1400px; margin: 0 auto; }
133
+ .slide-container { transition: all 0.3s ease; }
134
+ .slide-container:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15) !important; }
135
+ #custom_accordion .form {
136
+ max-height: 600px;
137
+ overflow-y: auto;
138
+ padding-right: 10px;
139
+ }
140
+ #custom_accordion .form::-webkit-scrollbar {
141
+ width: 6px;
142
+ }
143
+ #custom_accordion .form::-webkit-scrollbar-track {
144
+ background: #f1f1f1;
145
+ border-radius: 3px;
146
+ }
147
+ #custom_accordion .form::-webkit-scrollbar-thumb {
148
+ background: #888;
149
+ border-radius: 3px;
150
+ }
151
+ #custom_accordion .form::-webkit-scrollbar-thumb:hover {
152
+ background: #555;
153
+ }
154
+ .supervisor-box textarea {
155
+ border-left: 4px solid #667eea !important;
156
+ padding-left: 10px !important;
157
+ }
158
+ .researcher-box textarea {
159
+ border-left: 4px solid #10b981 !important;
160
+ padding-left: 10px !important;
161
+ }
162
+ .executor-box textarea {
163
+ border-left: 4px solid #764ba2 !important;
164
+ padding-left: 10px !important;
165
+ }
166
+ """
167
+
168
+ def get_usage_instructions():
169
+ """Get usage instructions markdown"""
170
+ return """
171
+ ### ๐Ÿ”„ Workflow:
172
+ 1. **Select Language**: Choose English or Korean for your presentation content
173
+ 2. **Load Example** or enter your own topic
174
+ 3. **Select Audience**: Content will be automatically optimized for your target audience
175
+ 4. **Choose Template and Theme**, then click generate
176
+ 5. **Download**: Download the PPTX file when generation is complete
177
+
178
+ ### ๐Ÿค– 3-AI Collaboration System:
179
+ - **Supervisor AI**: Designs PPT structure and provides guidance
180
+ - **Researcher AI**: Searches and organizes content information
181
+ - **Executor AI**: Creates actual PPT slides
182
+
183
+ ### ๐ŸŒ Language Support:
184
+ - **English**: Default interface language with English content generation
185
+ - **Korean**: Select for Korean content generation (full Korean PPT support)
186
+
187
+ ### ๐ŸŽญ Audience Features:
188
+ - **Executives/C-Level**: Strategic value, ROI, business impact focus
189
+ - **Investors**: Market opportunity, growth potential, profitability emphasis
190
+ - **Technical Team**: Technical details, implementation methods, performance metrics
191
+ - **General Staff**: Practical content, collaboration methods, execution plans
192
+ - **Customers/Partners**: Customer value, benefits, success stories
193
+ - **General Public**: Easy explanations, usability, practical benefits
194
+
195
+ ### ๐Ÿ’ก Text Style Features:
196
+ - **Concise noun-ending style**: Ends with nouns or short phrases
197
+ - **Emoji usage**: Relevant emojis automatically added before each point
198
+ - **8-12 words**: Each bullet point is very concise
199
+
200
+ ### ๐Ÿ“ Custom Slides:
201
+ - **Build your own**: Activated when selecting "Custom" template
202
+ - **3-20 slides freely**: Choose number of slides with slider
203
+ - **Style per slide**: Choose from 16 styles for each slide
204
+ - **Provide hints**: Guide content direction with prompt hints
205
+
206
+ ### ๐Ÿ”ง Process Flow Diagrams:
207
+ - **Automatic generation** for Business Workflow or Flowchart styles
208
+ - Full support for both English and Korean text
209
+ - Process, decision, input/output node types supported
210
+ """