BondLens AI is a Flask application packaged with Docker. The production entrypoint is gunicorn:
gunicorn -b 0.0.0.0:5000 app:appdocker compose up --buildOpen:
http://localhost:5000/agent
Health check:
http://localhost:5000/healthz
Agent response schema:
http://localhost:5000/api/agent/schema
FLASK_ENV=production
SECRET_KEY=change-me-in-production
OPENAI_API_KEY=
OPENAI_MODEL=gpt-5.4-mini
OPENAI_BASE_URL=
OPENAI_API_STYLE=auto
OPENAI_TIMEOUT_SECONDS=20
BOND_DATA_MODE=auto
BOND_LIVE_CACHE_PATH=
BOND_LIVE_CACHE_MAX_AGE_HOURS=24
BOND_REPLAY_ENABLED=true
BOND_REPLAY_DIR=BOND_DATA_MODE=autotries AkShare live data first, then cached live snapshot, then the local Excel fallback.OPENAI_API_KEYis optional. Without it, deterministic fallback output is used.OPENAI_BASE_URLcan point to an OpenAI-compatible local server such as Ollama.OPENAI_TIMEOUT_SECONDSdefaults to20so slow local models fail closed into deterministic fallback rather than timing out gunicorn.BOND_REPLAY_ENABLEDcontrols sanitized run replay summaries for/replay. Defaults totrue.BOND_REPLAY_DIRdefaults to.tmp/replays, which is ignored by Git.
When Docker runs on Windows or macOS, point the container to the host machine:
set OPENAI_BASE_URL=http://host.docker.internal:11434/v1
set OPENAI_MODEL=qwen2.5:1.5b
set OPENAI_API_STYLE=chat
docker compose up --buildThe local model is only used after Python tools produce evidence. The LLM answer must pass numeric and risk-language guardrails before it can become the final answer.
For Render, Railway, Fly.io, or similar platforms:
- Use Dockerfile deployment.
- Expose port
5000. - Configure the health check path as
/healthz. - Set
SECRET_KEYin the platform environment. - Keep
BOND_DATA_MODE=autofor live-first behavior orstaticfor deterministic demos. - Leave
OPENAI_API_KEYempty if the demo should run without external LLM calls. - Keep replay storage ephemeral unless the deployment platform needs persistent demo history.
BondLens AI is not an investment advisory system. The API response includes disclaimer, evidence_quality, llm_guardrail, and data_source fields so callers can inspect data freshness, missing context, and LLM safety status.
The portfolio UI intentionally renders evidence ledger, answer judge, risk profile, and replay summaries instead of raw JSON/code-like diagnostics. Raw contracts remain available through /api/agent/query and /api/agent/schema.
BondLens AI 是一个 Flask 应用,通过 Docker 打包。生产入口是 gunicorn:
gunicorn -b 0.0.0.0:5000 app:appdocker compose up --build打开:
http://localhost:5000/agent
健康检查:
http://localhost:5000/healthz
Agent 响应结构:
http://localhost:5000/api/agent/schema
FLASK_ENV=production
SECRET_KEY=change-me-in-production
OPENAI_API_KEY=
OPENAI_MODEL=gpt-5.4-mini
OPENAI_BASE_URL=
OPENAI_API_STYLE=auto
OPENAI_TIMEOUT_SECONDS=20
BOND_DATA_MODE=auto
BOND_LIVE_CACHE_PATH=
BOND_LIVE_CACHE_MAX_AGE_HOURS=24
BOND_REPLAY_ENABLED=true
BOND_REPLAY_DIR=BOND_DATA_MODE=auto会先请求 AkShare 实时数据,然后使用实时快照,最后使用本地 Excel 兜底。OPENAI_API_KEY是可选项。为空时使用确定性 fallback 输出。OPENAI_BASE_URL可以指向 Ollama 等 OpenAI-compatible 本地服务。OPENAI_TIMEOUT_SECONDS默认20秒,本地模型过慢时会安全回退,而不是拖到 gunicorn 超时。BOND_REPLAY_ENABLED控制/replay的运行回放摘要,默认开启。BOND_REPLAY_DIR默认是.tmp/replays,该目录不会提交到 Git。
如果 Docker 运行在 Windows 或 macOS 上,容器需要通过宿主机地址访问本地 Ollama:
set OPENAI_BASE_URL=http://host.docker.internal:11434/v1
set OPENAI_MODEL=qwen2.5:1.5b
set OPENAI_API_STYLE=chat
docker compose up --build本地模型只在 Python 工具生成证据之后使用。LLM 输出必须通过数字一致性和风险语言 guardrail,才会成为最终答案。
如果部署到 Render、Railway、Fly.io 或类似平台:
- 使用 Dockerfile 部署。
- 暴露端口
5000。 - 健康检查路径配置为
/healthz。 - 在平台环境变量中设置
SECRET_KEY。 - 演示实时优先能力时使用
BOND_DATA_MODE=auto;需要稳定演示时使用static。 - 如果不想依赖外部 LLM,保持
OPENAI_API_KEY为空。 - 除非部署平台需要保留演示历史,否则 replay 存储保持临时即可。
BondLens AI 不是投资顾问系统。API 响应包含 disclaimer、evidence_quality、llm_guardrail 和 data_source 字段,调用方可以检查数据新鲜度、缺失上下文和 LLM 安全状态。
作品集页面默认展示证据账本、答案评审、风险画像和运行回放摘要,不展示原始 JSON/代码式调试面板。机器可读结构仍然通过 /api/agent/query 和 /api/agent/schema 提供。