Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from huggingface_hub import InferenceClient
|
| 2 |
+
|
| 3 |
+
import gradio as gr
|
| 4 |
+
import random
|
| 5 |
+
|
| 6 |
+
client=InferenceClient("Qwen/Qwen2.5-72B-Instruct")
|
| 7 |
+
#deepseek-ai/DeepSeek-R1-Distill-Qwen-32B
|
| 8 |
+
|
| 9 |
+
def respond(message, history):
|
| 10 |
+
#responses = ["Yes", "No"]
|
| 11 |
+
#return random.choice(responses)
|
| 12 |
+
|
| 13 |
+
messages = [
|
| 14 |
+
{"role":"system",
|
| 15 |
+
"content": "You are a chatbot that is very sweet and kind"
|
| 16 |
+
}
|
| 17 |
+
]
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
if history:
|
| 21 |
+
messages.extend(history)
|
| 22 |
+
|
| 23 |
+
messages.append(
|
| 24 |
+
{"role":"user",
|
| 25 |
+
"content": "message"}
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
response = client.chat_completion(messages, max_tokens=100, temperature=1.3, top_p=.2)
|
| 29 |
+
#temperature and top_p control randomness
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
return response['choices'][0]['message']['content'].strip()
|
| 33 |
+
|
| 34 |
+
chatbot = gr.ChatInterface(respond, type="messages")
|
| 35 |
+
chatbot.launch()
|