forked from niuniu/llm-intelligence
feat(phase1): OpenRouter采集器接入PostgreSQL,数据链路闭环
- 将 fetch_openrouter.go 的 summarize() 实现为 PostgreSQL upsert - 新增 -db 参数和 DATABASE_URL 环境变量支持 - 打通 models + model_prices 表的最小可运行链路 - 创建 llm_intelligence 数据库并运行 migration - 前端 Explorer 验证 T-3.2~T-3.5 全部通过 - 日报生成器正常产出 Markdown 和 latest_models.json
This commit is contained in:
69
scripts/verify_t35.sh
Executable file
69
scripts/verify_t35.sh
Executable file
@@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
# verify_t35.sh — 验收 T-3.5:日报生成器同步产出 latest_models.json + Explorer fallback
|
||||
set -e
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
REPORT="$PROJECT_ROOT/scripts/generate_daily_report.go"
|
||||
EXPLORER="$PROJECT_ROOT/frontend/src/pages/Explorer.tsx"
|
||||
LATEST="$PROJECT_ROOT/frontend/src/data/latest_models.json"
|
||||
|
||||
echo "=== T-3.5 验收检查 ==="
|
||||
|
||||
# T-3.5.1: generate_daily_report.go 含 latest_models.json 写入,且路径从 outDir 推导而非硬编码相对 cwd
|
||||
if grep -q 'latest_models.json' "$REPORT" && \
|
||||
grep -q 'outDir.*frontend.*latest_models.json\|filepath.Join.*outDir.*latest' "$REPORT"; then
|
||||
echo "report-json-write PASS — latest_models.json 写入且路径从 outDir 推导"
|
||||
else
|
||||
echo "report-json-write FAIL"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# T-3.5.2: Explorer.tsx 含 latest_models.json 优先加载和 models.json fallback
|
||||
if grep -q 'latest_models.json' "$EXPLORER" && \
|
||||
grep -q 'models.json' "$EXPLORER"; then
|
||||
echo "explorer-fallback PASS — latest 优先 + models fallback 同时存在"
|
||||
else
|
||||
echo "explorer-fallback FAIL"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# T-3.5.1 补丁验证: latest_models.json 免费模型 pricing 字段完整性
|
||||
if [ ! -f "$LATEST" ]; then
|
||||
echo "pricing-normalized FAIL — latest_models.json 不存在"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if python3 - "$LATEST" <<'PY'
|
||||
import json
|
||||
import sys
|
||||
|
||||
path = sys.argv[1]
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
|
||||
free_models = [
|
||||
model for model in data.get("models", [])
|
||||
if isinstance(model.get("id"), str) and model["id"].endswith(":free")
|
||||
]
|
||||
if not free_models:
|
||||
raise SystemExit(1)
|
||||
|
||||
for model in free_models:
|
||||
pricing = model.get("pricing")
|
||||
if not isinstance(pricing, dict):
|
||||
raise SystemExit(1)
|
||||
if "input" not in pricing or "output" not in pricing:
|
||||
raise SystemExit(1)
|
||||
if pricing["input"] != 0 or pricing["output"] != 0:
|
||||
raise SystemExit(1)
|
||||
PY
|
||||
then
|
||||
echo "pricing-normalized PASS — 免费模型 pricing.input/output 均显式为 0"
|
||||
else
|
||||
echo "pricing-normalized FAIL — 免费模型 pricing 字段缺失或未显式归一为 0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "all PASS"
|
||||
exit 0
|
||||
Reference in New Issue
Block a user