Spaces:
Running
Running
th commited on
Commit ·
3b0e15d
1
Parent(s): 9e62548
🔧 Add troubleshooting guide + trigger rebuild
Browse files- Created TROUBLESHOOTING.md documenting common deployment issues
- Updated README.md with new features documentation
- Trigger rebuild to fix ModuleNotFoundError
🦊 Generated with Sisi
- README.md +36 -4
- TROUBLESHOOTING.md +266 -0
README.md
CHANGED
|
@@ -14,15 +14,47 @@ Professional birth chart calculation API powered by Swiss Ephemeris.
|
|
| 14 |
|
| 15 |
## ✨ Features
|
| 16 |
|
|
|
|
| 17 |
- ⭐ **100% Accurate** planetary positions using Kerykeion library
|
| 18 |
- 🏠 **12 House Systems** (Placidus, Whole Sign, Equal, Koch, Regiomontanus)
|
| 19 |
- 🌙 **Complete Celestial Data**: Sun, Moon, all planets + North Node
|
| 20 |
- 🔮 **Professional-grade** astronomical calculations
|
| 21 |
-
- 🚀 **Fast & Reliable** API built with FastAPI
|
| 22 |
|
| 23 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
🦊 Built with love by Sisi
|
| 28 |
-
# Trigger build
|
|
|
|
| 14 |
|
| 15 |
## ✨ Features
|
| 16 |
|
| 17 |
+
### Core Calculations
|
| 18 |
- ⭐ **100% Accurate** planetary positions using Kerykeion library
|
| 19 |
- 🏠 **12 House Systems** (Placidus, Whole Sign, Equal, Koch, Regiomontanus)
|
| 20 |
- 🌙 **Complete Celestial Data**: Sun, Moon, all planets + North Node
|
| 21 |
- 🔮 **Professional-grade** astronomical calculations
|
|
|
|
| 22 |
|
| 23 |
+
### NEW: Knowledge Base Endpoints (FREE) 🆓
|
| 24 |
+
- 📚 **48 Professional Interpretations** - Zero AI cost, instant responses
|
| 25 |
+
- ♈ **12 Complete Zodiac Profiles** - Personality, love, career, 2026 themes
|
| 26 |
+
- 🪐 **Planet in Sign Readings** - Sun/Moon through all 12 signs
|
| 27 |
+
- 🏠 **Planet in House Readings** - Detailed house interpretations
|
| 28 |
|
| 29 |
+
### NEW: AI-Powered Readings (Premium) ✨
|
| 30 |
+
- 🤖 **Personalized Birth Chart Analysis** - 800-1200 word custom readings
|
| 31 |
+
- 💰 **90% Cost Reduction** - Knowledge base + AI hybrid approach
|
| 32 |
+
- 🌍 **Multi-language Support** - English, 简体中文, 繁體中文
|
| 33 |
+
- 🎯 **Focus Areas** - Love, career, 2026 guidance, health, spirituality
|
| 34 |
+
|
| 35 |
+
### Infrastructure
|
| 36 |
+
- 🚀 **Fast & Reliable** - Built with FastAPI + Docker
|
| 37 |
+
- 🔐 **Secure** - API key authentication for premium endpoints
|
| 38 |
+
- 📊 **Well-documented** - Complete API docs and examples
|
| 39 |
+
|
| 40 |
+
## 🎯 API Endpoints
|
| 41 |
+
|
| 42 |
+
**FREE (No API Key Required)**:
|
| 43 |
+
- `GET /api/zodiac-profile/{sign}` - Complete zodiac profile
|
| 44 |
+
- `GET /api/planet-in-sign/{planet}/{sign}` - Planet in sign interpretation
|
| 45 |
+
- `GET /api/planet-in-house/{planet}/{house}` - Planet in house interpretation
|
| 46 |
+
- `GET /api/birthday-fortune/{month}/{day}` - Numerology reading
|
| 47 |
+
|
| 48 |
+
**Premium (API Key Required)**:
|
| 49 |
+
- `POST /api/calculate-birth-chart` - Full birth chart calculation
|
| 50 |
+
- `POST /api/generate-chart-svg` - Professional chart visualization
|
| 51 |
+
- `POST /api/personalized-reading` - AI-powered custom reading (NEW!)
|
| 52 |
+
|
| 53 |
+
## 📖 Documentation
|
| 54 |
+
|
| 55 |
+
See full API documentation in:
|
| 56 |
+
- `KNOWLEDGE_BASE_ENDPOINTS.md` - Static knowledge base API
|
| 57 |
+
- `AI_P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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🔧 Troubleshooting Guide - Hugging Face Spaces 部署常见问题
|
| 2 |
+
|
| 3 |
+
## ❌ 问题1: ModuleNotFoundError - 新添加的Python文件找不到
|
| 4 |
+
|
| 5 |
+
### 错误信息
|
| 6 |
+
```
|
| 7 |
+
ModuleNotFoundError: No module named 'ai_service'
|
| 8 |
+
ModuleNotFoundError: No module named 'knowledge_base'
|
| 9 |
+
ModuleNotFoundError: No module named 'xxx'
|
| 10 |
+
```
|
| 11 |
+
|
| 12 |
+
### 原因分析
|
| 13 |
+
Hugging Face Spaces使用Docker容器部署,有时会遇到以下问题:
|
| 14 |
+
|
| 15 |
+
1. **Docker层缓存问题** - 新文件被Git正确提交,但Docker构建时使用了旧缓存
|
| 16 |
+
2. **文件权限问题** - 某些情况下新文件权限不正确(虽然git commit成功)
|
| 17 |
+
3. **构建触发问题** - Space没有检测到需要重新构建
|
| 18 |
+
|
| 19 |
+
### ✅ 解决方案(按优先级尝试)
|
| 20 |
+
|
| 21 |
+
#### 方案1: Factory Reboot(最彻底,推荐)⭐
|
| 22 |
+
|
| 23 |
+
**步骤**:
|
| 24 |
+
1. 前往 Hugging Face Space设置页面
|
| 25 |
+
- URL: `https://huggingface.co/spaces/sisithefox/sisi-astrology-api/settings`
|
| 26 |
+
2. 滚动到底部找到 **"Factory reboot"** 按钮
|
| 27 |
+
3. 点击 **Factory reboot**
|
| 28 |
+
4. 等待Space重新构建(通常2-3分钟)
|
| 29 |
+
5. 检查日志确认新模块被正确加载
|
| 30 |
+
|
| 31 |
+
**原理**:Factory reboot会完全清除Docker缓存,从头构建容器。
|
| 32 |
+
|
| 33 |
+
---
|
| 34 |
+
|
| 35 |
+
#### 方案2: 触发Rebuild(简单快速)
|
| 36 |
+
|
| 37 |
+
**步骤**:
|
| 38 |
+
1. 修改任意文件触发rebuild(如README.md)
|
| 39 |
+
```bash
|
| 40 |
+
cd /Volumes/sparksverse/huggingface-spaces/sisi-astrology-api
|
| 41 |
+
echo "# Trigger rebuild" >> README.md
|
| 42 |
+
git add README.md
|
| 43 |
+
git commit -m "🔧 Trigger rebuild"
|
| 44 |
+
git push
|
| 45 |
+
```
|
| 46 |
+
2. 等待自动重建
|
| 47 |
+
3. 如果仍失败,使用方案1(Factory reboot)
|
| 48 |
+
|
| 49 |
+
**原理**:新commit会触发Space自动重建。
|
| 50 |
+
|
| 51 |
+
---
|
| 52 |
+
|
| 53 |
+
#### 方案3: 检查Git是否正确提交
|
| 54 |
+
|
| 55 |
+
**步骤**:
|
| 56 |
+
```bash
|
| 57 |
+
cd /Volumes/sparksverse/huggingface-spaces/sisi-astrology-api
|
| 58 |
+
|
| 59 |
+
# 确认文件存在
|
| 60 |
+
ls -la ai_service.py knowledge_base.py
|
| 61 |
+
|
| 62 |
+
# 确认已被Git跟踪
|
| 63 |
+
git ls-files | grep ai_service.py
|
| 64 |
+
|
| 65 |
+
# 查看最新commit包含的文件
|
| 66 |
+
git show --stat HEAD
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
**如果文件不在Git中**:
|
| 70 |
+
```bash
|
| 71 |
+
git add ai_service.py knowledge_base.py knowledge_extractor.py
|
| 72 |
+
git commit -m "🔧 Add missing modules"
|
| 73 |
+
git push
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
---
|
| 77 |
+
|
| 78 |
+
#### 方案4: 检查requirements.txt依赖
|
| 79 |
+
|
| 80 |
+
**步骤**:
|
| 81 |
+
确保所有新模块需要的依赖都在`requirements.txt`中:
|
| 82 |
+
|
| 83 |
+
```bash
|
| 84 |
+
# 检查当前依赖
|
| 85 |
+
cat requirements.txt
|
| 86 |
+
|
| 87 |
+
# 如果缺少依赖,添加并提交
|
| 88 |
+
git add requirements.txt
|
| 89 |
+
git commit -m "🔧 Add missing dependencies"
|
| 90 |
+
git push
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
**常见缺失依赖**:
|
| 94 |
+
- `aiohttp` - ai_service.py需要
|
| 95 |
+
- `pathlib` - 通常内置,但检查一下
|
| 96 |
+
|
| 97 |
+
---
|
| 98 |
+
|
| 99 |
+
## ❌ 问题2: Import错误但文件确实存在
|
| 100 |
+
|
| 101 |
+
### 错误信息
|
| 102 |
+
```
|
| 103 |
+
File "/app/app.py", line 19, in <module>
|
| 104 |
+
from ai_service import generate_with_cache
|
| 105 |
+
ModuleNotFoundError: No module named 'ai_service'
|
| 106 |
+
```
|
| 107 |
+
但`git ls-files`显示文件存在。
|
| 108 |
+
|
| 109 |
+
### ✅ 解决方案:添加__pycache__到.gitignore
|
| 110 |
+
|
| 111 |
+
**问题**:有时候`__pycache__`被错误提交,导致import混乱。
|
| 112 |
+
|
| 113 |
+
**步骤**:
|
| 114 |
+
```bash
|
| 115 |
+
cd /Volumes/sparksverse/huggingface-spaces/sisi-astrology-api
|
| 116 |
+
|
| 117 |
+
# 删除__pycache__
|
| 118 |
+
rm -rf __pycache__
|
| 119 |
+
|
| 120 |
+
# 确保.gitignore包含
|
| 121 |
+
echo "__pycache__/" >> .gitignore
|
| 122 |
+
echo "*.pyc" >> .gitignore
|
| 123 |
+
|
| 124 |
+
git add .gitignore
|
| 125 |
+
git commit -m "🔧 Ignore Python cache files"
|
| 126 |
+
git push
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
然后执行**Factory reboot**。
|
| 130 |
+
|
| 131 |
+
---
|
| 132 |
+
|
| 133 |
+
## ❌ 问题3: Space一直显示"Building"
|
| 134 |
+
|
| 135 |
+
### ✅ 解决方案
|
| 136 |
+
|
| 137 |
+
1. **检查构建日志**:
|
| 138 |
+
- 点击Space页面的"Logs"标签
|
| 139 |
+
- 查看详细错误信息
|
| 140 |
+
|
| 141 |
+
2. **常见原因**:
|
| 142 |
+
- requirements.txt中有不兼容的版本
|
| 143 |
+
- Dockerfile配置问题
|
| 144 |
+
- 超时(Space构建时间限制)
|
| 145 |
+
|
| 146 |
+
3. **解决**:
|
| 147 |
+
- 根据日志修复问题
|
| 148 |
+
- Factory reboot
|
| 149 |
+
|
| 150 |
+
---
|
| 151 |
+
|
| 152 |
+
## ❌ 问题4: 环境变量未生效
|
| 153 |
+
|
| 154 |
+
### 错误信息
|
| 155 |
+
```python
|
| 156 |
+
KeyError: 'GEMINI_API_KEY'
|
| 157 |
+
```
|
| 158 |
+
|
| 159 |
+
### ✅ 解决方案
|
| 160 |
+
|
| 161 |
+
**步骤**:
|
| 162 |
+
1. 前往 `https://huggingface.co/spaces/sisithefox/sisi-astrology-api/settings`
|
| 163 |
+
2. 滚动到 **"Repository secrets"**
|
| 164 |
+
3. 添加环境变量:
|
| 165 |
+
- Name: `GEMINI_API_KEY`
|
| 166 |
+
- Value: `your_key_here`
|
| 167 |
+
4. 点击 **Save**
|
| 168 |
+
5. **重要**: 添加环境变量后,必须**Factory reboot**才生效!
|
| 169 |
+
|
| 170 |
+
---
|
| 171 |
+
|
| 172 |
+
## 🎯 通用调试流程
|
| 173 |
+
|
| 174 |
+
遇到部署问题时,按此顺序排查:
|
| 175 |
+
|
| 176 |
+
```
|
| 177 |
+
1. 检查Git commit
|
| 178 |
+
↓ 文件都提交了?
|
| 179 |
+
|
| 180 |
+
2. 查看Hugging Face Logs
|
| 181 |
+
↓ 有具体错误信息?
|
| 182 |
+
|
| 183 |
+
3. Factory Reboot
|
| 184 |
+
↓ 最彻底的解决方案
|
| 185 |
+
|
| 186 |
+
4. 检查环境变量
|
| 187 |
+
↓ 所有secrets都配置了?
|
| 188 |
+
|
| 189 |
+
5. 测试端点
|
| 190 |
+
↓ 成功!
|
| 191 |
+
```
|
| 192 |
+
|
| 193 |
+
---
|
| 194 |
+
|
| 195 |
+
## 📋 部署成功检查清单
|
| 196 |
+
|
| 197 |
+
部署新功能时,确保以下步骤:
|
| 198 |
+
|
| 199 |
+
- [ ] 所有新文件已`git add`
|
| 200 |
+
- [ ] 所有新依赖已添加到`requirements.txt`
|
| 201 |
+
- [ ] `__pycache__`已在`.gitignore`中
|
| 202 |
+
- [ ] Git commit成功(`git show --stat HEAD`)
|
| 203 |
+
- [ ] Git push成功
|
| 204 |
+
- [ ] Hugging Face Space开始构建
|
| 205 |
+
- [ ] 查看构建日志无错误
|
| 206 |
+
- [ ] **如有import错误,立即Factory reboot**
|
| 207 |
+
- [ ] 配置所有需要的环境变量
|
| 208 |
+
- [ ] Factory reboot使环境变量生效
|
| 209 |
+
- [ ] 测试所有新端点
|
| 210 |
+
|
| 211 |
+
---
|
| 212 |
+
|
| 213 |
+
## 🦊 经验总结
|
| 214 |
+
|
| 215 |
+
### 什么时候需要Factory Reboot?
|
| 216 |
+
|
| 217 |
+
**必须Factory Reboot**:
|
| 218 |
+
- ✅ 添加了新的Python模块文件(如ai_service.py)
|
| 219 |
+
- ✅ 修改了requirements.txt依赖
|
| 220 |
+
- ✅ 添加/修改了环境变量
|
| 221 |
+
- ✅ 遇到ModuleNotFoundError但文件确实提交了
|
| 222 |
+
|
| 223 |
+
**不需要Factory Reboot**:
|
| 224 |
+
- ❌ 只修改现有文件内容(不涉及新模块)
|
| 225 |
+
- ❌ 只修改Markdown文档
|
| 226 |
+
|
| 227 |
+
### Factory Reboot位置
|
| 228 |
+
URL: `https://huggingface.co/spaces/sisithefox/sisi-astrology-api/settings`
|
| 229 |
+
|
| 230 |
+
滚动到页面底部 → **Factory reboot** 按钮(红色)
|
| 231 |
+
|
| 232 |
+
---
|
| 233 |
+
|
| 234 |
+
## 🔍 快速诊断命令
|
| 235 |
+
|
| 236 |
+
```bash
|
| 237 |
+
# 1. 确认文件在Git中
|
| 238 |
+
cd /Volumes/sparksverse/huggingface-spaces/sisi-astrology-api
|
| 239 |
+
git ls-files | grep -E "(ai_service|knowledge)"
|
| 240 |
+
|
| 241 |
+
# 2. 查看最新commit
|
| 242 |
+
git show --stat HEAD
|
| 243 |
+
|
| 244 |
+
# 3. 检查远程状态
|
| 245 |
+
git log origin/main --oneline -3
|
| 246 |
+
|
| 247 |
+
# 4. 确认本地和远程同步
|
| 248 |
+
git status
|
| 249 |
+
```
|
| 250 |
+
|
| 251 |
+
---
|
| 252 |
+
|
| 253 |
+
## 📞 仍无法解决?
|
| 254 |
+
|
| 255 |
+
如果按照以上步骤仍无法解决:
|
| 256 |
+
|
| 257 |
+
1. 检查Hugging Face状态页:https://status.huggingface.co/
|
| 258 |
+
2. 查看Space构建日志的**完整错误栈**
|
| 259 |
+
3. 确认Python版本兼容性(Space默认用Python 3.11)
|
| 260 |
+
4. 联系Hugging Face支持
|
| 261 |
+
|
| 262 |
+
---
|
| 263 |
+
|
| 264 |
+
**创建日期**: 2026-01-07
|
| 265 |
+
**最后更新**: 2026-01-07
|
| 266 |
+
**维护者**: SisiTheFox 🦊
|