Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,7 +15,7 @@ servers = [
|
|
| 15 |
def call_api(message, model, preset):
|
| 16 |
selected_server = random.choice(servers) # Randomly select a server
|
| 17 |
client = Client(selected_server) # Create a client for the selected server
|
| 18 |
-
|
| 19 |
try:
|
| 20 |
# Call the /chat endpoint with the provided parameters
|
| 21 |
result = client.predict(
|
|
@@ -31,47 +31,60 @@ def call_api(message, model, preset):
|
|
| 31 |
# Custom CSS for styling
|
| 32 |
css = """
|
| 33 |
.gradio-container {
|
| 34 |
-
background-color: #
|
| 35 |
-
font-family: '
|
| 36 |
-
padding:
|
| 37 |
-
border-radius:
|
| 38 |
-
box-shadow: 0 4px
|
|
|
|
| 39 |
}
|
| 40 |
|
| 41 |
h2 {
|
| 42 |
-
color: #
|
| 43 |
text-align: center;
|
|
|
|
| 44 |
}
|
| 45 |
|
| 46 |
.input-container {
|
| 47 |
display: flex;
|
| 48 |
align-items: center;
|
|
|
|
|
|
|
| 49 |
}
|
| 50 |
|
| 51 |
.gr-button {
|
| 52 |
-
background-color: #
|
| 53 |
color: white;
|
|
|
|
| 54 |
border: none;
|
| 55 |
-
border-radius:
|
| 56 |
-
|
|
|
|
| 57 |
}
|
| 58 |
|
| 59 |
.gr-button:hover {
|
| 60 |
-
background-color: #
|
|
|
|
| 61 |
}
|
| 62 |
|
| 63 |
.response-box {
|
| 64 |
-
background-color:
|
| 65 |
-
border
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
|
|
|
| 70 |
overflow-y: auto; /* Scroll if content exceeds height */
|
| 71 |
}
|
| 72 |
|
| 73 |
.settings-container {
|
| 74 |
-
margin-top:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
}
|
| 76 |
"""
|
| 77 |
|
|
@@ -81,16 +94,35 @@ def create_interface():
|
|
| 81 |
gr.Markdown("## Chat with Random Server")
|
| 82 |
|
| 83 |
# Input container for message and send button
|
| 84 |
-
with gr.Row():
|
| 85 |
-
message = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
submit_btn = gr.Button("Send", elem_id="send-button")
|
| 87 |
|
| 88 |
-
output = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
-
# Settings
|
| 91 |
-
with gr.Accordion("Settings", open=False, elem_id="settings-container"):
|
| 92 |
-
model = gr.Dropdown(
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
# Button click event with loading indicator
|
| 96 |
submit_btn.click(call_api, inputs=[message, model, preset], outputs=output)
|
|
|
|
| 15 |
def call_api(message, model, preset):
|
| 16 |
selected_server = random.choice(servers) # Randomly select a server
|
| 17 |
client = Client(selected_server) # Create a client for the selected server
|
| 18 |
+
|
| 19 |
try:
|
| 20 |
# Call the /chat endpoint with the provided parameters
|
| 21 |
result = client.predict(
|
|
|
|
| 31 |
# Custom CSS for styling
|
| 32 |
css = """
|
| 33 |
.gradio-container {
|
| 34 |
+
background-color: #121212;
|
| 35 |
+
font-family: 'Inter', sans-serif;
|
| 36 |
+
padding: 25px;
|
| 37 |
+
border-radius: 12px;
|
| 38 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
|
| 39 |
+
color: #FFFFFF;
|
| 40 |
}
|
| 41 |
|
| 42 |
h2 {
|
| 43 |
+
color: #E0E0E0;
|
| 44 |
text-align: center;
|
| 45 |
+
margin-bottom: 15px;
|
| 46 |
}
|
| 47 |
|
| 48 |
.input-container {
|
| 49 |
display: flex;
|
| 50 |
align-items: center;
|
| 51 |
+
justify-content: space-between;
|
| 52 |
+
gap: 10px;
|
| 53 |
}
|
| 54 |
|
| 55 |
.gr-button {
|
| 56 |
+
background-color: #1E88E5;
|
| 57 |
color: white;
|
| 58 |
+
font-weight: bold;
|
| 59 |
border: none;
|
| 60 |
+
border-radius: 8px;
|
| 61 |
+
padding: 8px 16px;
|
| 62 |
+
transition: background-color 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
|
| 63 |
}
|
| 64 |
|
| 65 |
.gr-button:hover {
|
| 66 |
+
background-color: #1565C0;
|
| 67 |
+
box-shadow: 0 4px 8px rgba(21, 101, 192, 0.3);
|
| 68 |
}
|
| 69 |
|
| 70 |
.response-box {
|
| 71 |
+
background-color: #1E1E1E;
|
| 72 |
+
border: 1px solid #333;
|
| 73 |
+
border-radius: 8px;
|
| 74 |
+
padding: 15px;
|
| 75 |
+
margin-top: 15px;
|
| 76 |
+
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
|
| 77 |
+
height: 250px; /* Fixed height for response area */
|
| 78 |
overflow-y: auto; /* Scroll if content exceeds height */
|
| 79 |
}
|
| 80 |
|
| 81 |
.settings-container {
|
| 82 |
+
margin-top: 25px;
|
| 83 |
+
background-color: #1E1E1E;
|
| 84 |
+
border: 1px solid #333;
|
| 85 |
+
border-radius: 8px;
|
| 86 |
+
padding: 15px;
|
| 87 |
+
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
|
| 88 |
}
|
| 89 |
"""
|
| 90 |
|
|
|
|
| 94 |
gr.Markdown("## Chat with Random Server")
|
| 95 |
|
| 96 |
# Input container for message and send button
|
| 97 |
+
with gr.Row(elem_id="input-container"):
|
| 98 |
+
message = gr.Textbox(
|
| 99 |
+
label="Message",
|
| 100 |
+
placeholder="Type your message here...",
|
| 101 |
+
elem_id="message-input",
|
| 102 |
+
lines=1
|
| 103 |
+
)
|
| 104 |
submit_btn = gr.Button("Send", elem_id="send-button")
|
| 105 |
|
| 106 |
+
output = gr.Textbox(
|
| 107 |
+
label="Response",
|
| 108 |
+
interactive=False,
|
| 109 |
+
elem_id="response-box",
|
| 110 |
+
lines=10,
|
| 111 |
+
show_label=False
|
| 112 |
+
)
|
| 113 |
|
| 114 |
+
# Settings section
|
| 115 |
+
with gr.Accordion("⚙️ Settings", open=False, elem_id="settings-container"):
|
| 116 |
+
model = gr.Dropdown(
|
| 117 |
+
choices=["Lake 1 Base"],
|
| 118 |
+
label="Select Model",
|
| 119 |
+
value="Lake 1 Base"
|
| 120 |
+
)
|
| 121 |
+
preset = gr.Dropdown(
|
| 122 |
+
choices=["Fast", "Normal", "Quality", "Unreal Performance"],
|
| 123 |
+
label="Select Preset",
|
| 124 |
+
value="Fast"
|
| 125 |
+
)
|
| 126 |
|
| 127 |
# Button click event with loading indicator
|
| 128 |
submit_btn.click(call_api, inputs=[message, model, preset], outputs=output)
|