Commit Graph

433 Commits

Author SHA1 Message Date
MarkLo127 9c0a9819e6 Implement Plan A1: Fast Mode Analysis
Features:
- Add analysis_mode parameter (fast/deep) to AnalysisRequest
- Fast mode (15-25 min): Disables investment and risk debates (max_debate_rounds=0)
- Deep mode (60 min): Default mode with debates enabled
- Update backend TradingService to handle analysis_mode
- Add analysis_mode form field to frontend with dropdown selector
- Update TypeScript interfaces to include analysis_mode

Changes:
- backend/app/models/schemas.py: Add analysis_mode field to AnalysisRequest
- backend/app/services/trading_service.py: Handle analysis_mode in create_config()
- backend/app/api/routes.py: Pass analysis_mode parameter to run_analysis()
- frontend/components/analysis/AnalysisForm.tsx: Add analysis_mode dropdown (fast/deep)
- frontend/lib/types.ts: Add analysis_mode to AnalysisRequest interface

When users select "fast mode", the system will:
1. Skip investment debate (max_debate_rounds = 0)
2. Skip risk debate (max_risk_discuss_rounds = 0)
3. Reduce analysis time from ~60 minutes to ~15-25 minutes
4. Still run all analyst reports with proper 500-1000 word counts
5. Provide initial decision without debate refinement

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-12 21:33:23 +08:00
MarkLo127 a019896a9e Merge optimization changes into main
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-12 18:50:01 +08:00
MarkLo127 b2fc38671b Optimize analysis speed and stability: Redis TTL, word count limits, and reporting
Changes:
- C1: Increase Redis TTL from 1 hour to 4 hours for completed tasks (prevents report deletion)
- Word count: Change all analyst prompts from 800-1500 to 500-1000 words
- Output filter: Update word count validation to 500-1000 range, hide specific word counts in warnings
- Remove character counts from output to improve clarity

These changes address:
1. Reports being deleted after 1 hour (now 4 hours)
2. Inconsistent word counts causing reruns (now strict 500-1000)
3. Output showing specific word counts (now just pass/warning)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-12 18:49:48 +08:00
MarkLo127 ca1a1f8cb5 2026-03-12 17:21:30 +08:00
MarkLo127 3545e1574d Merge dazzling-leakey into main: GraphRecursionError fix and stock data validation
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-12 17:19:58 +08:00
MarkLo127 4f219bd74e Fix: Resolve GraphRecursionError by passing config params to agents and increasing recursion_limit to 200
- Pass max_debate_rounds and max_risk_discuss_rounds from config to ConditionalLogic
- Pass max_recur_limit from config to Propagator
- Increase default recursion_limit from 100 to 200 in default_config.py
- Increase Propagator default max_recur_limit from 100 to 200

Also includes earlier fixes:
- Add 365-day minimum date range validation to get_stock_data tool
- Update market analyst prompt to specify 1-year data requirement
- Initialize all debate state fields (bull_history, bear_history, judge_decision, etc.)
- Add report completeness logging in trading_service.py
- Add debug logging in frontend results page

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-12 17:17:23 +08:00
MarkLo127 d887c3be91 2026-03-12 12:02:36 +08:00
MarkLo127 b8454fefc7 Replace next.config.ts rewrites with catch-all API proxy route
The rewrites() approach resolves the backend URL once at server startup,
which always falls back to http://backend:8000 on Railway (where that
Docker Compose hostname doesn't exist). This caused ECONNREFUSED for
/api/analyze and all other proxied routes.

Fix: Add app/api/[...path]/route.ts that resolves the backend URL
per-request via getBackendUrl(), matching the pattern already used by
/api/chat and /api/auth/google/token routes.

Changes:
- New: frontend/app/api/[...path]/route.ts — catch-all proxy (GET/POST/PUT/PATCH/DELETE)
- Removed: frontend/app/api/chat/route.ts — now handled by catch-all
- Updated: frontend/next.config.ts — removed rewrites() block
- Updated: frontend/Dockerfile — cleared NEXT_PUBLIC_API_URL build default

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 11:37:12 +08:00
MarkLo127 ffc36edb97 Fix Railway ECONNREFUSED error by unifying backend URL resolution
Problem: Next.js frontend in production mode falls back to http://backend:8000
(Docker Compose internal hostname) when BACKEND_URL env var is not set.
In Railway's distributed environment, this hostname doesn't exist, causing
ECONNREFUSED errors.

