Khushisingla commited on
Commit
385cea5
1 Parent(s): 67fdf84

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -16
app.py CHANGED
@@ -1,12 +1,8 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
- """
5
- For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
- """
7
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
 
9
-
10
  def respond(
11
  message,
12
  history: list[tuple[str, str]],
@@ -15,6 +11,11 @@ def respond(
15
  temperature,
16
  top_p,
17
  ):
 
 
 
 
 
18
  messages = [{"role": "system", "content": system_message}]
19
 
20
  for val in history:
@@ -39,25 +40,21 @@ def respond(
39
  response += token
40
  yield response
41
 
42
- """
43
- For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
44
- """
45
  demo = gr.ChatInterface(
46
  respond,
47
  additional_inputs=[
48
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
49
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
50
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
51
- gr.Slider(
52
- minimum=0.1,
53
- maximum=1.0,
54
- value=0.95,
55
- step=0.05,
56
- label="Top-p (nucleus sampling)",
57
- ),
58
  ],
 
 
 
 
 
 
59
  )
60
 
61
-
62
  if __name__ == "__main__":
63
  demo.launch()
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
 
 
 
4
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
5
 
 
6
  def respond(
7
  message,
8
  history: list[tuple[str, str]],
 
11
  temperature,
12
  top_p,
13
  ):
14
+ if system_message is None:
15
+ system_message = "I'm here to help you unwind. Let's take a deep breath together."
16
+ else:
17
+ system_message = "You are a good stress reliefer. your approach is to encourage letting go of overthinking, steering away from negative thoughts, and providing practical steps to manage stress effectively. Feel free to share what's on your mind, or would you like to try a quick relaxation exercise together."
18
+
19
  messages = [{"role": "system", "content": system_message}]
20
 
21
  for val in history:
 
40
  response += token
41
  yield response
42
 
 
 
 
43
  demo = gr.ChatInterface(
44
  respond,
45
  additional_inputs=[
46
+ gr.Textbox(value="Remember to breathe deeply. Avoid fixating on unhelpful thoughts.", label="System message"),
47
  gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
48
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
49
+ gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
 
 
 
 
 
 
50
  ],
51
+ examples=[
52
+ ["I feel stressed with work."],
53
+ ["How can I incorporate mindfulness into my daily routine to reduce stress?"],
54
+ ["How do you recommend I handle recurring negative thoughts that contribute to my stress?"]
55
+ ],
56
+ title="Peace_maker"
57
  )
58
 
 
59
  if __name__ == "__main__":
60
  demo.launch()