Ozgur Unlu
commited on
Commit
β’
9fb1b7d
1
Parent(s):
a4cf769
small changes
Browse files
app.py
CHANGED
@@ -286,8 +286,74 @@ def create_interface():
|
|
286 |
|
287 |
def clear_form():
|
288 |
return [""] * 7 # Returns empty strings for all 7 input fields
|
|
|
|
|
289 |
|
290 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
291 |
|
292 |
# Create the interface with blocks for custom layout
|
293 |
with gr.Blocks(theme=gr.themes.Default()) as demo:
|
@@ -300,7 +366,7 @@ def create_interface():
|
|
300 |
"Fill the form with sample data",
|
301 |
variant="primary",
|
302 |
size="sm",
|
303 |
-
scale=
|
304 |
)
|
305 |
|
306 |
# Main content area with two columns
|
@@ -321,8 +387,10 @@ def create_interface():
|
|
321 |
|
322 |
# Buttons row at the bottom of the form
|
323 |
with gr.Row():
|
324 |
-
|
325 |
-
|
|
|
|
|
326 |
|
327 |
# Right column - Output
|
328 |
with gr.Column(scale=1):
|
|
|
286 |
|
287 |
def clear_form():
|
288 |
return [""] * 7 # Returns empty strings for all 7 input fields
|
289 |
+
|
290 |
+
import time
|
291 |
|
292 |
+
def process_input_with_loading(
|
293 |
+
product_name,
|
294 |
+
product_description,
|
295 |
+
target_audience,
|
296 |
+
key_features,
|
297 |
+
unique_benefits,
|
298 |
+
platform,
|
299 |
+
tone,
|
300 |
+
progress=gr.Progress()
|
301 |
+
):
|
302 |
+
# Initial loading message
|
303 |
+
features_list = """β‘ While I generate your content, here's what I can do:
|
304 |
+
|
305 |
+
π Generate multiple unique marketing messages
|
306 |
+
π― Adapt content for different platforms
|
307 |
+
π Ensure ethical content generation
|
308 |
+
π Analyze sentiment and safety
|
309 |
+
β¨ Create platform-specific formatting
|
310 |
+
|
311 |
+
Processing your request..."""
|
312 |
+
|
313 |
+
yield features_list + "\n\nβ³ Starting generation..."
|
314 |
+
time.sleep(1)
|
315 |
+
|
316 |
+
# Update message with steps
|
317 |
+
steps = [
|
318 |
+
"Loading language models...",
|
319 |
+
"Analyzing product information...",
|
320 |
+
"Generating content variations...",
|
321 |
+
"Checking content safety...",
|
322 |
+
"Finalizing output..."
|
323 |
+
]
|
324 |
+
|
325 |
+
for i, step in enumerate(steps, 1):
|
326 |
+
progress(i/len(steps))
|
327 |
+
yield features_list + f"\n\nβ³ {step}"
|
328 |
+
time.sleep(1)
|
329 |
+
|
330 |
+
# Generate actual content
|
331 |
+
try:
|
332 |
+
results = generate_content(
|
333 |
+
product_name,
|
334 |
+
product_description,
|
335 |
+
target_audience,
|
336 |
+
key_features,
|
337 |
+
unique_benefits,
|
338 |
+
platform,
|
339 |
+
tone,
|
340 |
+
generator_tokenizer,
|
341 |
+
generator,
|
342 |
+
sentiment_analyzer,
|
343 |
+
content_checker
|
344 |
+
)
|
345 |
+
|
346 |
+
output = "π― Generated Marketing Content:\n\n"
|
347 |
+
for i, content in enumerate(results, 1):
|
348 |
+
output += f"Version {i}:\n"
|
349 |
+
output += f"π Content: {content['text']}\n"
|
350 |
+
output += f"π Sentiment: {content['sentiment']}\n"
|
351 |
+
output += f"β
Safety Score: {content['safety_score']}\n"
|
352 |
+
output += "-" * 50 + "\n"
|
353 |
+
|
354 |
+
yield output
|
355 |
+
except Exception as e:
|
356 |
+
yield f"An error occurred: {str(e)}"
|
357 |
|
358 |
# Create the interface with blocks for custom layout
|
359 |
with gr.Blocks(theme=gr.themes.Default()) as demo:
|
|
|
366 |
"Fill the form with sample data",
|
367 |
variant="primary",
|
368 |
size="sm",
|
369 |
+
scale=0.2
|
370 |
)
|
371 |
|
372 |
# Main content area with two columns
|
|
|
387 |
|
388 |
# Buttons row at the bottom of the form
|
389 |
with gr.Row():
|
390 |
+
with gr.Column(scale=2):
|
391 |
+
submit_button = gr.Button("Generate Content", variant="primary", scale=1)
|
392 |
+
with gr.Column(scale=1):
|
393 |
+
clear_button = gr.Button("Clear Form", variant="secondary", scale=1)
|
394 |
|
395 |
# Right column - Output
|
396 |
with gr.Column(scale=1):
|