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