diff --git a/app.py b/app.py
index 2d86cc2..669c97d 100644
--- a/app.py
+++ b/app.py
@@ -17,179 +17,11 @@ st.set_page_config(
initial_sidebar_state="collapsed",
)
-# ─── Custom CSS ──────────────────────────────────────────────────────────────
+# ─── Minimal CSS ─────────────────────────────────────────────────────────────
st.markdown("""
""", unsafe_allow_html=True)
@@ -205,31 +37,22 @@ QUICK_QUESTIONS = [
# ─── Header ──────────────────────────────────────────────────────────────────
-st.markdown("""
-
-""", unsafe_allow_html=True)
+st.title("🌾 农技问答")
+st.caption("有农业问题,随时来问")
+st.markdown("
", unsafe_allow_html=True)
# ─── Quick Questions ─────────────────────────────────────────────────────────
-chips_html = ''
-for q in QUICK_QUESTIONS:
- chips_html += f'{q}'
-chips_html += '
'
-st.markdown(chips_html, unsafe_allow_html=True)
+with st.container(border=False):
+ cols = st.columns(len(QUICK_QUESTIONS))
+ for i, q in enumerate(QUICK_QUESTIONS):
+ with cols[i]:
+ if st.button(q, key=f"chip_{q}", use_container_width=True):
+ st.session_state.user_input = q
+ st.rerun()
-# Handle chip clicks via native buttons (invisible, placed neatly)
-cols = st.columns(len(QUICK_QUESTIONS))
-for i, q in enumerate(QUICK_QUESTIONS):
- with cols[i]:
- st.markdown("" + " " + "
", unsafe_allow_html=True)
- if st.button(q, key=f"chip_{q}", use_container_width=True):
- st.session_state.user_input = q
- st.rerun()
+st.markdown("
", unsafe_allow_html=True)
# ─── Input ───────────────────────────────────────────────────────────────────
-st.markdown('', unsafe_allow_html=True)
user_input = st.text_area(
"请输入您的问题",
value=st.session_state.get("user_input", ""),
@@ -237,10 +60,7 @@ user_input = st.text_area(
placeholder="例如:水稻稻瘟病怎么防治?",
label_visibility="collapsed",
)
-col1, col2 = st.columns([1, 6])
-with col1:
- submitted = st.button("发送", use_container_width=True)
-st.markdown('
', unsafe_allow_html=True)
+submitted = st.button("发送", type="primary")
# ─── Settings Panel ──────────────────────────────────────────────────────────
with st.expander("⚙️ 模型设置"):
@@ -292,25 +112,16 @@ if submitted and user_input.strip():
if reasoning_piece:
full_reasoning += reasoning_piece
if enable_thinking:
- thinking_placeholder.markdown(
- f''
- f'
正在思考...'
- f'
{full_reasoning}
'
- f'
',
- unsafe_allow_html=True,
+ thinking_placeholder.info(
+ "**正在思考...**\n\n" + full_reasoning
)
content_piece = delta.get("content", "")
if content_piece:
full_content += content_piece
- answer_placeholder.markdown(
- f''
- f'
🌱 回答
'
- f'
'
- f'{full_content}
'
- f'
',
- unsafe_allow_html=True,
- )
+ with answer_placeholder.container(border=True):
+ st.markdown("### 🌱 回答")
+ st.markdown(full_content)
if full_reasoning and enable_thinking:
thinking_placeholder.empty()
@@ -318,19 +129,10 @@ if submitted and user_input.strip():
st.markdown(full_reasoning)
except httpx.HTTPStatusError as e:
- st.markdown(
- f'请求失败 (HTTP {e.response.status_code}): {e.response.text}
',
- unsafe_allow_html=True,
- )
+ st.error(f"请求失败 (HTTP {e.response.status_code}): {e.response.text}")
except Exception as e:
- st.markdown(
- f'请求异常: {e}
',
- unsafe_allow_html=True,
- )
+ st.error(f"请求异常: {e}")
# ─── Footer ───────────────────────────────────────────────────────────────────
-st.markdown("""
-
-""", unsafe_allow_html=True)
+st.divider()
+st.caption("农业技术知识问答 · 仅供参考")