# SPDX-License-Identifier: Apache-2.0 from src.processor.message_processor import process_user_request from config import DESCRIPTION import gradio as gr QUICK_PROMPTS = [ "#news AI earthquake early warning [條列] depth:3", "#papers PLUM method for EEW [表格]", "#compare Gemini 1.5 Pro vs GPT-4.1 [簡報] creative!", "#earthquakes 6.0 2024-04-01 2024-04-07 [講義]", "#howto Run SearXNG on Debian [落地實作]", ] with gr.Blocks( fill_height=True, fill_width=True, theme=gr.themes.Soft(), css=""" /* 確保行動版底部按鈕列不被遮到 */ @media (max-width: 640px){ .gradio-container .gr-chat-interface .gr-form{ padding-bottom: 72px; } } """ ) as app: # ChatInterface 使用舊版支援的參數 chat = gr.ChatInterface( fn=process_user_request, chatbot=gr.Chatbot( label="SearchGPT | Gemini 1.5", type="messages", show_copy_button=True, scale=1 ), type="messages", submit_btn="Send", # 舊版只支援 submit_btn examples=[ ["#news Open-source LLM trends [條列] depth:2"], ["#papers P-wave picking with AI [表格]"], ["#compare MiniCPM vs Phi-4 [簡報]"], ["#timeline Taiwan EEW milestones [條列]"], ["https://wikipedia.org/wiki/Artificial_intelligence Read and summarize that"], ["https://huggingface.co/spaces?sort=trending What are the trending Spaces?"], ], cache_examples=False, show_api=False, concurrency_limit=5, ) # 側欄:說明 + 一鍵示例 with gr.Sidebar(): gr.HTML(DESCRIPTION) gr.Markdown("### ⚡ 一鍵範例") for i, p in enumerate(QUICK_PROMPTS, 1): gr.Button(f"示例 {i}", size="sm").click( fn=lambda x=p: x, inputs=None, outputs=chat.textbox ) gr.Markdown("> 點示例 → 文字填入輸入框 → 按 **Send** 或 **Enter** 送出。") app.launch(server_name="0.0.0.0", pwa=True)