Spaces:
Sleeping
Sleeping
Updated Code
Browse files
app.py
CHANGED
|
@@ -1,22 +1,23 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
client = InferenceClient("Qwen/Qwen2.5-7B-Instruct")
|
| 5 |
|
| 6 |
-
def
|
| 7 |
-
messages = [{"role":"system",
|
| 8 |
-
|
|
|
|
| 9 |
if history:
|
| 10 |
messages.extend(history)
|
| 11 |
-
messages.append({"role":"user",
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
chatbot = gr.ChatInterface(random_response, title = "Vanshika's First Chatbot")
|
| 21 |
|
|
|
|
| 22 |
chatbot.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
client = InferenceClient("Qwen/Qwen2.5-7B-Instruct")
|
| 6 |
|
| 7 |
+
def respond(message, history):
|
| 8 |
+
messages = [{"role": "system",
|
| 9 |
+
"content":"You are an emotional support chatbot. "
|
| 10 |
+
}]
|
| 11 |
if history:
|
| 12 |
messages.extend(history)
|
| 13 |
+
messages.append({"role":"user",
|
| 14 |
+
"content":message
|
| 15 |
+
})
|
| 16 |
+
response = " "
|
| 17 |
+
for msg in client.chat_completion(messages, max_tokens = 1000, temperature = 1, top_p = 0.5, stream = True):
|
| 18 |
+
token = msg.choices[0].delta.content
|
| 19 |
+
response += token
|
| 20 |
+
yield response
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
chatbot gr.ChatInterface(fn=respond, title = "Mind Matters", description = "_put this rn_", editable = True)
|
| 23 |
chatbot.launch()
|