Update app.py
Browse files
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
|
| 37 |
gr.Markdown("# π Productivity Journal")
|
| 38 |
-
gr.Markdown("Welcome to your personalized productivity journal.
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
| 49 |
|
| 50 |
with gr.Row():
|
| 51 |
with gr.Column():
|
| 52 |
-
# Input text box
|
| 53 |
-
|
| 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=
|
| 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! π")
|