refactor(meet-kevin): switch LLM back to native Anthropic SDK with OAuth bearer
Previous refactor (89f01ad) moved to OpenRouter because no sk-ant-api-* key
was found in Vault. Turns out claude-agent-service-spare-{1,2} hold
sk-ant-oat01-* OAuth tokens (108 chars, scope user:inference, 1-year TTL,
minted via 'claude setup-token' — see memory id=832).
These tokens work with the Anthropic SDK via the auth_token= constructor
argument (routes to Authorization: Bearer ... instead of x-api-key: ...).
They consume the Enterprise Claude subscription quota rather than
per-call billing, so the OpenRouter zero-credit problem goes away.
- llm_analyzer.py: revert OpenAI client to AsyncAnthropic; tool-use API
+ cache_control restored
- config.py: openrouter_api_key -> anthropic_oauth_token; model slug
reverted from anthropic/claude-sonnet-4.5 -> claude-sonnet-4-5
- main.py: AsyncOpenAI -> AsyncAnthropic(auth_token=...), drop OpenRouter
attribution headers
- pyproject: openai>=1.50 -> anthropic>=0.40 in meet_kevin extras
- tests: mocks ported back to messages.create + tool_use blocks
This commit is contained in:
parent
4f4d365652
commit
8a1d03a967
5 changed files with 211 additions and 235 deletions
|
|
@ -16,7 +16,7 @@ from datetime import timezone
|
|||
from decimal import Decimal
|
||||
|
||||
import httpx
|
||||
from openai import AsyncOpenAI
|
||||
from anthropic import AsyncAnthropic
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.dialects.postgresql import insert as pg_insert
|
||||
|
||||
|
|
@ -179,14 +179,9 @@ async def run() -> None:
|
|||
# Database
|
||||
engine, session_factory = create_db(config)
|
||||
|
||||
# OpenRouter client + LLM analyzer
|
||||
client = AsyncOpenAI(
|
||||
api_key=config.openrouter_api_key,
|
||||
base_url="https://openrouter.ai/api/v1",
|
||||
default_headers={
|
||||
"HTTP-Referer": "https://trading.viktorbarzin.me",
|
||||
"X-Title": "trading-bot meet-kevin",
|
||||
},
|
||||
# Anthropic client + LLM analyzer (OAuth bearer token)
|
||||
client = AsyncAnthropic(
|
||||
auth_token=config.anthropic_oauth_token,
|
||||
)
|
||||
analyzer = LlmAnalyzer(
|
||||
client=client,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue