Claude/trading council setup xezm r#186
Open
yuters777 wants to merge 19 commits intokarpathy:masterfrom
Open
Conversation
…ic, and Google - Add backend/llm_providers.py with provider-agnostic ModelConfig and call_model() interface - Implement direct API integrations for OpenAI, Anthropic, and Google Gemini - Update config.py to use ModelConfig objects instead of string identifiers - Remove OpenRouter dependency (openrouter.py deleted) - Update documentation (README.md, CLAUDE.md) with new API key setup instructions
- Implement shared HTTP client with connection pooling for better performance - Add retry with exponential backoff for transient failures (429, 502, 503, timeouts) - Replace print() statements with structured logging (logger.error/warning/debug) - Add specific exception handling for HTTPStatusError, TimeoutException, RequestError - Register graceful shutdown handler using FastAPI lifespan context manager - Truncate response bodies in error logs to avoid leaking sensitive data
Backend changes: - llm_providers.py: Add Attachment TypedDict and provider-specific formatters - OpenAI: image_url with data URLs, PDFs as image_url - Anthropic: Native image and document content blocks - Google: inlineData parts with mimeType - council.py: Pass attachments through stage1_collect_responses() - main.py: Add AttachmentModel with validation, accept attachments in endpoints Frontend changes: - api.js: Add fileToBase64, validateFile, formatAttachments helpers - ChatInterface.jsx: Add file upload UI with preview and remove buttons - ChatInterface.css: Styling for attachment preview, error messages Supported file types: - Images: jpg, jpeg, png, gif, webp - Documents: pdf, txt, csv, json, md - Max file size: 20MB per file Note: Attachments only sent to Stage 1. Stages 2 and 3 evaluate text only.
Define MarketSnapshot input schema with all nested models (Override, GeoStress, EmaGate, CryptoOverride, CrossAsset, Session) and TradingDecision output schema with ModelVote, ConsensusResult, and TradingMeta. All nested fields are Optional to accept partial snapshots. Trading config defines 3 weighted council models (claude=0.40, gpt=0.35, gemini=0.25) with temperature=0.3. https://claude.ai/code/session_01ReQPKyCWTuys1a7DCVBFp9
Create 6 markdown prompt templates in backend/prompts/trading/: - system_base.md: Framework hierarchy, decision rules, JSON response format - override_change.md: OVERRIDE_STATE_CHANGE trigger analysis - geostress_alert.md: GEOSTRESS_ALERT trigger with stress severity assessment - morning_briefing.md: MORNING_BRIEFING with news/movers placeholders - conflicting_signals.md: CONFLICTING_SIGNALS with hierarchy resolution - unusual_pattern.md: UNUSUAL_PATTERN with signal-vs-noise assessment https://claude.ai/code/session_01ReQPKyCWTuys1a7DCVBFp9
…tep 3) Implements backend/trading_council.py with 5 function groups: - Prompt building: load_prompt_template, load_system_prompt, build_prompts - 3-tier response parsing: direct JSON, markdown block, regex, fallback HOLD - Consensus aggregation: weighted confidence, majority/unanimous/split handling - Telegram alert formatting: emoji per trigger type, < 300 chars - Main orchestrator: async analyze_trading() pipeline via call_models_parallel() No direct API calls — all LLM calls go through llm_providers module. https://claude.ai/code/session_01ReQPKyCWTuys1a7DCVBFp9
Add trading council endpoint isolated from existing conversation routes. Imports MarketSnapshot/TradingDecision models and analyze_trading orchestrator. Health check now returns trading_enabled status. Proper error handling with 503 (disabled) and 500 (failure) responses. All existing routes unchanged. https://claude.ai/code/session_01ReQPKyCWTuys1a7DCVBFp9
Comprehensive pytest suite covering: - Parsing: 5 tests for 3-tier JSON fallback (clean, markdown, regex, partial, garbage) - Consensus: 4 tests for unanimous, majority, 3-way split, weighted confidence - Pipeline: 3 tests verifying Stage 2 skip for OVERRIDE/GEOSTRESS triggers - Models: 3 tests for minimal/full MarketSnapshot and TradingDecision round-trip - Alerts: 3 tests for emoji prefixes, VIX display, and 300-char limit All LLM calls mocked with AsyncMock. No real API calls during test execution. https://claude.ai/code/session_01ReQPKyCWTuys1a7DCVBFp9
CLAUDE.md: Add technical section documenting new files, API endpoint, call flow, trigger types, config, JSON parsing fallback strategy, cost estimates, and integration architecture. README.md: Add user-facing section with setup instructions, sample curl command, and abbreviated response format. Placed before Tech Stack section. No existing content modified in either file. https://claude.ai/code/session_01ReQPKyCWTuys1a7DCVBFp9
Claude/trading council setup xezm r
Covers both General Council and Trading Council modes: file map, provider layer (ModelConfig, retry logic, connection pooling, provider quirks), full pipeline flows, all Pydantic data models, configuration settings, API endpoints, prompt templates with trigger mappings, and dependency graph. https://claude.ai/code/session_01RyfdUHFutBNF4a9okw6Sji
…ture-6ah29 Add comprehensive ARCHITECTURE.md documenting backend structure
- Add OpenAI-Project header to _call_openai() for project-scoped API keys - Replace shutdown gemini-3-pro-preview with gemini-2.5-flash in trading config https://claude.ai/code/session_01ReQPKyCWTuys1a7DCVBFp9
Claude/trading council setup xezm r
- Section 3: Add OpenAI-Project header note under OpenAI quirks - Section 7: Update General Council claude model to claude-sonnet-4-6-20250415 - Section 7: Update Trading Council claude to claude-sonnet-4-6-20250415, gemini to gemini-2.5-pro - Section 7: Add note that gemini-3-pro-preview was shut down March 9, 2026 https://claude.ai/code/session_01ReQPKyCWTuys1a7DCVBFp9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.