Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,64 @@ import gradio as gr
|
|
| 2 |
import random
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
client = InferenceClient(HuggingFaceH4/zephyr-7b-beta)
|
| 6 |
|
| 7 |
def respond(message, history):
|
|
@@ -37,3 +95,4 @@ chatbot = gr.ChatInterface(respond, type="messages")
|
|
| 37 |
|
| 38 |
chatbot.launch()
|
| 39 |
|
|
|
|
|
|
| 2 |
import random
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def respond(message, history):
|
| 12 |
+
|
| 13 |
+
messages = [{"role": "system", "content": "You are a friendly chatbot."}]
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
if history:
|
| 18 |
+
|
| 19 |
+
messages.extend(history)
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
messages.append({"role": "user", "content": message})
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
response = client.chat_completion(messages, max_tokens = 100)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
return response['choices'][0]['message']['content'].strip()
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
chatbot = gr.ChatInterface(respond, type="messages")
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
chatbot.launch()
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
'''
|
| 59 |
+
import gradio as gr
|
| 60 |
+
import random
|
| 61 |
+
from huggingface_hub import InferenceClient
|
| 62 |
+
|
| 63 |
client = InferenceClient(HuggingFaceH4/zephyr-7b-beta)
|
| 64 |
|
| 65 |
def respond(message, history):
|
|
|
|
| 95 |
|
| 96 |
chatbot.launch()
|
| 97 |
|
| 98 |
+
'''
|