Spaces:
Runtime error
Runtime error
Update app.py
#1
by ckdeleon - opened
app.py
CHANGED
|
@@ -1,9 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
chatbot = gr.ChatInterface(random_response, title = "Random Yes or No Chatbot")
|
| 9 |
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 |
+
messeges = [{"role": "system", "content": "You are a friendly chatbot."}]
|
| 9 |
+
|
| 10 |
+
if history:
|
| 11 |
+
messeges.extend(history)
|
| 12 |
+
messeges.append({"role":"user", "content": message})
|
| 13 |
+
|
| 14 |
+
response = client.chat_completion (
|
| 15 |
+
messages,
|
| 16 |
+
max_tokens = 100
|
| 17 |
+
)
|
| 18 |
+
return response.choices[0].message.content.strip()
|
| 19 |
|
| 20 |
chatbot = gr.ChatInterface(random_response, title = "Random Yes or No Chatbot")
|
| 21 |
chatbot.launch()
|