Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,3 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from huggingface_hub import InferenceClient
|
| 3 |
-
|
| 4 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 5 |
|
| 6 |
def respond(
|
|
@@ -35,51 +32,68 @@ def respond(
|
|
| 35 |
response += token
|
| 36 |
yield response
|
| 37 |
|
| 38 |
-
#
|
| 39 |
-
js_autofocus_fix = """
|
| 40 |
-
<script>
|
| 41 |
-
window.onload = function() {
|
| 42 |
-
setTimeout(function() {
|
| 43 |
-
let inputField = document.querySelector("textarea");
|
| 44 |
-
if (inputField) {
|
| 45 |
-
inputField.blur(); // Removes focus from the input field
|
| 46 |
-
}
|
| 47 |
-
}, 100);
|
| 48 |
-
};
|
| 49 |
-
</script>
|
| 50 |
-
"""
|
| 51 |
-
|
| 52 |
-
# ✅ Custom CSS (without JavaScript)
|
| 53 |
custom_css = """
|
|
|
|
| 54 |
body {
|
| 55 |
font-family: Arial, sans-serif;
|
| 56 |
background-color: white;
|
| 57 |
}
|
| 58 |
.gradio-container {
|
|
|
|
| 59 |
border-radius: 10px;
|
| 60 |
padding: 20px;
|
| 61 |
background-color: #ffffff;
|
| 62 |
-
box-shadow:
|
| 63 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
"""
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
| 83 |
|
| 84 |
if __name__ == "__main__":
|
| 85 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 2 |
|
| 3 |
def respond(
|
|
|
|
| 32 |
response += token
|
| 33 |
yield response
|
| 34 |
|
| 35 |
+
# Define custom CSS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
custom_css = """
|
| 37 |
+
/* Add your custom CSS styles here */
|
| 38 |
body {
|
| 39 |
font-family: Arial, sans-serif;
|
| 40 |
background-color: white;
|
| 41 |
}
|
| 42 |
.gradio-container {
|
| 43 |
+
border: linear-gradient(90deg, rgba(0,0,0,1) 1%, rgba(15,6,83,1) 53%, rgba(22,9,121,1) 100%, rgba(0,212,255,1) 100%);
|
| 44 |
border-radius: 10px;
|
| 45 |
padding: 20px;
|
| 46 |
background-color: #ffffff;
|
| 47 |
+
box-shadow:0 0 12px 12px solid black;
|
| 48 |
}
|
| 49 |
+
.gradio-input {
|
| 50 |
+
border-radius: 5px;
|
| 51 |
+
border: 1px solid #ddd;
|
| 52 |
+
padding: 10px;
|
| 53 |
+
}
|
| 54 |
+
.gradio-button {
|
| 55 |
+
background-color: #4CAF50;
|
| 56 |
+
color: white;
|
| 57 |
+
border: none;
|
| 58 |
+
border-radius: 5px;
|
| 59 |
+
padding: 10px 20px;
|
| 60 |
+
}
|
| 61 |
+
.gradio-output {
|
| 62 |
+
border: 1px solid #ddd;
|
| 63 |
+
padding: 10px;
|
| 64 |
+
border-radius: 5px;
|
| 65 |
+
box-shadow:0 0 12px 12px solid grey;
|
| 66 |
+
}
|
| 67 |
+
<script>
|
| 68 |
+
window.onload = function() {
|
| 69 |
+
setTimeout(function() {
|
| 70 |
+
let inputField = document.querySelector("textarea");
|
| 71 |
+
if (inputField) {
|
| 72 |
+
inputField.blur(); // Removes focus from the input field
|
| 73 |
+
}
|
| 74 |
+
}, 100);
|
| 75 |
+
};
|
| 76 |
+
</script>
|
| 77 |
"""
|
| 78 |
|
| 79 |
+
# Create a Gradio chat interface with custom CSS
|
| 80 |
+
demo = gr.ChatInterface(
|
| 81 |
+
fn=respond,
|
| 82 |
+
additional_inputs=[
|
| 83 |
+
gr.Textbox(value="You are a Chatbot.Your name is Evy.Your are Developed By Joe.", label="System message"),
|
| 84 |
+
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
| 85 |
+
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
| 86 |
+
gr.Slider(
|
| 87 |
+
minimum=0.1,
|
| 88 |
+
maximum=1.0,
|
| 89 |
+
value=0.95,
|
| 90 |
+
step=0.05,
|
| 91 |
+
label="Top-p (nucleus sampling)",
|
| 92 |
+
),
|
| 93 |
+
],
|
| 94 |
+
|
| 95 |
+
css=custom_css
|
| 96 |
+
)
|
| 97 |
|
| 98 |
if __name__ == "__main__":
|
| 99 |
+
demo.launch()
|