File size: 2,639 Bytes
7718432
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# 部署到 Hugging Face Spaces 指南

## 前置需求

1. 擁有 Hugging Face 帳號
2. 取得 Access Token: https://huggingface.co/settings/tokens
3. 已建立 Space: https://huggingface.co/spaces/Bingdo/process_parameter

---

## 部署步驟

### 1. 進入專案目錄

```bash
cd /Users/bingdo/Documents/deep_research/process_parameter_hf
```

### 2. 初始化 Git(僅首次需要)

```bash
git init
git remote add origin https://huggingface.co/spaces/Bingdo/process_parameter
```

### 3. 新增所有報告資料

```bash
# 複製所有完整報告(含 07_final_output.json 的資料夾)
for dir in /Users/bingdo/Documents/deep_research/process_param_outputs/*/; do
  if [ -f "${dir}07_final_output.json" ]; then
    cp -r "$dir" reports/
  fi
done
```

### 4. 提交變更

```bash
git add .
git commit -m "Add all reports"
```

### 5. 推送到 Hugging Face

**方法 A: 使用 Token 認證(推薦)**

```bash
# 將 YOUR_HF_TOKEN 替換為你的 token
git remote set-url origin https://YOUR_USERNAME:YOUR_HF_TOKEN@huggingface.co/spaces/Bingdo/process_parameter
git push origin main
```

**方法 B: 使用 huggingface-cli 登入**

```bash
# 安裝 huggingface_hub
pip install huggingface_hub

# 登入(會提示輸入 token)
huggingface-cli login

# 推送
git push origin main
```

### 6. 清除 Token(安全考量)

推送完成後,移除 URL 中的 token:

```bash
git remote set-url origin https://huggingface.co/spaces/Bingdo/process_parameter
```

---

## 強制覆蓋遠端

如果遠端已有內容需要覆蓋:

```bash
git push origin main --force
```

---

## 驗證部署

1. 訪問 Space: https://huggingface.co/spaces/Bingdo/process_parameter
2. 等待狀態變為 "Running"(約 1-2 分鐘)
3. 確認報告選擇器顯示所有報告

---

## 常見問題

### Q: 推送時出現 "could not read Username" 錯誤
A: 使用 Token 認證方式,將 token 加入 remote URL

### Q: Space 顯示 "Building" 很久
A: 檢查 requirements.txt 是否有問題,或查看 Build logs

### Q: App 不顯示,只看到 "You can now view your Streamlit app"
A: 確認 `.streamlit/config.toml` 沒有設定 `port`(HF Spaces 只允許 port 8501)

---

## 檔案結構

```
process_parameter_hf/
├── app.py                 # Streamlit 應用程式
├── requirements.txt       # Python 相依套件
├── README.md              # HF Spaces metadata
├── .streamlit/
│   └── config.toml        # Streamlit 設定(不可設定 port)
└── reports/               # 報告資料
    └── {material}_{date}_{time}/
        └── 07_final_output.json
```