mirror of
https://github.com/laoxong/nofx.git
synced 2026-06-04 01:48:22 +08:00
fix: add AI_MAX_TOKENS environment variable to prevent response truncation
## Problem AI responses were being truncated due to a hardcoded max_tokens limit of 2000, causing JSON parsing failures. The error occurred when: 1. AI's thought process analysis was cut off mid-response 2. extractDecisions() incorrectly extracted MACD data arrays from the input prompt 3. Go failed to unmarshal numbers into Decision struct Error message: ``` json: cannot unmarshal number into Go value of type decision.Decision JSON内容: [-867.759, -937.406, -1020.435, ...] ``` ## Solution - Add MaxTokens field to mcp.Client struct - Read AI_MAX_TOKENS from environment variable (default: 2000) - Set AI_MAX_TOKENS=4000 in docker-compose.yml for production use - This provides enough tokens for complete analysis with the 800-line trading strategy prompt ## Testing - Verify environment variable is read correctly - Confirm AI responses are no longer truncated - Check decision logs for complete JSON output
This commit is contained in:
@@ -17,6 +17,7 @@ services:
|
||||
- /etc/localtime:/etc/localtime:ro # Sync host time
|
||||
environment:
|
||||
- TZ=${NOFX_TIMEZONE:-Asia/Shanghai} # Set timezone
|
||||
- AI_MAX_TOKENS=4000 # AI响应的最大token数(默认2000,建议4000-8000)
|
||||
networks:
|
||||
- nofx-network
|
||||
healthcheck:
|
||||
|
||||
Reference in New Issue
Block a user