cwadayi commited on
Commit
1f036fb
·
verified ·
1 Parent(s): 7a6cc2f

Update ui/layouts.py

Browse files
Files changed (1) hide show
  1. ui/layouts.py +76 -41
ui/layouts.py CHANGED
@@ -38,17 +38,34 @@ def create_ui(visit_count_html: str, theme: gr.Theme):
38
  opacity: 0.9;
39
  margin-top: 0;
40
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  @media (max-width: 768px) {
42
- .custom-header {
43
- padding: 3rem 1rem;
44
- border-radius: 0;
45
- }
46
- .custom-header h1 {
47
- font-size: 2.5rem;
48
- }
49
- .custom-header p {
50
- font-size: 1.2rem;
51
- }
52
  }
53
  </style>
54
  <div class="custom-header">
@@ -95,37 +112,55 @@ def create_ui(visit_count_html: str, theme: gr.Theme):
95
  with gr.Column(scale=3):
96
  seismo_plot_output = gr.Plot(label="震波圖輸出")
97
  seismo_console_output = gr.Textbox(label="執行結果 / 錯誤訊息", lines=8, interactive=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
 
99
- # --- ✨ 以下是修改後的 AI 助教說明 ---
100
  with gr.TabItem("🤖 AI 課程助教"):
101
  with gr.Group():
102
- gr.Markdown("### 🤖 AI 課程助教 (���識庫 & 即時資訊強化版)")
103
- gr.Markdown("""
104
- 歡迎使用課程 AI 助教!我整合了靜態的課程知識與多種即時資訊來源,您可以隨時向我提問。
105
-
106
- ---
107
-
108
- #### 📚 **課程知識庫**
109
- 我可以回答關於本課程的各種問題,例如:`「這門課的評分標準是什麼?」`
110
-
111
- ---
112
-
113
- #### ⚡ **即時資訊查詢 (可直接輸入 `#數字` 快捷指令)**
114
-
115
- #1. **今日新聞** (或輸入 `今天有什麼重要新聞?`)
116
- #2. **CWA 顯著地震報告** (或輸入 `最新的 CWA 顯著地震報告`)
117
- #3. **CWA 地震預警** (或輸入 `現在有地震預警嗎?`)
118
- #4. **全球大地震** (或輸入 `最近全球有哪些大地震?`)
119
- #5. **PWS 發布情形** (或輸入 `pws info`)
120
- #6. **PWS 地震警報** (或輸入 `最新的 pws 地震警報`)
121
-
122
- ---
123
-
124
- #### 🔎 **進階地震查詢**
125
- 您也可以指定日期與規模來查詢全球地震紀錄,請**完全依照以下格式**提問:
126
- - `查詢 2024-04-01 到 2024-04-07 規模 6.0 以上地震`
127
- """)
128
-
129
  custom_textbox = gr.Textbox(
130
  placeholder="對課程有什麼問題嗎?或輸入 #1、#2... 查詢即時資訊",
131
  show_label=False,
@@ -134,9 +169,9 @@ def create_ui(visit_count_html: str, theme: gr.Theme):
134
 
135
  gr.ChatInterface(
136
  callbacks.ai_chatbot_with_kb,
137
- chatbot=gr.Chatbot(height=450, type="messages", avatar_images=(None, "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png")),
138
- title="課程AI助教",
139
- description="由結構化知識庫與即時工具驅動的問答機器人",
140
  textbox=custom_textbox,
141
  )
142
 
 
38
  opacity: 0.9;
39
  margin-top: 0;
40
  }
41
+ /* Style for instruction cards */
42
+ .instruction-card {
43
+ background-color: #ffffff;
44
+ border-left: 5px solid #0a9396;
45
+ padding: 20px 25px;
46
+ margin: 20px 0;
47
+ border-radius: 8px;
48
+ box-shadow: 0 4px 12px rgba(0,0,0,0.08);
49
+ }
50
+ .instruction-card h3 {
51
+ margin-top: 0;
52
+ color: #005f73;
53
+ font-size: 1.5rem;
54
+ }
55
+ .instruction-card p, .instruction-card ul {
56
+ font-size: 1.1rem;
57
+ color: #34495e;
58
+ }
59
+ .instruction-card code {
60
+ background-color: #e9ecef;
61
+ padding: 3px 6px;
62
+ border-radius: 4px;
63
+ font-size: 1rem;
64
+ }
65
  @media (max-width: 768px) {
66
+ .custom-header { padding: 3rem 1rem; border-radius: 0; }
67
+ .custom-header h1 { font-size: 2.5rem; }
68
+ .custom-header p { font-size: 1.2rem; }
 
 
 
 
 
 
 
69
  }
70
  </style>
71
  <div class="custom-header">
 
112
  with gr.Column(scale=3):
113
  seismo_plot_output = gr.Plot(label="震波圖輸出")
114
  seismo_console_output = gr.Textbox(label="執行結果 / 錯誤訊息", lines=8, interactive=False)
115
+
116
+ # --- ✨ 1. 新增的「AI 助教說明」分頁 ---
117
+ with gr.TabItem("❓ AI 助教說明"):
118
+ gr.Markdown("## 🤖 AI 課程助教使用指南")
119
+ gr.Markdown("歡迎使用課程 AI 助教!我整合了課程知識庫與多種即時資訊來源,您可以透過多種方式與我互動。")
120
+
121
+ with gr.Blocks():
122
+ gr.Markdown(
123
+ """
124
+ <div class="instruction-card">
125
+ <h3>📚 課程知識庫</h3>
126
+ <p>我可以回答關於本課程的各種靜態問題。您可以隨意提問,例如:</p>
127
+ <ul>
128
+ <li><code>這門課的評分標準是什麼?</code></li>
129
+ <li><code>Anaconda 和 Colab 有什麼不同?</code></li>
130
+ <li><code>如何安裝 anaconda?</code></li>
131
+ </ul>
132
+ </div>
133
+
134
+ <div class="instruction-card">
135
+ <h3>⚡ 即時資訊查詢</h3>
136
+ <p>我能幫您查詢最新的動態資訊,您可以直接輸入下方的<b>快捷指令</b>或對應的<b>文字問題</b>:</p>
137
+ <ul>
138
+ <li>快捷指令 <code>#1</code> 或輸入 <code>今天有什麼重要新聞?</code></li>
139
+ <li>快捷指令 <code>#2</code> 或輸入 <code>最新的CWA顯著地震報告</code></li>
140
+ <li>快捷指令 <code>#3</code> 或輸入 <code>現在有地震預警嗎?</code></li>
141
+ <li>快捷指令 <code>#4</code> 或輸入 <code>最近全球有哪些大地震?</code></li>
142
+ <li>快捷指令 <code>#5</code> 或輸入 <code>pws info</code></li>
143
+ <li>快捷指令 <code>#6</code> 或輸入 <code>最新的pws地震警報</code></li>
144
+ </ul>
145
+ </div>
146
+
147
+ <div class="instruction-card">
148
+ <h3>🔎 進階地震查詢</h3>
149
+ <p>您也可以指定<b>日期範圍</b>與<b>規模</b>來查詢全球地震紀錄,請務必<b>完全依照</b>以下格式提問:</p>
150
+ <ul>
151
+ <li><code>查詢 2024-04-01 到 2024-04-07 規模 6.0 以上地震</code></li>
152
+ </ul>
153
+ <p>您可以自由更換其中的日期與規模數值。</p>
154
+ </div>
155
+ """
156
+ )
157
 
158
+ # --- ✨ 2. 簡化後的「AI 課程助教」主分頁 ---
159
  with gr.TabItem("🤖 AI 課程助教"):
160
  with gr.Group():
161
+ gr.Markdown("### 🤖 AI 課程助教")
162
+ gr.Markdown("歡迎使用 AI 助教!您可以直接在下方對話框提問,或參考「❓ **AI 助教說明**」分頁了解所有支援的功能與快捷指令。")
163
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  custom_textbox = gr.Textbox(
165
  placeholder="對課程有什麼問題嗎?或輸入 #1、#2... 查詢即時資訊",
166
  show_label=False,
 
169
 
170
  gr.ChatInterface(
171
  callbacks.ai_chatbot_with_kb,
172
+ chatbot=gr.Chatbot(height=500, type="messages", avatar_images=(None, "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png")),
173
+ title=None,
174
+ description=None,
175
  textbox=custom_textbox,
176
  )
177