Spaces:
Sleeping
Sleeping
Updating
Browse files
app.py
CHANGED
|
@@ -1,24 +1,24 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
| 3 |
-
|
| 4 |
|
| 5 |
client = InferenceClient("Qwen/Qwen2.5-7B-Instruct")
|
| 6 |
|
| 7 |
-
def
|
| 8 |
-
messages = [{"role" : "system", "content"
|
| 9 |
|
| 10 |
if history:
|
| 11 |
messages.extend(history)
|
| 12 |
-
|
| 13 |
-
messages.append({"role":"user", "content":message})
|
| 14 |
|
|
|
|
|
|
|
| 15 |
response = client.chat_completion (
|
| 16 |
messages,
|
| 17 |
-
|
| 18 |
)
|
| 19 |
|
| 20 |
return response.choices[0].message.content.strip()
|
| 21 |
|
| 22 |
-
chatbot = gr.ChatInterface(
|
| 23 |
|
| 24 |
chatbot.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
| 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", "content": "You are a friendly chatbot"}]
|
| 9 |
|
| 10 |
if history:
|
| 11 |
messages.extend(history)
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
messages.append({"role": "user", "content": message})
|
| 14 |
+
|
| 15 |
response = client.chat_completion (
|
| 16 |
messages,
|
| 17 |
+
max_tokens=100
|
| 18 |
)
|
| 19 |
|
| 20 |
return response.choices[0].message.content.strip()
|
| 21 |
|
| 22 |
+
chatbot = gr.ChatInterface(respond)
|
| 23 |
|
| 24 |
chatbot.launch()
|