Files
PlantAI-dev/scripts/validate_qa_v1_1_73_sidecar.sh
T
2026-08-21 11:04:28 +08:00

53 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SIDECAR_PORT="${QA_V1_SIDECAR_PORT:-7945}"
EVIDENCE_DIR="$PROJECT_ROOT/.runtime/qa_v1_1_73/formal_sidecar_$SIDECAR_PORT"
QUESTION="In which species was tissue-specific expression of CAMTA3 (SR1) examined?"
mkdir -p "$EVIDENCE_DIR"
QA_V1_1_73_PORT="$SIDECAR_PORT" \
QA_V1_RUNTIME_DIR="$EVIDENCE_DIR" \
bash "$PROJECT_ROOT/scripts/start_qa_v1_1_73_7920.sh" \
> "$EVIDENCE_DIR/launch.txt" 2>&1
curl -fsS --max-time 15 \
"http://127.0.0.1:$SIDECAR_PORT/health" \
> "$EVIDENCE_DIR/health.json"
curl -fsS --max-time 15 \
"http://127.0.0.1:$SIDECAR_PORT/api/v1/qa-v1-1-73/info" \
> "$EVIDENCE_DIR/info.json"
curl -sS --max-time 150 \
-H "Content-Type: application/json" \
-d "{\"question\":\"$QUESTION\",\"debug\":false,\"use_llm\":true,\"chain_top_k\":3,\"chain_hops\":2,\"chain_max_edges\":12,\"chain_max_nodes\":10,\"native_chain_enabled\":true,\"native_chain_max_hops\":3,\"native_chain_top_k\":5}" \
-o "$EVIDENCE_DIR/response.json" \
-w "status=%{http_code} total=%{time_total}s bytes=%{size_download}\\n" \
"http://127.0.0.1:$SIDECAR_PORT/api/v1/qa-v1-1-73/chat" \
> "$EVIDENCE_DIR/timing.txt"
"${QA_V1_PYTHON:-/home/xzq/miniconda3/envs/gfpy312/bin/python}" - "$EVIDENCE_DIR" <<'PY'
import json
import sys
from pathlib import Path
evidence_dir = Path(sys.argv[1])
health = json.loads((evidence_dir / "health.json").read_text(encoding="utf-8"))
info = json.loads((evidence_dir / "info.json").read_text(encoding="utf-8"))
response = json.loads((evidence_dir / "response.json").read_text(encoding="utf-8"))
timing = (evidence_dir / "timing.txt").read_text(encoding="utf-8")
assert health["status"] == "ok"
assert health["source"] == "plantai_git_repository"
assert "sandbox" not in json.dumps(health).lower()
assert "sandbox" not in json.dumps(info).lower()
assert info["config"]["graph_schema"] == "canonical"
assert "status=200" in timing
assert response.get("success", True) is True
assert "Solanum lycopersicum" in response.get("answer", "")
assert response.get("native_graph_chains")
(evidence_dir / "PASS").write_text("sidecar validation passed\n", encoding="utf-8")
PY