BICORP commited on
Commit
6a98d1a
·
verified ·
1 Parent(s): aab9ed4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -62
app.py CHANGED
@@ -27,80 +27,27 @@ def call_api(message, model, preset):
27
  except Exception as e:
28
  return f"Error: {str(e)}"
29
 
30
- # Dark mode CSS
31
- dark_css = """
32
- .gradio-container {
33
- background-color: #1e1e1e; /* Dark background */
34
- color: white; /* Light text color */
35
- }
36
- #chatbox {
37
- background-color: #2e2e2e; /* Dark chatbox */
38
- color: white; /* Light text color */
39
- }
40
- #input-container {
41
- display: flex;
42
- align-items: center;
43
- background-color: #2e2e2e; /* Dark input container */
44
- border: 1px solid #444; /* Dark border */
45
- border-radius: 20px; /* Rounded corners */
46
- padding: 5px;
47
- }
48
- #message-input {
49
- flex: 1;
50
- background-color: #3e3e3e; /* Dark input field */
51
- color: white; /* Light text color */
52
- border: none;
53
- border-radius: 20px; /* Rounded corners for input */
54
- padding: 10px 15px;
55
- font-size: 14px;
56
- }
57
- #message-input:focus {
58
- outline: none;
59
- }
60
- #send-button {
61
- background-color: #007BFF; /* Button background color */
62
- color: white; /* Button text color */
63
- border: none; /* No border */
64
- border-radius: 20px; /* Rounded corners */
65
- padding: 10px 20px; /* Padding for the button */
66
- font-size: 14px; /* Font size for the button text */
67
- margin-left: 10px; /* Space between input and button */
68
- cursor: pointer; /* Pointer cursor */
69
- transition: background-color 0.3s ease; /* Smooth hover transition */
70
- }
71
- #send-button:hover {
72
- background-color: #0056b3; /* Darker hover color */
73
- }
74
- """
75
-
76
- # Function to toggle dark mode
77
- def toggle_dark_mode(is_dark):
78
- return dark_css if is_dark else ""
79
-
80
  # Create Gradio interface
81
  def create_interface():
82
- with gr.Blocks(css=dark_css) as demo:
83
  gr.Markdown("## 💬 Chatbot")
84
 
85
  # Chat display area
86
- chatbox = gr.Textbox(label="", interactive=False, elem_id="chatbox", lines=12)
87
 
88
- # Custom input field with button
89
- with gr.Row(elem_id="input-container"):
90
- message = gr.Textbox(placeholder="Type a message...", elem_id="message-input", lines=1, show_label=False)
91
- send_btn = gr.Button("Send", elem_id="send-button")
 
92
 
93
  # Settings section
94
  with gr.Accordion("⚙️ Settings", open=False):
95
  model = gr.Dropdown(choices=["Lake 1 Base"], label="Model", value="Lake 1 Base")
96
  preset = gr.Dropdown(choices=["Fast", "Normal", "Quality", "Unreal Performance"], label="Preset", value="Fast")
97
- dark_mode = gr.Checkbox(label="Enable Dark Mode", value=False)
98
-
99
- # Button click event
100
- send_btn.click(call_api, inputs=[message, model, preset], outputs=chatbox)
101
 
102
- # Change CSS based on dark mode toggle
103
- dark_mode.change(lambda x: demo.css.update(toggle_dark_mode(x)), inputs=[dark_mode])
104
 
105
  return demo
106
 
 
27
  except Exception as e:
28
  return f"Error: {str(e)}"
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  # Create Gradio interface
31
  def create_interface():
32
+ with gr.Blocks() as demo:
33
  gr.Markdown("## 💬 Chatbot")
34
 
35
  # Chat display area
36
+ chatbox = gr.Textbox(label="", interactive=False, lines=12)
37
 
38
+ # Input box for user messages
39
+ user_input = gr.Textbox(label="Type your message here...", placeholder="Enter your message...", lines=1)
40
+
41
+ # Send button
42
+ send_button = gr.Button("Send")
43
 
44
  # Settings section
45
  with gr.Accordion("⚙️ Settings", open=False):
46
  model = gr.Dropdown(choices=["Lake 1 Base"], label="Model", value="Lake 1 Base")
47
  preset = gr.Dropdown(choices=["Fast", "Normal", "Quality", "Unreal Performance"], label="Preset", value="Fast")
 
 
 
 
48
 
49
+ # Define the action for the send button
50
+ send_button.click(fn=call_api, inputs=[user_input, model, preset], outputs=chatbox)
51
 
52
  return demo
53