Add .gitignore and remove tracked cache files

This commit is contained in:
2025-12-05 16:14:00 +08:00
parent b4934dfe6d
commit 8f52fad41c
21 changed files with 160 additions and 37 deletions

160
.gitignore vendored Normal file
View File

@@ -0,0 +1,160 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
Pipfile.lock
# poetry
poetry.lock
# pdm
.pdm.toml
# PEP 582
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# IDEs
.vscode/
.idea/
*.swp
*.swo
*~
.DS_Store
# Project specific
outputs/
*.jsonl
*.log
# Node modules (if any frontend dependencies)
node_modules/
package-lock.json
yarn.lock
# Temporary files
*.tmp
*.temp
.trae/

View File

@@ -1,37 +0,0 @@
## 问题分析
- 浏览器报错 `net::ERR_ABORTED http://0.0.0.0:8010/`,常见于预览环境对 `0.0.0.0` 的访问被中止或跳转流程未完成。
- 现有后端已启动并挂载静态目录到 `/`,但预览器可能对根路径加载敏感,或端口/主机解析不一致。
- 目前 API 路由与静态挂载并存,使用相对 `fetch('/query')` 正常;问题主要是根页面加载。
## 修复方案
1. 主机与端口访问
- 推荐使用 `http://127.0.0.1:8010/``http://localhost:8010/` 访问,而不是 `0.0.0.0`
- 新增 `/health` 路由用于快速诊断服务是否运行。
2. 静态页面挂载位置
- 将静态目录从根 `/` 改为 `/ui` 挂载,降低与根路径的潜在冲突。
- 新增 `GET /` 路由,返回 `frontend/index.html` 或 302 跳转到 `/ui/index.html`
3. 前端请求与错误处理
- 保持相对路径 `fetch('/query')``/select``/reject`,保持同源;增强错误提示(显示响应状态与内容)。
- 若需要跨源(前端单独部署),补充 CORS允许前端源访问后端 API。
4. 诊断与验证
- 使用 `curl http://127.0.0.1:8010/health` 验证健康。
- 使用 `curl` 端到端:`/query`(新会话与带 `session_id` 再生)、`/select`(生成答案)。
- 浏览器打开 `/ui/` 页面,执行完整流程:开始生成 → 拒绝并再生 → 选择并出答案。
## 具体改动清单
- `_qwen_xinference_demo/api.py`
- 添加 `GET /health` 路由返回 `{status:"ok"}`
-`StaticFiles(directory="frontend", html=True)``/` 挂载到 `/ui`
- 添加 `GET /` 路由,返回 `index.html` 或重定向到 `/ui/index.html`
- `frontend/index.html`
- 增强错误显示:同时显示响应状态码与文本(提升诊断能力)。
## 后续增强(可选)
-`/query``/select` 增加耗时、来源日志,便于问题排查。
- 在页面上展示历史候选与拒绝原因列表,提升可观测性。
- 提供配置项切换嵌入优先级Xinference/Ollama
请确认是否按以上方案进行修改与验证,我将立即实施并完成端到端测试。

Binary file not shown.

Binary file not shown.