Spaces:
Sleeping
Sleeping
motivate
Browse files
app.py
CHANGED
|
@@ -3,17 +3,16 @@ 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 motivational quote-giver chatbot. You are supposed to go through the feelings and emotions
|
| 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,
|
| 11 |
-
3. Did you get out of bed today?
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
if history:
|
| 17 |
messages.extend(history)
|
| 18 |
messages.append({"role":"user","content":message})
|
| 19 |
response= client.chat_completion(
|
|
@@ -25,8 +24,8 @@ If the user gets too personal, remind them that YOU ARE NOT A PROFESSIONAL; THEY
|
|
| 25 |
)
|
| 26 |
return response.choices[0].message.content.strip()
|
| 27 |
respond ""
|
| 28 |
-
for messagge in stream
|
| 29 |
-
|
| 30 |
if respond:
|
| 31 |
respond+=token
|
| 32 |
yield repond
|
|
|
|
| 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 user's feelings and emotions and put them into words. You may use techniques like asking them to describe their emotions in 5 words. Don't be imposing, and remember not to 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 |
+
Example: “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? If the user says yes, then say CONGRATULATIONS, MOST PEOPLE DON'T EVEN DO THAT. Remember, “Something is better than nothing”.
|
| 12 |
+
4. Good start. Remember, pal, “I am nothing to no one, and that is my greatest freedom.”
|
| 13 |
+
5. “Until death, all defeat is psychological”.
|
| 14 |
+
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. Remember to listen.
|
| 15 |
+
"""]}
|
|
|
|
| 16 |
messages.extend(history)
|
| 17 |
messages.append({"role":"user","content":message})
|
| 18 |
response= client.chat_completion(
|
|
|
|
| 24 |
)
|
| 25 |
return response.choices[0].message.content.strip()
|
| 26 |
respond ""
|
| 27 |
+
for messagge in stream:
|
| 28 |
+
token=message.choices[0].delta.content
|
| 29 |
if respond:
|
| 30 |
respond+=token
|
| 31 |
yield repond
|