lyi029 commited on
Commit
f9bfd83
·
1 Parent(s): dde483a
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -4,8 +4,6 @@ from fastapi import FastAPI, Query
4
  from fastapi.middleware.cors import CORSMiddleware
5
  import httpx
6
 
7
-
8
-
9
  # ============================================================
10
  # app_spaceB_demo.py — Demo版 Active Learning Space (模擬流程)
11
  # ============================================================
@@ -31,7 +29,7 @@ SIMULATED_FILES = [
31
  ]
32
 
33
  # === Space A 連線設定(請改成你的真實 Space A API endpoint)===
34
- SPACE_A_URL = os.getenv("SPACE_A_URL", "https://huggingface.co/spaces/lyi029/test")
35
 
36
  @app.get("/")
37
  def greet_json():
@@ -42,7 +40,7 @@ def greet_json():
42
  # 🧠 Endpoint 1️⃣: 模擬 Entropy 決策
43
  # ============================================================
44
  @app.post("/check-new-samples")
45
- def check_new_samples(entropy_threshold: float = Query(1.1)):
46
  """
47
  模擬 Active Learning 決策:
48
  entropy 隨機 → 若高於門檻則要求人工標註;
@@ -66,6 +64,7 @@ def check_new_samples(entropy_threshold: float = Query(1.1)):
66
  "cached_branches": len(SIMULATED_BRANCHES)
67
  }
68
  print(f"⚠️ 高熵 → 請人工標註: {samples}")
 
69
  return result
70
 
71
  # 低熵 → 模擬選擇最佳分支
@@ -78,6 +77,7 @@ def check_new_samples(entropy_threshold: float = Query(1.1)):
78
  "cached_branches": len(SIMULATED_BRANCHES)
79
  }
80
  print(f"✅ 低熵 → 推薦使用分支: {branch}")
 
81
  return result
82
 
83
 
 
4
  from fastapi.middleware.cors import CORSMiddleware
5
  import httpx
6
 
 
 
7
  # ============================================================
8
  # app_spaceB_demo.py — Demo版 Active Learning Space (模擬流程)
9
  # ============================================================
 
29
  ]
30
 
31
  # === Space A 連線設定(請改成你的真實 Space A API endpoint)===
32
+ SPACE_A_URL = os.getenv("SPACE_A_URL", "https://lyi029/test.hf.space")
33
 
34
  @app.get("/")
35
  def greet_json():
 
40
  # 🧠 Endpoint 1️⃣: 模擬 Entropy 決策
41
  # ============================================================
42
  @app.post("/check-new-samples")
43
+ def check_new_samples(entropy_threshold: float = Query(0.9)):
44
  """
45
  模擬 Active Learning 決策:
46
  entropy 隨機 → 若高於門檻則要求人工標註;
 
64
  "cached_branches": len(SIMULATED_BRANCHES)
65
  }
66
  print(f"⚠️ 高熵 → 請人工標註: {samples}")
67
+ print(result)
68
  return result
69
 
70
  # 低熵 → 模擬選擇最佳分支
 
77
  "cached_branches": len(SIMULATED_BRANCHES)
78
  }
79
  print(f"✅ 低熵 → 推薦使用分支: {branch}")
80
+ print(result)
81
  return result
82
 
83