- agent/tools.py:Tool 元数据(JSON Schema)+ 白名单调用(异常转可读反馈,不中断对话) - agent/tools_impl.py:6 个受控工具 search_stocks / get_market_data / test_factor / run_backtest / get_experiment / compare_experiments —— 全部只读经 Job/Experiment 链路,研究自动归档;无 shell/任意执行/写删数据能力 - agent/llm.py:LLMClient 抽象 + OpenAI 兼容客户端(LLM_API_KEY/LLM_BASE_URL/LLM_MODEL 走 .env,未配置给出引导提示)+ 研究纪律 system prompt(反过拟合/样本外/成本) - agent/service.py:编排循环(tool/final JSON 决策 → 执行 → 回喂 → 结论),轮次上限兜底,未知工具拒绝 - /api/agent/chat;httpx 移至主依赖;Job 默认工厂抽取(api/agent/executor 复用) - 测试 6 项(白名单无 shell、完整研究循环产出、未知工具拒绝、轮次兜底),全量 79 passed / ruff clean
44 lines
931 B
TOML
44 lines
931 B
TOML
[project]
|
|
name = "qlib-platform-backend"
|
|
version = "0.1.0"
|
|
description = "A股个人量化研究平台后端:Qlib 研究引擎 / Tushare 数据源 / FastAPI"
|
|
readme = "../README.md"
|
|
requires-python = ">=3.12"
|
|
dependencies = [
|
|
"fastapi>=0.115",
|
|
"uvicorn[standard]>=0.32",
|
|
"sqlalchemy>=2.0",
|
|
"alembic>=1.13",
|
|
"pyyaml>=6.0",
|
|
"httpx>=0.28.1",
|
|
]
|
|
|
|
[project.optional-dependencies]
|
|
# Phase 1 数据同步需要:uv sync --extra datasource-tushare
|
|
datasource-tushare = ["tushare>=1.4"]
|
|
|
|
[dependency-groups]
|
|
dev = [
|
|
"pytest>=8.0",
|
|
"httpx>=0.27",
|
|
"ruff>=0.6",
|
|
]
|
|
|
|
# uv:本项目是应用(backend/app),不作为可分发包构建
|
|
[tool.uv]
|
|
package = false
|
|
|
|
[tool.pytest.ini_options]
|
|
testpaths = ["tests"]
|
|
pythonpath = ["."]
|
|
addopts = "-q"
|
|
|
|
[tool.ruff]
|
|
line-length = 100
|
|
target-version = "py312"
|
|
src = ["app", "tests"]
|
|
|
|
[tool.ruff.lint]
|
|
select = ["E", "F", "I", "UP", "B", "SIM"]
|
|
ignore = ["E501"]
|