feat(score): add Claude CLI backend via subscription token
Replace the direct Anthropic API call in score.py with a pluggable backend (BLAAAI_BACKEND=cli|api, default cli). The CLI path shells out to `claude -p` authed by CLAUDE_CODE_OAUTH_TOKEN, so scoring counts against the Claude subscription instead of API billing. - _call_cli forces a tool-free, JSON-only role (--append-system-prompt, --disallowed-tools) and retries the intermittently-failing `claude -p` - lower default concurrency (3) since each call spawns a heavy Node process - metrics use the CLI's reported total_cost_usd and full token load - batch failures no longer crash the whole scoring run - remove the hardcoded live ANTHROPIC_API_KEY fallback (rotate it in console) - Dockerfile installs Node + @anthropic-ai/claude-code - Nomad injects CLAUDE_CODE_OAUTH_TOKEN via Consul, bumps memory for Node
This commit is contained in:
11
blaaai.nomad
11
blaaai.nomad
@@ -102,11 +102,16 @@ job "blaaai" {
|
||||
}
|
||||
|
||||
env {
|
||||
PORT = "${NOMAD_PORT_http}"
|
||||
PORT = "${NOMAD_PORT_http}"
|
||||
BLAAAI_BACKEND = "cli" # score via the claude CLI (subscription), not API billing
|
||||
BLAAAI_MAX_WORKERS = "2" # heavy Node procs — keep low within the memory budget
|
||||
}
|
||||
|
||||
template {
|
||||
data = <<EOT
|
||||
# Subscription auth for the claude CLI (generate with `claude setup-token`)
|
||||
CLAUDE_CODE_OAUTH_TOKEN={{ key "blaaai/claude_oauth_token" }}
|
||||
# Kept for BLAAAI_BACKEND=api fallback
|
||||
ANTHROPIC_API_KEY={{ key "blaaai/anthropic_api_key" }}
|
||||
HARBOR_ROBOT_TOKEN={{ key "blaaai/harbor_robot_token" }}
|
||||
EOT
|
||||
@@ -115,8 +120,8 @@ EOT
|
||||
}
|
||||
|
||||
resources {
|
||||
cpu = 500
|
||||
memory = 512
|
||||
cpu = 1000
|
||||
memory = 1024 # claude CLI (Node) + chromium need more headroom than the API client
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user