Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,20 +6,20 @@ from huggingface_hub import InferenceClient
|
|
| 6 |
client = InferenceClient('Qwen2.5-7B-Instruct-1M')
|
| 7 |
def respond(message, history):
|
| 8 |
|
| 9 |
-
messages = [{
|
| 10 |
|
| 11 |
if history:
|
| 12 |
messages.extend(history)
|
| 13 |
|
| 14 |
-
messages.append({
|
| 15 |
|
| 16 |
response = client.chat_completion(messages, max_tokens = 100)
|
| 17 |
|
| 18 |
-
return response[
|
| 19 |
def echo(message, history):
|
| 20 |
return message
|
| 21 |
def yes_no(message, history):
|
| 22 |
-
responses = [
|
| 23 |
return random.choice(responses)
|
| 24 |
chatbot = gr.ChatInterface(respond, type=βmessagesβ)
|
| 25 |
chatbot.launch()
|
|
|
|
| 6 |
client = InferenceClient('Qwen2.5-7B-Instruct-1M')
|
| 7 |
def respond(message, history):
|
| 8 |
|
| 9 |
+
messages = [{'role': 'system', 'content': 'You are a friendly chatbot.'}]
|
| 10 |
|
| 11 |
if history:
|
| 12 |
messages.extend(history)
|
| 13 |
|
| 14 |
+
messages.append({"role": "user", "content": message})
|
| 15 |
|
| 16 |
response = client.chat_completion(messages, max_tokens = 100)
|
| 17 |
|
| 18 |
+
return response["choices"][0]["message"]["content"].strip()
|
| 19 |
def echo(message, history):
|
| 20 |
return message
|
| 21 |
def yes_no(message, history):
|
| 22 |
+
responses = ["Yes", "No"]
|
| 23 |
return random.choice(responses)
|
| 24 |
chatbot = gr.ChatInterface(respond, type=βmessagesβ)
|
| 25 |
chatbot.launch()
|