farah1 commited on
Commit
0eb69ca
·
verified ·
1 Parent(s): 017a61f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -88,7 +88,7 @@ def classify_text(api_key, input_text, k=20):
88
  print(f"Error occurred: {e}")
89
  return f"Error: {e}"
90
 
91
- # Enhanced Gradio Interface
92
  with gr.Blocks() as interface:
93
  gr.Markdown(
94
  """
@@ -105,6 +105,17 @@ with gr.Blocks() as interface:
105
  placeholder="Enter your OpenAI API key here...",
106
  type="password",
107
  )
 
 
 
 
 
 
 
 
 
 
 
108
  with gr.Row():
109
  text_input = gr.Textbox(
110
  label="📝 Input Text",
@@ -120,6 +131,9 @@ with gr.Blocks() as interface:
120
  interactive=False,
121
  )
122
 
 
 
 
123
  submit_button.click(
124
  classify_text,
125
  inputs=[api_key_input, text_input],
@@ -129,3 +143,4 @@ with gr.Blocks() as interface:
129
  if __name__ == "__main__":
130
  interface.launch()
131
 
 
 
88
  print(f"Error occurred: {e}")
89
  return f"Error: {e}"
90
 
91
+ # Enhanced Gradio Interface with Examples
92
  with gr.Blocks() as interface:
93
  gr.Markdown(
94
  """
 
105
  placeholder="Enter your OpenAI API key here...",
106
  type="password",
107
  )
108
+ with gr.Row():
109
+ example_texts = gr.Dropdown(
110
+ label="🔎 Example Texts",
111
+ choices=[
112
+ "I feel like I'm constantly under pressure at work. The deadlines keep piling up, and I can't seem to catch a break. I'm exhausted and overwhelmed.", # Stress
113
+ "Lately, I’ve been feeling really anxious about social situations. I keep overthinking what people might think of me, and it’s making me avoid going out altogether.", # Anxiety
114
+ "I have no energy or motivation to do anything. Even getting out of bed feels like a struggle, and nothing seems to make me happy anymore.", # Depression
115
+ ],
116
+ value="Select an example text or type your own below.",
117
+ interactive=True,
118
+ )
119
  with gr.Row():
120
  text_input = gr.Textbox(
121
  label="📝 Input Text",
 
131
  interactive=False,
132
  )
133
 
134
+ # Update the text input field when an example is selected
135
+ example_texts.change(fn=lambda x: x, inputs=example_texts, outputs=text_input)
136
+
137
  submit_button.click(
138
  classify_text,
139
  inputs=[api_key_input, text_input],
 
143
  if __name__ == "__main__":
144
  interface.launch()
145
 
146
+