Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -17,47 +17,57 @@ def chat(user_input, chat_history):
|
|
17 |
except Exception as e:
|
18 |
return f"Error: {e}", chat_history
|
19 |
|
20 |
-
# Create Gradio interface with
|
21 |
with gr.Blocks(css="""
|
22 |
body {
|
23 |
background-color: #121212;
|
24 |
color: #f1f1f1;
|
25 |
font-family: Arial, sans-serif;
|
|
|
|
|
|
|
|
|
|
|
26 |
}
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
padding:
|
32 |
-
border-radius:
|
33 |
-
background-color: #2a2a2a;
|
34 |
-
color: #f1f1f1;
|
35 |
}
|
36 |
-
.textbox, .button {
|
37 |
background-color: #333;
|
38 |
color: #f1f1f1;
|
39 |
border: 1px solid #444;
|
|
|
40 |
}
|
41 |
-
.textbox:focus, .button:focus {
|
42 |
border-color: #007bff;
|
43 |
}
|
44 |
-
.button {
|
45 |
-
padding: 10px;
|
46 |
-
border-radius: 6px;
|
47 |
-
}
|
48 |
-
.button:hover {
|
49 |
background-color: #007bff;
|
50 |
cursor: pointer;
|
51 |
}
|
52 |
-
.
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
}
|
56 |
""") as demo:
|
57 |
gr.Markdown("## 🤖 Professional Groq Chatbot")
|
58 |
gr.Markdown("Type your message below to chat with the AI!")
|
59 |
|
60 |
-
with
|
|
|
61 |
user_input = gr.Textbox(
|
62 |
label="Your Message",
|
63 |
placeholder="Ask me anything!",
|
@@ -67,13 +77,13 @@ with gr.Blocks(css="""
|
|
67 |
submit_button = gr.Button("Send")
|
68 |
clear_button = gr.Button("Clear Chat")
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
|
78 |
# State to hold chat history
|
79 |
chat_history = gr.State([])
|
|
|
17 |
except Exception as e:
|
18 |
return f"Error: {e}", chat_history
|
19 |
|
20 |
+
# Create Gradio interface with vertical alignment and background color
|
21 |
with gr.Blocks(css="""
|
22 |
body {
|
23 |
background-color: #121212;
|
24 |
color: #f1f1f1;
|
25 |
font-family: Arial, sans-serif;
|
26 |
+
display: flex;
|
27 |
+
justify-content: center;
|
28 |
+
align-items: center;
|
29 |
+
height: 100vh;
|
30 |
+
margin: 0;
|
31 |
}
|
32 |
+
.gradio-container {
|
33 |
+
width: 100%;
|
34 |
+
max-width: 600px;
|
35 |
+
background-color: #1e1e1e;
|
36 |
+
padding: 20px;
|
37 |
+
border-radius: 10px;
|
|
|
|
|
38 |
}
|
39 |
+
.gradio-container .textbox, .gradio-container .button {
|
40 |
background-color: #333;
|
41 |
color: #f1f1f1;
|
42 |
border: 1px solid #444;
|
43 |
+
border-radius: 8px;
|
44 |
}
|
45 |
+
.gradio-container .textbox:focus, .gradio-container .button:focus {
|
46 |
border-color: #007bff;
|
47 |
}
|
48 |
+
.gradio-container .button:hover {
|
|
|
|
|
|
|
|
|
49 |
background-color: #007bff;
|
50 |
cursor: pointer;
|
51 |
}
|
52 |
+
.textbox {
|
53 |
+
margin-bottom: 15px;
|
54 |
+
}
|
55 |
+
#chatbox {
|
56 |
+
height: 400px;
|
57 |
+
overflow-y: auto;
|
58 |
+
border: 2px solid #444;
|
59 |
+
padding: 15px;
|
60 |
+
border-radius: 8px;
|
61 |
+
background-color: #2a2a2a;
|
62 |
+
color: #f1f1f1;
|
63 |
+
margin-bottom: 20px;
|
64 |
}
|
65 |
""") as demo:
|
66 |
gr.Markdown("## 🤖 Professional Groq Chatbot")
|
67 |
gr.Markdown("Type your message below to chat with the AI!")
|
68 |
|
69 |
+
# Define layout with vertical alignment
|
70 |
+
with gr.Column():
|
71 |
user_input = gr.Textbox(
|
72 |
label="Your Message",
|
73 |
placeholder="Ask me anything!",
|
|
|
77 |
submit_button = gr.Button("Send")
|
78 |
clear_button = gr.Button("Clear Chat")
|
79 |
|
80 |
+
chatbot_output = gr.Textbox(
|
81 |
+
label="Chat History",
|
82 |
+
placeholder="AI's responses will appear here.",
|
83 |
+
lines=15,
|
84 |
+
interactive=False,
|
85 |
+
elem_id="chatbox",
|
86 |
+
)
|
87 |
|
88 |
# State to hold chat history
|
89 |
chat_history = gr.State([])
|