yasserrmd commited on
Commit
691ff52
β€’
1 Parent(s): 140fb0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -16
app.py CHANGED
@@ -17,6 +17,10 @@ def generate_text(prompt):
17
  response = pipe(prompt, max_length=100, num_return_sequences=1)
18
  return response[0]['generated_text']
19
 
 
 
 
 
20
  # Custom CSS for the app
21
  css = """
22
  body {background-color: #f0f8ff; font-family: 'Arial', sans-serif;}
@@ -26,31 +30,35 @@ button {background-color: #4caf50; color: #000000; border-radius: 5px; padding:
26
  button:hover {background-color: #45a049;}
27
  h1 {color: #333; font-size: 32px; text-align: center;}
28
  footer {text-align: center; padding: 10px;}
29
- #icon {width: 50px; display: block; margin: 10px auto;}
30
  #prompt_box {padding: 10px; background-color: #f9f9f9; border-radius: 10px;}
31
  """
32
 
33
  # Create the Gradio interface
34
  with gr.Blocks(css=css) as journal_app:
35
 
36
- # Header and icons
37
  gr.Markdown("# πŸ“ Productivity Journal")
38
- gr.Markdown("Welcome to your personalized productivity journal. Enter your thoughts and let AI inspire you to stay on track!")
 
 
 
39
 
40
- # Provide guided prompts to help the user write their entry
41
- gr.Markdown("### **Here are some ideas to get started:**")
42
- gr.Markdown("""
43
- - 🌟 *What's one thing you accomplished today that you're proud of?*
44
- - 🧠 *What was your biggest challenge today? How did you overcome it?*
45
- - 🎯 *What's a goal you want to focus on tomorrow?*
46
- - πŸ“ *What are you feeling grateful for right now?*
47
- - πŸš€ *What's one new thing you learned today, and how can you apply it?*
48
- """)
 
 
49
 
50
  with gr.Row():
51
  with gr.Column():
52
- # Input text box
53
- prompt = gr.Textbox(label="Write your thoughts here:", placeholder="Start with a reflection or goal...", elem_id="prompt_box", lines=5)
54
 
55
  with gr.Column():
56
  # Output for generated text
@@ -59,8 +67,8 @@ with gr.Blocks(css=css) as journal_app:
59
  # Generate button
60
  generate_button = gr.Button("Generate Entry ✍️")
61
 
62
- # Define the click event
63
- generate_button.click(fn=generate_text, inputs=prompt, outputs=output)
64
 
65
  # Footer
66
  gr.Markdown("🌞 Keep your spirits high and stay productive! 😊")
 
17
  response = pipe(prompt, max_length=100, num_return_sequences=1)
18
  return response[0]['generated_text']
19
 
20
+ # Function to handle example entry selection
21
+ def fill_prompt(selected_prompt):
22
+ return selected_prompt
23
+
24
  # Custom CSS for the app
25
  css = """
26
  body {background-color: #f0f8ff; font-family: 'Arial', sans-serif;}
 
30
  button:hover {background-color: #45a049;}
31
  h1 {color: #333; font-size: 32px; text-align: center;}
32
  footer {text-align: center; padding: 10px;}
 
33
  #prompt_box {padding: 10px; background-color: #f9f9f9; border-radius: 10px;}
34
  """
35
 
36
  # Create the Gradio interface
37
  with gr.Blocks(css=css) as journal_app:
38
 
39
+ # Header and introduction
40
  gr.Markdown("# πŸ“ Productivity Journal")
41
+ gr.Markdown("Welcome to your personalized productivity journal. Click an example below or write your thoughts!")
42
+
43
+ # Actual example journal entries for users to click and add to the text box
44
+ gr.Markdown("### **Click an example to start writing:**")
45
 
46
+ with gr.Row():
47
+ example_entries = [
48
+ "🌟 Today, I finished a major project that I’ve been working on for weeks. It felt great to finally get it done, and I’m proud of the effort I put in.",
49
+ "🧠 I faced a tough challenge today when I had to give a presentation with very little preparation. Despite feeling nervous, I managed to pull through by staying calm and focused.",
50
+ "🎯 Tomorrow, my goal is to focus on improving my communication skills during team meetings. I want to make sure I’m clear and concise in expressing my ideas.",
51
+ "πŸ“ I’m grateful for the support I received from my coworkers today. Their encouragement really helped me push through a stressful moment.",
52
+ "πŸš€ I learned a new approach to managing my time more effectively today. I’m going to apply this to my daily routine to see if it helps me stay more productive."
53
+ ]
54
+
55
+ for entry in example_entries:
56
+ gr.Button(entry).click(fn=fill_prompt, inputs=[], outputs="prompt_textbox")
57
 
58
  with gr.Row():
59
  with gr.Column():
60
+ # Input text box with example entries functionality
61
+ prompt_textbox = gr.Textbox(label="Write your thoughts here:", placeholder="Start writing or select an example...", elem_id="prompt_box", lines=5)
62
 
63
  with gr.Column():
64
  # Output for generated text
 
67
  # Generate button
68
  generate_button = gr.Button("Generate Entry ✍️")
69
 
70
+ # Define the click event for text generation
71
+ generate_button.click(fn=generate_text, inputs=prompt_textbox, outputs=output)
72
 
73
  # Footer
74
  gr.Markdown("🌞 Keep your spirits high and stay productive! 😊")