#!/bin/bash # 任务1:采集缺失模型参考(detector 16-cell + fp_fusion 26-cell) # 用法: bash collect_ref.sh # 依赖包外的 llm-fingerprint-detector(Node 工具,不在本仓库内),需显式指定: # export FP_DET_TOOL=/path/to/llm-fingerprint-detector # export FP_API_KEY=sk-xxxx # 或复用 OPENAI_API_KEY set -e MODEL="$1" NAME="$2" API="${FP_API_URL:-https://api.vectron.meta-stone.com/v1}" KEY="${FP_API_KEY:-${OPENAI_API_KEY:-}}" FP="$(cd "$(dirname "$0")" && pwd)" DET="${FP_DET_TOOL:?需设置 FP_DET_TOOL 指向 llm-fingerprint-detector 检出目录}" if [ -z "$KEY" ]; then echo "ERROR: 未设置 FP_API_KEY/OPENAI_API_KEY" >&2; exit 1; fi echo "=== [$NAME] 16-cell detector 参考 ===" cd "$DET" LLM_FINGERPRINT_API_KEY="$KEY" node dist/cli.js fingerprint \ --base-url "$API" --model "$MODEL" --preset strict \ --concurrency 2 --timeout 90000 \ --out "$FP/references/${NAME}_reference.json" --quiet 2>&1 | tail -3 echo "=== [$NAME] 10 新增 cell(fp_fusion extra)===" cd "$FP" python3 collect_fp_extra_reference.py \ --api-url "$API" --model "$MODEL" --api-key "$KEY" \ --out /tmp/bfd/${NAME}_extra_cells.json 2>&1 | tail -2 echo "=== [$NAME] 合并 26-cell fusion ===" python3 merge_fusion_reference.py "$NAME" "${NAME}_reference.json" \ /tmp/bfd/${NAME}_extra_cells.json 2>&1 | tail -3 echo "=== [$NAME] 校验 ===" python3 check_ref.py "$FP/references/${NAME}_reference.json" python3 check_ref.py "$FP/references/${NAME}_fusion_reference.json"