Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,124 +1,27 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
messages,
|
| 29 |
-
max_tokens=max_tokens,
|
| 30 |
-
stream=True,
|
| 31 |
-
temperature=temperature,
|
| 32 |
-
top_p=top_p,
|
| 33 |
-
):
|
| 34 |
-
token = message.choices[0].delta.content
|
| 35 |
-
|
| 36 |
-
response += token
|
| 37 |
-
yield response
|
| 38 |
-
|
| 39 |
-
# Define the interface with styling and customization
|
| 40 |
-
demo = gr.ChatInterface(
|
| 41 |
-
respond,
|
| 42 |
-
additional_inputs=[
|
| 43 |
-
gr.Textbox(value="You are a friendly Chatbot.", label="System message", lines=1),
|
| 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(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
|
| 47 |
-
],
|
| 48 |
-
css="""
|
| 49 |
-
/* Custom CSS to style the interface with pink and cute aesthetic */
|
| 50 |
-
.gradio-container {
|
| 51 |
-
background-color: #f9e5e5; /* Soft pastel pink */
|
| 52 |
-
color: #ff8fa3; /* Pink text */
|
| 53 |
-
font-family: 'Comic Sans MS', sans-serif; /* Fun, playful font */
|
| 54 |
-
border-radius: 20px;
|
| 55 |
-
padding: 30px;
|
| 56 |
-
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
.gradio-button {
|
| 60 |
-
background-color: #ff7fa5; /* Lighter pink buttons */
|
| 61 |
-
color: white;
|
| 62 |
-
border-radius: 12px;
|
| 63 |
-
font-size: 18px;
|
| 64 |
-
padding: 16px 32px;
|
| 65 |
-
font-weight: bold;
|
| 66 |
-
transition: background-color 0.3s ease;
|
| 67 |
-
}
|
| 68 |
-
|
| 69 |
-
.gradio-button:hover {
|
| 70 |
-
background-color: #ff5885; /* Even lighter pink on hover */
|
| 71 |
-
}
|
| 72 |
-
|
| 73 |
-
.gradio-textbox {
|
| 74 |
-
background-color: #ffd3d3; /* Soft pink background for textboxes */
|
| 75 |
-
border-radius: 12px;
|
| 76 |
-
color: #ff4d6d; /* Bold pink text */
|
| 77 |
-
padding: 16px;
|
| 78 |
-
border: 2px solid #ff8fa3;
|
| 79 |
-
}
|
| 80 |
-
|
| 81 |
-
.gradio-chat {
|
| 82 |
-
background-color: #fff0f5; /* Very light pink for chat */
|
| 83 |
-
border-radius: 20px;
|
| 84 |
-
padding: 20px;
|
| 85 |
-
}
|
| 86 |
-
|
| 87 |
-
.gradio-chat .gradio-message-user {
|
| 88 |
-
background-color: #ff7fa5; /* Light pink background for user messages */
|
| 89 |
-
border-radius: 12px;
|
| 90 |
-
color: white;
|
| 91 |
-
padding: 12px;
|
| 92 |
-
}
|
| 93 |
-
|
| 94 |
-
.gradio-chat .gradio-message-assistant {
|
| 95 |
-
background-color: #ffd3d3; /* Soft pink for assistant's messages */
|
| 96 |
-
border-radius: 12px;
|
| 97 |
-
color: #ff4d6d;
|
| 98 |
-
padding: 12px;
|
| 99 |
-
}
|
| 100 |
-
|
| 101 |
-
.gradio-container h1 {
|
| 102 |
-
color: #ff4d6d; /* Pink header */
|
| 103 |
-
font-size: 40px;
|
| 104 |
-
text-align: center;
|
| 105 |
-
font-weight: bold;
|
| 106 |
-
margin-bottom: 30px;
|
| 107 |
-
}
|
| 108 |
-
|
| 109 |
-
.gradio-container p {
|
| 110 |
-
color: #ff8fa3; /* Soft pink text for descriptions */
|
| 111 |
-
text-align: center;
|
| 112 |
-
font-size: 16px;
|
| 113 |
-
margin-top: 10px;
|
| 114 |
-
}
|
| 115 |
-
|
| 116 |
-
.gradio-container .gradio-textbox input {
|
| 117 |
-
font-size: 18px;
|
| 118 |
-
}
|
| 119 |
-
"""
|
| 120 |
-
)
|
| 121 |
-
|
| 122 |
-
if __name__ == "__main__":
|
| 123 |
-
demo.launch()
|
| 124 |
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
+
# Function to greet the user
|
| 4 |
+
def greet(name):
|
| 5 |
+
return f"Hello, {name}!"
|
| 6 |
+
|
| 7 |
+
# Make the app pretty using some styles
|
| 8 |
+
css = """
|
| 9 |
+
.gradio-container {
|
| 10 |
+
background-color: #ffccff; /* Pink background */
|
| 11 |
+
font-family: "Comic Sans MS"; /* Fun font */
|
| 12 |
+
}
|
| 13 |
+
.gradio-button {
|
| 14 |
+
background-color: #ff66b2; /* Pink button */
|
| 15 |
+
color: white; /* White text */
|
| 16 |
+
}
|
| 17 |
+
.gradio-input {
|
| 18 |
+
background-color: #ffccff; /* Pink input box */
|
| 19 |
+
}
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
# Creating a Gradio interface
|
| 23 |
+
demo = gr.Interface(fn=greet, inputs="text", outputs="text", title="Cute Greeting App", description="This app greets the user with a fun message!", css=css)
|
| 24 |
+
|
| 25 |
+
# Launch the app
|
| 26 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|