Spaces:
Sleeping
Sleeping
BrianChuan commited on
Commit ·
8ccb674
1
Parent(s): a4c77d4
weight API update
Browse files
app.py
CHANGED
|
@@ -43,6 +43,7 @@ def update_system_weights(ow, tw, iw, dw, gw, fw):
|
|
| 43 |
"ow": float(ow), "tw": float(tw), "iw": float(iw),
|
| 44 |
"dw": float(dw), "gw": float(gw), "fw": float(fw)
|
| 45 |
})
|
|
|
|
| 46 |
|
| 47 |
ACTION_MAP = {
|
| 48 |
"教務系統: 期末網路教學評量": "click_eval_system",
|
|
@@ -561,6 +562,7 @@ with gr.Blocks(title="模擬校園入口與資安防護系統") as demo:
|
|
| 561 |
device_weight = gr.Number(label="裝置指紋/行為權重 (%)", value=45, minimum=0, maximum=100)
|
| 562 |
geo_weight = gr.Number(label="🌍 地理偏移敏感度 (%)", value=50, minimum=0, maximum=100)
|
| 563 |
freq_weight = gr.Number(label="⚡ 行為頻率敏感度 (%)", value=60, minimum=0, maximum=100)
|
|
|
|
| 564 |
|
| 565 |
with gr.Accordion("▼ 異常 Log 分析 (Groq AI Agent)", open=True, elem_classes="weight-card"):
|
| 566 |
abnormal_log_display = gr.Dataframe(value=initial_df_abn, headers=["timestamp", "ip_address", "cookie_id", "account", "role", "action", "status"], datatype=["str", "str", "str", "str", "str", "str", "str"], interactive=False, wrap=True)
|
|
@@ -609,7 +611,7 @@ with gr.Blocks(title="模擬校園入口與資安防護系統") as demo:
|
|
| 609 |
|
| 610 |
weight_inputs = [overall_weight, time_weight, ip_weight, device_weight, geo_weight, freq_weight]
|
| 611 |
for w_input in weight_inputs:
|
| 612 |
-
w_input.change(fn=update_system_weights, inputs=weight_inputs, outputs=[])
|
| 613 |
|
| 614 |
update_outputs = [main_router, role_tabs, login_msg, welcome_text, store_df_all, store_df_abn, abnormal_log_input]
|
| 615 |
|
|
|
|
| 43 |
"ow": float(ow), "tw": float(tw), "iw": float(iw),
|
| 44 |
"dw": float(dw), "gw": float(gw), "fw": float(fw)
|
| 45 |
})
|
| 46 |
+
return f"✅ 系統權重已更新 - 總體: {ow}%, 時間: {tw}%, IP: {iw}%, 裝置: {dw}%, 地理: {gw}%, 頻率: {fw}%"
|
| 47 |
|
| 48 |
ACTION_MAP = {
|
| 49 |
"教務系統: 期末網路教學評量": "click_eval_system",
|
|
|
|
| 562 |
device_weight = gr.Number(label="裝置指紋/行為權重 (%)", value=45, minimum=0, maximum=100)
|
| 563 |
geo_weight = gr.Number(label="🌍 地理偏移敏感度 (%)", value=50, minimum=0, maximum=100)
|
| 564 |
freq_weight = gr.Number(label="⚡ 行為頻率敏感度 (%)", value=60, minimum=0, maximum=100)
|
| 565 |
+
weights_status = gr.Textbox(value="", visible=False)
|
| 566 |
|
| 567 |
with gr.Accordion("▼ 異常 Log 分析 (Groq AI Agent)", open=True, elem_classes="weight-card"):
|
| 568 |
abnormal_log_display = gr.Dataframe(value=initial_df_abn, headers=["timestamp", "ip_address", "cookie_id", "account", "role", "action", "status"], datatype=["str", "str", "str", "str", "str", "str", "str"], interactive=False, wrap=True)
|
|
|
|
| 611 |
|
| 612 |
weight_inputs = [overall_weight, time_weight, ip_weight, device_weight, geo_weight, freq_weight]
|
| 613 |
for w_input in weight_inputs:
|
| 614 |
+
w_input.change(fn=update_system_weights, inputs=weight_inputs, outputs=[weights_status])
|
| 615 |
|
| 616 |
update_outputs = [main_router, role_tabs, login_msg, welcome_text, store_df_all, store_df_abn, abnormal_log_input]
|
| 617 |
|