yasserrmd commited on
Commit
3096487
·
verified ·
1 Parent(s): 1fc0910

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -17,10 +17,6 @@ def generate_text(prompt):
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;}
@@ -42,6 +38,10 @@ example_entries = [
42
  "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."
43
  ]
44
 
 
 
 
 
45
  # Create the Gradio interface
46
  with gr.Blocks(css=css) as journal_app:
47
 
@@ -53,14 +53,12 @@ with gr.Blocks(css=css) as journal_app:
53
  gr.Markdown("### **Click an example to start writing:**")
54
 
55
  with gr.Row():
 
 
56
  for i, entry in enumerate(example_entries):
57
- gr.Button(f"Example {i+1}").click(fn=lambda e=entry: fill_prompt(e), inputs=[], outputs="prompt_textbox")
58
 
59
  with gr.Row():
60
- with gr.Column():
61
- # Input text box with example entries functionality
62
- prompt_textbox = gr.Textbox(label="Write your thoughts here:", placeholder="Start writing or select an example...", elem_id="prompt_box", lines=5)
63
-
64
  with gr.Column():
65
  # Output for generated text
66
  output = gr.Textbox(label="Your AI Journal Entry ✨", lines=5)
@@ -76,4 +74,4 @@ with gr.Blocks(css=css) as journal_app:
76
  gr.Markdown("Made with ❤️ using Gradio and Llama-3.2")
77
 
78
  # Launch the app
79
- journal_app.launch()
 
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;}
 
38
  "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."
39
  ]
40
 
41
+ # Function to return the selected prompt
42
+ def fill_prompt(selected_prompt):
43
+ return gr.update(value=selected_prompt)
44
+
45
  # Create the Gradio interface
46
  with gr.Blocks(css=css) as journal_app:
47
 
 
53
  gr.Markdown("### **Click an example to start writing:**")
54
 
55
  with gr.Row():
56
+ prompt_textbox = gr.Textbox(label="Write your thoughts here:", placeholder="Start writing or select an example...", elem_id="prompt_box", lines=5)
57
+
58
  for i, entry in enumerate(example_entries):
59
+ gr.Button(f"Example {i+1}").click(fn=fill_prompt, inputs=None, outputs=prompt_textbox, _js="")
60
 
61
  with gr.Row():
 
 
 
 
62
  with gr.Column():
63
  # Output for generated text
64
  output = gr.Textbox(label="Your AI Journal Entry ✨", lines=5)
 
74
  gr.Markdown("Made with ❤️ using Gradio and Llama-3.2")
75
 
76
  # Launch the app
77
+ journal_app.launch()