Solution: Create unified getBackendUrl() function with consistent fallback
priority across all server-side proxying files:
1. Explicit BACKEND_URL (for Railway / custom deployment)
2. Development mode -> http://localhost:8000
3. NEXT_PUBLIC_API_URL (may be set in Railway)
4. Docker Compose default -> http://backend:8000

Changes:
- New: frontend/lib/backend-url.ts - centralized URL resolution
- Updated: frontend/next.config.ts - use getBackendUrl()
- Updated: frontend/app/api/chat/route.ts - use getBackendUrl()
- Updated: frontend/app/api/auth/google/token/route.ts - use getBackendUrl()

Railway users must set BACKEND_URL=https://<backend-service>.up.railway.app

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-12 11:03:05 +08:00
MarkLo127 69eba15bbb 2026-03-12 09:30:42 +08:00
MarkLo127 2a8bc6ade8 2026-03-11 20:30:53 +08:00
MarkLo127 62b82788b8 2026-03-11 20:26:37 +08:00
MarkLo127 199315327b 2026-03-11 19:40:54 +08:00
MarkLo127 6802731507 2026-03-11 19:15:24 +08:00
MarkLo127 ea4a267bcf 2026-03-11 18:59:17 +08:00
MarkLo127 c305ea5d3b 2026-03-11 18:38:42 +08:00
MarkLo127 a45bd56ad0 2026-03-11 17:46:07 +08:00
MarkLo127 cccf02b8dc 2026-03-11 17:19:43 +08:00
MarkLo127 de09723454 2026-03-11 16:56:32 +08:00
MarkLo127 7103a0ec90 2026-03-11 16:21:51 +08:00
MarkLo127 d405f39d87 2026-03-11 16:09:38 +08:00
MarkLo127 1f5d59ac7a 2026-03-11 15:32:10 +08:00
MarkLo127 fa209762bb 2026-03-10 19:07:11 +08:00
MarkLo127 e0eab14c11 2026-03-10 18:58:03 +08:00
MarkLo127 2061fa27dd 2026-03-10 18:35:55 +08:00
MarkLo127 83e8068e8d 2026-03-10 18:14:41 +08:00
MarkLo127 071c4bf5cf 2026-03-10 17:58:38 +08:00
MarkLo127 d0c04d4048 2026-03-10 17:36:15 +08:00
MarkLo127 72d287baae 2026-03-10 17:11:02 +08:00
MarkLo127 92c2a84b83 2026-03-10 17:00:32 +08:00
MarkLo127 6e9524c777 2026-03-10 09:13:00 +08:00
MarkLo127 f3cfe21230 2026-03-10 09:05:46 +08:00
MarkLo127 2b3a0e7daa 2026-03-10 02:47:43 +08:00
MarkLo127 9efb5fe8a1 2026-03-09 16:43:54 +08:00
MarkLo127 7a45016f9a 2026-03-09 16:39:21 +08:00
MarkLo127 b545959312 2026-03-09 16:35:09 +08:00
MarkLo127 e0965a66d6 fix: Increase LLM max_tokens to 16384 to prevent report truncation. 2026-03-09 16:03:33 +08:00
MarkLo127 4843bca0d3 Update news data and technical indicator utility functions. 2026-03-09 15:14:48 +08:00
MarkLo127 a90e0434a2 2026-03-09 14:56:49 +08:00
MarkLo127 24511b7992 2026-03-06 08:44:14 +08:00
MarkLo127 d95af6a64c 刪除claude被棄用的模型 2026-03-05 23:42:58 +08:00
MarkLo127 a8a1da6867 2026-03-05 23:32:12 +08:00
MarkLo127 d6020d8bd7 2026-02-12 04:52:16 +08:00
MarkLo127 70d763beca 2026-01-27 15:34:37 +08:00
MarkLo127 d58e80a962 2026-01-27 13:22:52 +08:00
MarkLo127 26ff5ce220 2026-01-27 12:58:53 +08:00
MarkLo127 0bdb3fb774 2026-01-16 00:56:14 +08:00
MarkLo 3145d08c30 2025-12-28 01:22:45 +08:00
MarkLo c0f25aaafd 2025-12-25 20:39:46 +08:00
MarkLo 07b1be6574 2025-12-24 15:24:51 +08:00