- Gate validation: all 143 unit tests pass (80.38% coverage), 11 integration tests pass - Fix ANTHROPIC_MODEL default: claude-sonnet-4-6-20260217 → claude-sonnet-4-6 - Fix docker-compose DATABASE_URL/REDIS_URL: remove nested var expansion - health_check.sh: auto-source .env for local runs, capture claude inference log - .github/workflows/ci.yml: lint (ruff), type-check (mypy), unit + integration tests - .github/workflows/build-and-notify.yml: build Python image → GHCR, notify sync-service - scripts/ops/apply-sync-autopr.sh: configure sync-service auto-PR to agent-deploy - scripts/ops/check-sync-autopr.sh: verify sync-service + ArgoCD app status Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
70 lines
2.0 KiB
Python
Executable File
70 lines
2.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import os
|
|
import sys
|
|
|
|
from anthropic import Anthropic
|
|
|
|
|
|
def parse_args() -> argparse.Namespace:
|
|
parser = argparse.ArgumentParser(
|
|
description="Run an end-to-end Claude inference check via Anthropic-compatible endpoint."
|
|
)
|
|
parser.add_argument(
|
|
"--model",
|
|
default=os.getenv("ANTHROPIC_MODEL", "claude-sonnet-4-6"),
|
|
help="Model name to use (default: ANTHROPIC_MODEL env or claude-sonnet-4-6).",
|
|
)
|
|
parser.add_argument(
|
|
"--base-url",
|
|
default=os.getenv("ANTHROPIC_BASE_URL", "https://api.anthropic.com"),
|
|
help="Anthropic-compatible base URL (default: ANTHROPIC_BASE_URL env).",
|
|
)
|
|
parser.add_argument(
|
|
"--max-tokens",
|
|
type=int,
|
|
default=32,
|
|
help="Max output tokens for the check request.",
|
|
)
|
|
parser.add_argument(
|
|
"--prompt",
|
|
default="Reply with exactly: CLAUDE_OK",
|
|
help="Prompt for the check request.",
|
|
)
|
|
return parser.parse_args()
|
|
|
|
|
|
def main() -> int:
|
|
args = parse_args()
|
|
|
|
auth_token = os.getenv("ANTHROPIC_AUTH_TOKEN", "").strip()
|
|
if not auth_token:
|
|
print("ERROR: ANTHROPIC_AUTH_TOKEN is empty or missing.", file=sys.stderr)
|
|
return 2
|
|
|
|
client = Anthropic(api_key=auth_token, base_url=args.base_url)
|
|
try:
|
|
response = client.messages.create(
|
|
model=args.model,
|
|
max_tokens=args.max_tokens,
|
|
messages=[{"role": "user", "content": args.prompt}],
|
|
)
|
|
except Exception as exc: # noqa: BLE001
|
|
print(f"FAIL: Claude inference request failed: {exc}", file=sys.stderr)
|
|
return 1
|
|
|
|
text_parts = [block.text for block in response.content if getattr(block, "type", "") == "text"]
|
|
text = " ".join(text_parts).strip()
|
|
|
|
print("PASS: Claude inference request succeeded.")
|
|
print(f"model={response.model}")
|
|
print(f"stop_reason={response.stop_reason}")
|
|
print(f"text={text}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|