BICORP commited on
Commit
a710c69
·
verified ·
1 Parent(s): 1df1cdd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -14
app.py CHANGED
@@ -2,7 +2,7 @@ import random
2
  from gradio_client import Client
3
  import gradio as gr
4
 
5
- # **List of available servers**
6
  servers = [
7
  "BICORP/GOGOGOGO",
8
  "BICORP/server-2",
@@ -11,7 +11,7 @@ servers = [
11
  "BICORP/server-5"
12
  ]
13
 
14
- # **Function to call the API with correct parameters**
15
  def call_api(message, model, preset):
16
  selected_server = random.choice(servers)
17
  client = Client(selected_server)
@@ -27,7 +27,7 @@ def call_api(message, model, preset):
27
  except Exception as e:
28
  return f"Error: {str(e)}"
29
 
30
- # **Custom CSS for clean UI**
31
  css = """
32
  .gradio-container {
33
  background-color: #f9f9f9;
@@ -65,14 +65,16 @@ css = """
65
  border: none;
66
  background: none;
67
  cursor: pointer;
68
- padding: 5px; /* Reduced padding for a smaller button */
69
- font-size: 12px; /* Smaller font size */
70
- width: 30px; /* Set a specific width */
71
- height: 30px; /* Set a specific height */
 
 
72
  }
73
 
74
  #send-button:hover {
75
- opacity: 0.7;
76
  }
77
 
78
  #settings-container {
@@ -80,31 +82,31 @@ css = """
80
  }
81
  """
82
 
83
- # **Create Gradio interface**
84
  def create_interface():
85
  with gr.Blocks(css=css) as demo:
86
  gr.Markdown("## 💬 Chatbot")
87
 
88
- # **Chat display area**
89
  chatbox = gr.Textbox(label="", interactive=False, elem_id="chatbox", lines=12)
90
 
91
- # **Input field with button inside**
92
  with gr.Row(elem_id="input-container"):
93
  message = gr.Textbox(placeholder="Type a message...", elem_id="message-input", lines=1, show_label=False)
94
  send_btn = gr.Button("➤", elem_id="send-button")
95
 
96
- # **Settings section**
97
  with gr.Accordion("⚙️ Settings", open=False, elem_id="settings-container"):
98
  model = gr.Dropdown(choices=["Lake 1 Base"], label="Model", value="Lake 1 Base")
99
  preset = gr.Dropdown(choices=["Fast", "Normal", "Quality", "Unreal Performance"], label="Preset", value="Fast")
100
  dark_mode = gr.Checkbox(label="Enable Dark Mode", value=False)
101
 
102
- # **Button click event**
103
  send_btn.click(call_api, inputs=[message, model, preset], outputs=chatbox)
104
 
105
  return demo
106
 
107
- # **Launch the interface**
108
  if __name__ == "__main__":
109
  interface = create_interface()
110
  interface.launch()
 
2
  from gradio_client import Client
3
  import gradio as gr
4
 
5
+ # List of available servers
6
  servers = [
7
  "BICORP/GOGOGOGO",
8
  "BICORP/server-2",
 
11
  "BICORP/server-5"
12
  ]
13
 
14
+ # Function to call the API with correct parameters
15
  def call_api(message, model, preset):
16
  selected_server = random.choice(servers)
17
  client = Client(selected_server)
 
27
  except Exception as e:
28
  return f"Error: {str(e)}"
29
 
30
+ # Custom CSS for clean UI
31
  css = """
32
  .gradio-container {
33
  background-color: #f9f9f9;
 
65
  border: none;
66
  background: none;
67
  cursor: pointer;
68
+ padding: 5px; /* Reduced padding for a smaller button */
69
+ font-size: 12px; /* Smaller font size */
70
+ width: 30px; /* Set a specific width */
71
+ height: 30px; /* Set a specific height */
72
+ color: #007BFF; /* Text color */
73
+ transition: opacity 0.3s; /* Smooth transition for hover effect */
74
  }
75
 
76
  #send-button:hover {
77
+ opacity: 0.7; /* Change opacity on hover */
78
  }
79
 
80
  #settings-container {
 
82
  }
83
  """
84
 
85
+ # Create Gradio interface
86
  def create_interface():
87
  with gr.Blocks(css=css) as demo:
88
  gr.Markdown("## 💬 Chatbot")
89
 
90
+ # Chat display area
91
  chatbox = gr.Textbox(label="", interactive=False, elem_id="chatbox", lines=12)
92
 
93
+ # Input field with button inside
94
  with gr.Row(elem_id="input-container"):
95
  message = gr.Textbox(placeholder="Type a message...", elem_id="message-input", lines=1, show_label=False)
96
  send_btn = gr.Button("➤", elem_id="send-button")
97
 
98
+ # Settings section
99
  with gr.Accordion("⚙️ Settings", open=False, elem_id="settings-container"):
100
  model = gr.Dropdown(choices=["Lake 1 Base"], label="Model", value="Lake 1 Base")
101
  preset = gr.Dropdown(choices=["Fast", "Normal", "Quality", "Unreal Performance"], label="Preset", value="Fast")
102
  dark_mode = gr.Checkbox(label="Enable Dark Mode", value=False)
103
 
104
+ # Button click event
105
  send_btn.click(call_api, inputs=[message, model, preset], outputs=chatbox)
106
 
107
  return demo
108
 
109
+ # Launch the interface
110
  if __name__ == "__main__":
111
  interface = create_interface()
112
  interface.launch()