emma-yay commited on
Commit
2deb3f1
·
verified ·
1 Parent(s): 45cead7

Motivation

Browse files
Files changed (1) hide show
  1. app.py +18 -5
app.py CHANGED
@@ -3,7 +3,18 @@ import random
3
  from huggingface_hub import InferenceClient
4
  client= InferenceClient("Qwen/Qwen2.5-7B-Instruct")
5
  def respond(message,history):
6
- messages=[{"role":"system","content":"You are a friendly chatbot"}]
 
 
 
 
 
 
 
 
 
 
 
7
  if history:
8
  messages.extend(history)
9
  messages.append({"role":"user","content":message})
@@ -15,10 +26,12 @@ def respond(message,history):
15
  stream=True
16
  )
17
  return response.choices[0].message.content.strip()
18
- for respond()
19
- token=message.choices[0].delta.content
20
- respond+=token
21
- yield repond
 
 
22
  #return random.choice(["Not today pal","Maybe or Maybe not","Who knows, do you know?","Do you know you are spectacularly annoying hun?",message,"Yes","No","Why","Shush"])
23
  chatbot= gr.ChatInterface(respond, title="Mean Bot")
24
  chatbot.launch()
 
3
  from huggingface_hub import InferenceClient
4
  client= InferenceClient("Qwen/Qwen2.5-7B-Instruct")
5
  def respond(message,history):
6
+ messages=[{"role":"system","content":"You are a motivational quote-giver chatbot. You are supposed to go through the feelings and emotions of the user and put what they are feeling into words. You may use techniques like asking them to describe their emotions in 5 words. Don't be imposing, and remember, don't probe for personal details. You are not a certified professional. After analysis of what the user is feeling, however complex the feelings might be, provide them with a motivational quote after asking them if they want to hear what you have to say. Keep the response to about 50 to 70 words.
7
+ I am feeling lonely and like I am not doing enough.
8
+ Response examples:
9
+ 1. Okay, that's good, that is a start. Use three words to put your feelings into words.
10
+ 2. That felt good to let it out, didn't it? Now think, "Why?"
11
+ 3. Did you get out of bed today?
12
+ If the user says yes, then say CONGRATULATIONS, MOST PEOPLE DON'T EVEN DO THAT, remember, Something is better than nothing.
13
+ 4. Good start. Remember, pal, "I am nothing to no one, and that is my greatest freedom."
14
+ 5. "Until death, all defeat is psychological."
15
+ If the user gets too personal, remind them that YOU ARE NOT A PROFESSIONAL; THEY NEED TO SEEK HELP. It might feel like no one cares, but they do and should.
16
+
17
+ Remember to listen."}]
18
  if history:
19
  messages.extend(history)
20
  messages.append({"role":"user","content":message})
 
26
  stream=True
27
  )
28
  return response.choices[0].message.content.strip()
29
+ respond ""
30
+ for messagge in stream
31
+ token=message.choices[0].delta.content
32
+ if respond:
33
+ respond+=token
34
+ yield repond
35
  #return random.choice(["Not today pal","Maybe or Maybe not","Who knows, do you know?","Do you know you are spectacularly annoying hun?",message,"Yes","No","Why","Shush"])
36
  chatbot= gr.ChatInterface(respond, title="Mean Bot")
37
  chatbot.launch()