Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,32 @@
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
def respond(message, history):
|
| 4 |
-
responses = ["Yes", "No"]
|
| 5 |
-
return random.choice(responses)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
chatbot = gr.ChatInterface(respond, type="messages")
|
| 7 |
chatbot.launch()
|
|
|
|
| 1 |
+
from huggingface_hub import InferenceClient
|
| 2 |
+
|
| 3 |
import gradio as gr
|
| 4 |
import random
|
| 5 |
+
|
| 6 |
+
client=InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 7 |
+
|
| 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 friendly chatbot! :)"
|
| 16 |
+
}
|
| 17 |
+
]
|
| 18 |
+
|
| 19 |
+
if history:
|
| 20 |
+
messages.extend(history)
|
| 21 |
+
|
| 22 |
+
response = client.chat_completion(
|
| 23 |
+
messages, max_tokens=100
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
return response['choices'][0]['message']['content'].strip()
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|
| 31 |
chatbot = gr.ChatInterface(respond, type="messages")
|
| 32 |
chatbot.launch()
|