Spaces:
Sleeping
Sleeping
Keira James
commited on
Commit
·
c98706e
1
Parent(s):
bcf9fc0
update to gradio
Browse files
app.py
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
|
|
|
| 4 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 5 |
|
| 6 |
-
|
| 7 |
def respond(
|
| 8 |
message,
|
| 9 |
history: list[tuple[str, str]],
|
|
@@ -32,28 +33,21 @@ def respond(
|
|
| 32 |
top_p=top_p,
|
| 33 |
):
|
| 34 |
token = message.choices[0].delta.content
|
| 35 |
-
|
| 36 |
response += token
|
| 37 |
yield response
|
| 38 |
|
| 39 |
-
|
| 40 |
demo = gr.ChatInterface(
|
| 41 |
respond,
|
| 42 |
additional_inputs=[
|
| 43 |
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
| 44 |
-
# gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 45 |
-
# gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 46 |
-
# gr.Slider(
|
| 47 |
-
# minimum=0.1,
|
| 48 |
-
# maximum=1.0,
|
| 49 |
-
# value=0.95,
|
| 50 |
-
# step=0.05,
|
| 51 |
-
# label="Top-p (nucleus sampling)",
|
| 52 |
-
# ),
|
| 53 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
)
|
| 55 |
|
| 56 |
-
|
| 57 |
if __name__ == "__main__":
|
| 58 |
demo.launch()
|
| 59 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
+
# Connect to Hugging Face model
|
| 5 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 6 |
|
| 7 |
+
# Define the chat response function
|
| 8 |
def respond(
|
| 9 |
message,
|
| 10 |
history: list[tuple[str, str]],
|
|
|
|
| 33 |
top_p=top_p,
|
| 34 |
):
|
| 35 |
token = message.choices[0].delta.content
|
|
|
|
| 36 |
response += token
|
| 37 |
yield response
|
| 38 |
|
| 39 |
+
# Gradio interface layout
|
| 40 |
demo = gr.ChatInterface(
|
| 41 |
respond,
|
| 42 |
additional_inputs=[
|
| 43 |
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
],
|
| 45 |
+
css=".gradio-container {background-color: #ffeef8;} .gr-button {background-color: #ff88cc; color: white; border-radius: 12px;} .gr-input {border: 2px solid #ff66b2; border-radius: 10px;} .gr-output {border: 2px solid #ff66b2; border-radius: 10px; padding: 10px;} .gr-button:hover {background-color: #ff66b2;} .gr-textbox {background-color: #fff1f5;}",
|
| 46 |
+
theme="huggingface", # Hugging Face's default theme
|
| 47 |
+
title="Cuddly Chatbot 🐾", # Title for the app
|
| 48 |
+
description="Welcome to the most adorable chatbot! 💖",
|
| 49 |
)
|
| 50 |
|
|
|
|
| 51 |
if __name__ == "__main__":
|
| 52 |
demo.launch()
|
| 53 |
|