Spaces:
Sleeping
Sleeping
idk
Browse files
app.py
CHANGED
|
@@ -1,9 +1,20 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
chatbot = gr.ChatInterface(random_response)
|
| 9 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
| 3 |
+
from huggingface_hub import inferenceClient
|
| 4 |
|
| 5 |
+
client = inferenceClient('Qwen/Qwen2.5-7B-Instruct')
|
| 6 |
+
def respond(message, history):
|
| 7 |
+
messages = [{'role': 'system', 'content': 'You are a friendly chatbot'}]
|
| 8 |
+
|
| 9 |
+
if history:
|
| 10 |
+
messages.extend(history)
|
| 11 |
+
messages.append({'role':'user', 'content': message})
|
| 12 |
+
|
| 13 |
+
response = client.chat_completion (
|
| 14 |
+
messages,
|
| 15 |
+
max_tokens = 100
|
| 16 |
+
)
|
| 17 |
+
return random.choice[0].message.content.strip()
|
| 18 |
|
| 19 |
chatbot = gr.ChatInterface(random_response)
|
| 20 |
|