Spaces:
Sleeping
Sleeping
fix bug from log display
Browse files65 unmodified lines666768697071397 unmodified lines46947047147247347447565 unmodified lineslog_history = baseline_df.sort_values(by='timestamp', ascending=False).head(20).to_dict('records')initial_abnormal_logs = [log for log in log_history if "異常" in str(log.get("status", ""))]if initial_abnormal_logs:initial_df_abn = pd.DataFrame(initial_abnormal_logs)397 unmodified linescustom_time_input = gr.Textbox(label="輸入自訂時間", placeholder="格式: YYYY-MM-DD HH:MM:SS", value="2026-03-17 03:00:00", visible=False)gr.Markdown("---")gr.Markdown("### 📊 即時 Log 與 AI 判定區")log_display = gr.Dataframe(value=log_history, headers=["timestamp", "ip_address", "cookie_id", "account", "role", "action", "status"], datatype=["str", "str", "str", "str", "str", "str", "str"], interactive=False, wrap=True)with gr.Column(scale=2):65 unmodified lines6667686970717273747576397 unmodified lines47447547647747847948048148248348448548665 unmodified lineslog_history = baseline_df.sort_values(by='timestamp', ascending=False).head(20).to_dict('records')# 🌟 修正:先將時間欄位強制轉換為純字串,再轉成字典,避免前端 JS 解析崩潰display_df = baseline_df.sort_values(by='timestamp', ascending=False).head(20).copy()display_df['timestamp'] = display_df['timestamp'].dt.strftime('%Y-%m-%d %H:%M:%S')log_history = display_df.to_dict('records')initial_abnormal_logs = [log for log in log_history if "異常" in str(log.get("status", ""))]if initial_abnormal_logs:initial_df_abn = pd.DataFrame(initial_abnormal_logs)397 unmodified linescustom_time_input = gr.Textbox(label="輸入自訂時間", placeholder="格式: YYYY-MM-DD HH:MM:SS", value="2026-03-17 03:00:00", visible=False)gr.Markdown("---")gr.Markdown("### 📊 即時 Log 與 AI 判定區")log_display = gr.Dataframe(value=pd.DataFrame(log_history) if log_history else None,headers=["timestamp", "ip_address", "cookie_id", "account", "role", "action", "status"],datatype=["str", "str", "str", "str", "str", "str", "str"],interactive=False,wrap=True)with gr.Column(scale=2):
app.py+12-1