Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -102,135 +102,113 @@ def create_chat_interface():
|
|
102 |
with gr.Blocks(
|
103 |
title="AI用药咨询助手",
|
104 |
css="""
|
105 |
-
|
|
|
|
|
|
|
106 |
.container {
|
107 |
-
width:
|
108 |
-
|
109 |
-
|
110 |
-
padding: 1rem; /* 减小内边距 */
|
111 |
box-sizing: border-box;
|
112 |
}
|
113 |
-
html, body {
|
114 |
-
height: 100%; /* 设置 html 和 body 的高度 */
|
115 |
-
background-color: #f5f5f5;
|
116 |
-
}
|
117 |
-
/* 标题区域样式 */
|
118 |
.title-container {
|
119 |
text-align: center;
|
120 |
-
margin-bottom:
|
121 |
}
|
122 |
.title-container h1 {
|
123 |
color: #2C3E50;
|
124 |
-
font-size: 2rem;
|
|
|
125 |
margin-bottom: 0.5rem;
|
126 |
}
|
127 |
.title-container h3 {
|
128 |
-
color: #
|
129 |
-
font-size: 1rem;
|
130 |
-
font-weight:
|
131 |
}
|
132 |
-
/* 聊天容器样式 */
|
133 |
.chat-container {
|
134 |
-
background-color:
|
135 |
-
border-radius:
|
136 |
-
box-shadow: 0
|
137 |
-
|
138 |
-
margin-bottom: 1rem; /* 减小下边距 */
|
139 |
}
|
140 |
-
/* 聊天框样式 */
|
141 |
.chatbot {
|
142 |
-
|
143 |
-
|
144 |
-
padding:
|
145 |
-
margin-bottom: 1rem; /* 减小下边距 */
|
146 |
-
height: calc(100vh - 350px) !important; /* 动态计算高度 */
|
147 |
-
min-height: 300px; /* 最小高度 */
|
148 |
overflow-y: auto;
|
149 |
-
border: none !important;
|
150 |
}
|
151 |
-
/* 消息样式 */
|
152 |
.chatbot .user-message {
|
153 |
-
background: linear-gradient(135deg, #
|
154 |
color: white !important;
|
155 |
-
border-radius:
|
156 |
-
|
157 |
-
|
158 |
-
max-width: 70% !important; /* 减小最大宽度 */
|
159 |
-
float: right !important;
|
160 |
-
clear: both !important;
|
161 |
-
box-shadow: 0 2px 6px rgba(99, 102, 241, 0.2) !important;
|
162 |
}
|
163 |
.chatbot .bot-message {
|
164 |
-
background
|
165 |
-
border: none !important; /* 移除边框 */
|
166 |
color: #1F2937 !important;
|
167 |
-
border
|
168 |
-
|
169 |
-
|
170 |
-
max-width:
|
171 |
-
float: left !important;
|
172 |
-
clear: both !important;
|
173 |
-
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05) !important;
|
174 |
-
}
|
175 |
-
.chatbot .user-message p, .chatbot .bot-message p{
|
176 |
-
margin: 0 !important;
|
177 |
-
line-height: 1.5 !important;
|
178 |
}
|
179 |
-
.chatbot .user-message:before, .chatbot .bot-message:before {
|
180 |
-
content: none !important;
|
181 |
-
}
|
182 |
-
.chatbot .user-message:after, .chatbot .bot-message:after {
|
183 |
-
content: none !important;
|
184 |
-
}
|
185 |
-
/* 输入区域样式 */
|
186 |
.input-container {
|
187 |
background: white;
|
188 |
-
padding: 1rem;
|
189 |
-
border-
|
190 |
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
|
191 |
}
|
192 |
.message-box {
|
193 |
-
border:
|
194 |
border-radius: 12px !important;
|
195 |
-
padding: 0.
|
196 |
-
font-size: 0.
|
197 |
transition: all 0.3s ease !important;
|
198 |
background: white !important;
|
199 |
}
|
200 |
.message-box:focus {
|
201 |
-
border-color: #
|
202 |
-
box-shadow: 0 0 0
|
203 |
}
|
204 |
-
/* 按钮样式 */
|
205 |
.button-container {
|
206 |
display: flex;
|
207 |
-
gap:
|
208 |
-
margin-top:
|
209 |
}
|
210 |
.submit-btn {
|
211 |
-
background: linear-gradient(135deg, #
|
212 |
color: white !important;
|
213 |
-
padding: 0.
|
214 |
border-radius: 12px !important;
|
215 |
-
font-weight:
|
216 |
transition: all 0.3s ease !important;
|
217 |
flex: 1;
|
218 |
}
|
219 |
.submit-btn:hover {
|
220 |
-
transform: translateY(-
|
221 |
-
box-shadow: 0
|
222 |
}
|
223 |
.clear-btn {
|
224 |
background: #EF4444 !important;
|
225 |
color: white !important;
|
226 |
-
padding: 0.
|
227 |
border-radius: 12px !important;
|
228 |
-
font-weight:
|
229 |
transition: all 0.3s ease !important;
|
230 |
}
|
231 |
.clear-btn:hover {
|
232 |
-
transform: translateY(-
|
233 |
-
box-shadow: 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
}
|
235 |
"""
|
236 |
) as interface:
|
|
|
102 |
with gr.Blocks(
|
103 |
title="AI用药咨询助手",
|
104 |
css="""
|
105 |
+
body {
|
106 |
+
background-color: #F4F6F9;
|
107 |
+
font-family: 'Inter', 'PingFang SC', sans-serif;
|
108 |
+
}
|
109 |
.container {
|
110 |
+
max-width: 800px;
|
111 |
+
margin: 2rem auto;
|
112 |
+
padding: 1rem;
|
|
|
113 |
box-sizing: border-box;
|
114 |
}
|
|
|
|
|
|
|
|
|
|
|
115 |
.title-container {
|
116 |
text-align: center;
|
117 |
+
margin-bottom: 1.5rem;
|
118 |
}
|
119 |
.title-container h1 {
|
120 |
color: #2C3E50;
|
121 |
+
font-size: 2.2rem;
|
122 |
+
font-weight: 700;
|
123 |
margin-bottom: 0.5rem;
|
124 |
}
|
125 |
.title-container h3 {
|
126 |
+
color: #6B7280;
|
127 |
+
font-size: 1rem;
|
128 |
+
font-weight: 400;
|
129 |
}
|
|
|
130 |
.chat-container {
|
131 |
+
background-color: white;
|
132 |
+
border-radius: 16px;
|
133 |
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
|
134 |
+
overflow: hidden;
|
|
|
135 |
}
|
|
|
136 |
.chatbot {
|
137 |
+
height: 500px !important;
|
138 |
+
background-color: #F9FAFB;
|
139 |
+
padding: 1rem;
|
|
|
|
|
|
|
140 |
overflow-y: auto;
|
|
|
141 |
}
|
|
|
142 |
.chatbot .user-message {
|
143 |
+
background: linear-gradient(135deg, #3B82F6, #2563EB);
|
144 |
color: white !important;
|
145 |
+
border-radius: 16px 16px 4px 16px !important;
|
146 |
+
align-self: flex-end !important;
|
147 |
+
max-width: 80% !important;
|
|
|
|
|
|
|
|
|
148 |
}
|
149 |
.chatbot .bot-message {
|
150 |
+
background: linear-gradient(135deg, #F3F4F6, #FFFFFF);
|
|
|
151 |
color: #1F2937 !important;
|
152 |
+
border: 1px solid #E5E7EB !important;
|
153 |
+
border-radius: 16px 16px 16px 4px !important;
|
154 |
+
align-self: flex-start !important;
|
155 |
+
max-width: 80% !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
.input-container {
|
158 |
background: white;
|
159 |
+
padding: 1rem;
|
160 |
+
border-top: 1px solid #E5E7EB;
|
|
|
161 |
}
|
162 |
.message-box {
|
163 |
+
border: 2px solid #E5E7EB !important;
|
164 |
border-radius: 12px !important;
|
165 |
+
padding: 0.75rem !important;
|
166 |
+
font-size: 0.95rem !important;
|
167 |
transition: all 0.3s ease !important;
|
168 |
background: white !important;
|
169 |
}
|
170 |
.message-box:focus {
|
171 |
+
border-color: #3B82F6 !important;
|
172 |
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2) !important;
|
173 |
}
|
|
|
174 |
.button-container {
|
175 |
display: flex;
|
176 |
+
gap: 1rem;
|
177 |
+
margin-top: 1rem;
|
178 |
}
|
179 |
.submit-btn {
|
180 |
+
background: linear-gradient(135deg, #3B82F6, #2563EB) !important;
|
181 |
color: white !important;
|
182 |
+
padding: 0.75rem 1.5rem !important;
|
183 |
border-radius: 12px !important;
|
184 |
+
font-weight: 600 !important;
|
185 |
transition: all 0.3s ease !important;
|
186 |
flex: 1;
|
187 |
}
|
188 |
.submit-btn:hover {
|
189 |
+
transform: translateY(-2px);
|
190 |
+
box-shadow: 0 6px 16px rgba(59, 130, 246, 0.3) !important;
|
191 |
}
|
192 |
.clear-btn {
|
193 |
background: #EF4444 !important;
|
194 |
color: white !important;
|
195 |
+
padding: 0.75rem 1.5rem !important;
|
196 |
border-radius: 12px !important;
|
197 |
+
font-weight: 600 !important;
|
198 |
transition: all 0.3s ease !important;
|
199 |
}
|
200 |
.clear-btn:hover {
|
201 |
+
transform: translateY(-2px);
|
202 |
+
box-shadow: 0 6px 16px rgba(239, 68, 68, 0.3) !important;
|
203 |
+
}
|
204 |
+
@media (max-width: 600px) {
|
205 |
+
.container {
|
206 |
+
margin: 1rem;
|
207 |
+
padding: 0.5rem;
|
208 |
+
}
|
209 |
+
.chatbot {
|
210 |
+
height: 400px !important;
|
211 |
+
}
|
212 |
}
|
213 |
"""
|
214 |
) as interface:
|