Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ def chat(user_input, chat_history):
|
|
9 |
# Update chat history
|
10 |
chat_history.append(("User", user_input))
|
11 |
chat_history.append(("AI", response))
|
12 |
-
# Format chat history for display
|
13 |
formatted_history = "\n".join(
|
14 |
[f"{role}: {message}" for role, message in chat_history]
|
15 |
)
|
@@ -17,11 +17,11 @@ 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: #
|
24 |
-
color: #
|
25 |
font-family: 'Roboto', sans-serif;
|
26 |
display: flex;
|
27 |
justify-content: center;
|
@@ -31,51 +31,59 @@ with gr.Blocks(css="""
|
|
31 |
}
|
32 |
.gradio-container {
|
33 |
width: 100%;
|
34 |
-
max-width:
|
35 |
-
background-color: #
|
36 |
-
padding:
|
37 |
-
border-radius:
|
38 |
-
box-shadow: 0px
|
39 |
}
|
40 |
.gradio-container .textbox, .gradio-container .button {
|
41 |
-
background-color: #
|
42 |
-
color: #
|
43 |
-
border: 1px solid #
|
44 |
-
border-radius:
|
|
|
45 |
font-size: 16px;
|
46 |
}
|
47 |
.gradio-container .textbox:focus, .gradio-container .button:focus {
|
48 |
border-color: #007bff;
|
|
|
49 |
}
|
50 |
.gradio-container .button:hover {
|
51 |
background-color: #007bff;
|
|
|
52 |
cursor: pointer;
|
53 |
}
|
54 |
.textbox {
|
55 |
-
margin-bottom:
|
56 |
}
|
57 |
#chatbox {
|
58 |
-
height:
|
59 |
overflow-y: auto;
|
60 |
-
border:
|
61 |
-
padding:
|
62 |
-
border-radius:
|
63 |
-
background-color: #
|
64 |
-
color: #
|
65 |
margin-bottom: 20px;
|
66 |
font-size: 14px;
|
67 |
-
line-height: 1.
|
68 |
-
|
69 |
-
.button-container {
|
70 |
-
display: flex;
|
71 |
-
justify-content: space-between;
|
72 |
-
align-items: center;
|
73 |
}
|
74 |
-
.
|
75 |
-
background-color: #
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
-
.
|
78 |
-
background-color: #
|
|
|
|
|
|
|
|
|
|
|
79 |
}
|
80 |
""") as demo:
|
81 |
gr.Markdown("## 🤖 **Professional Groq Chatbot**")
|
@@ -90,7 +98,7 @@ with gr.Blocks(css="""
|
|
90 |
interactive=True,
|
91 |
)
|
92 |
submit_button = gr.Button("Send")
|
93 |
-
clear_button = gr.Button("Clear Chat"
|
94 |
|
95 |
chatbot_output = gr.Textbox(
|
96 |
label="Chat History",
|
|
|
9 |
# Update chat history
|
10 |
chat_history.append(("User", user_input))
|
11 |
chat_history.append(("AI", response))
|
12 |
+
# Format chat history for display with a conversational style
|
13 |
formatted_history = "\n".join(
|
14 |
[f"{role}: {message}" for role, message in chat_history]
|
15 |
)
|
|
|
17 |
except Exception as e:
|
18 |
return f"Error: {e}", chat_history
|
19 |
|
20 |
+
# Create Gradio interface with updated modern design
|
21 |
with gr.Blocks(css="""
|
22 |
body {
|
23 |
+
background-color: #f7f7f7;
|
24 |
+
color: #333;
|
25 |
font-family: 'Roboto', sans-serif;
|
26 |
display: flex;
|
27 |
justify-content: center;
|
|
|
31 |
}
|
32 |
.gradio-container {
|
33 |
width: 100%;
|
34 |
+
max-width: 500px;
|
35 |
+
background-color: #ffffff;
|
36 |
+
padding: 30px;
|
37 |
+
border-radius: 15px;
|
38 |
+
box-shadow: 0px 10px 30px rgba(0, 0, 0, 0.1);
|
39 |
}
|
40 |
.gradio-container .textbox, .gradio-container .button {
|
41 |
+
background-color: #eeeeee;
|
42 |
+
color: #333;
|
43 |
+
border: 1px solid #ccc;
|
44 |
+
border-radius: 10px;
|
45 |
+
padding: 12px;
|
46 |
font-size: 16px;
|
47 |
}
|
48 |
.gradio-container .textbox:focus, .gradio-container .button:focus {
|
49 |
border-color: #007bff;
|
50 |
+
box-shadow: 0px 0px 5px rgba(0, 123, 255, 0.5);
|
51 |
}
|
52 |
.gradio-container .button:hover {
|
53 |
background-color: #007bff;
|
54 |
+
color: #fff;
|
55 |
cursor: pointer;
|
56 |
}
|
57 |
.textbox {
|
58 |
+
margin-bottom: 20px;
|
59 |
}
|
60 |
#chatbox {
|
61 |
+
height: 350px;
|
62 |
overflow-y: auto;
|
63 |
+
border: none;
|
64 |
+
padding: 20px;
|
65 |
+
border-radius: 10px;
|
66 |
+
background-color: #f1f1f1;
|
67 |
+
color: #333;
|
68 |
margin-bottom: 20px;
|
69 |
font-size: 14px;
|
70 |
+
line-height: 1.6;
|
71 |
+
font-family: 'Arial', sans-serif;
|
|
|
|
|
|
|
|
|
72 |
}
|
73 |
+
.user-message {
|
74 |
+
background-color: #e0f7fa;
|
75 |
+
padding: 10px;
|
76 |
+
border-radius: 10px;
|
77 |
+
margin-bottom: 8px;
|
78 |
+
max-width: 75%;
|
79 |
}
|
80 |
+
.ai-message {
|
81 |
+
background-color: #e8f5e9;
|
82 |
+
padding: 10px;
|
83 |
+
border-radius: 10px;
|
84 |
+
margin-bottom: 8px;
|
85 |
+
max-width: 75%;
|
86 |
+
margin-left: auto;
|
87 |
}
|
88 |
""") as demo:
|
89 |
gr.Markdown("## 🤖 **Professional Groq Chatbot**")
|
|
|
98 |
interactive=True,
|
99 |
)
|
100 |
submit_button = gr.Button("Send")
|
101 |
+
clear_button = gr.Button("Clear Chat")
|
102 |
|
103 |
chatbot_output = gr.Textbox(
|
104 |
label="Chat History",
|