fix: Fix Deepseek compatibility issues on the official website. (#1166)

* fix: Compatible with the HTTP2 stream transmission bug on DeepSeek's official website endpoint.

* fix: Remove reasoning from JSON
This commit is contained in:
SkywalkerJi
2025-12-04 20:19:48 +09:00
committed by GitHub
parent 4557f2e657
commit 499ca25bf7
4 changed files with 13 additions and 17 deletions

View File

@@ -404,15 +404,15 @@ func buildSystemPrompt(accountEquity float64, btcEthLeverage, altcoinLeverage in
sb.WriteString("<decision>\n")
sb.WriteString("第二步: JSON决策数组\n\n")
sb.WriteString("```json\n[\n")
sb.WriteString(fmt.Sprintf(" {\"symbol\": \"BTCUSDT\", \"action\": \"open_short\", \"leverage\": %d, \"position_size_usd\": %.0f, \"stop_loss\": 97000, \"take_profit\": 91000, \"confidence\": 85, \"risk_usd\": 300, \"reasoning\": \"下跌趋势+MACD死叉\"},\n", btcEthLeverage, accountEquity*5))
sb.WriteString(" {\"symbol\": \"SOLUSDT\", \"action\": \"update_stop_loss\", \"new_stop_loss\": 155, \"reasoning\": \"移动止损至保本位\"},\n")
sb.WriteString(" {\"symbol\": \"ETHUSDT\", \"action\": \"close_long\", \"reasoning\": \"止盈离场\"}\n")
sb.WriteString(fmt.Sprintf(" {\"symbol\": \"BTCUSDT\", \"action\": \"open_short\", \"leverage\": %d, \"position_size_usd\": %.0f, \"stop_loss\": 97000, \"take_profit\": 91000, \"confidence\": 85, \"risk_usd\": 300},\n", btcEthLeverage, accountEquity*5))
sb.WriteString(" {\"symbol\": \"SOLUSDT\", \"action\": \"update_stop_loss\", \"new_stop_loss\": 155},\n")
sb.WriteString(" {\"symbol\": \"ETHUSDT\", \"action\": \"close_long\"}\n")
sb.WriteString("]\n```\n")
sb.WriteString("</decision>\n\n")
sb.WriteString("## 字段说明\n\n")
sb.WriteString("- `action`: open_long | open_short | close_long | close_short | update_stop_loss | update_take_profit | partial_close | hold | wait\n")
sb.WriteString("- `confidence`: 0-100开仓建议≥75\n")
sb.WriteString("- 开仓时必填: leverage, position_size_usd, stop_loss, take_profit, confidence, risk_usd, reasoning\n")
sb.WriteString("- 开仓时必填: leverage, position_size_usd, stop_loss, take_profit, confidence, risk_usd\n")
sb.WriteString("- update_stop_loss 时必填: new_stop_loss (注意是 new_stop_loss不是 stop_loss)\n")
sb.WriteString("- update_take_profit 时必填: new_take_profit (注意是 new_take_profit不是 take_profit)\n")
sb.WriteString("- partial_close 时必填: close_percentage (0-100)\n\n")

View File

@@ -153,8 +153,7 @@ BTC broke support, MACD death cross, volume increased...
"position_size_usd": 5000,
"stop_loss": 97000,
"take_profit": 91000,
"confidence": 85,
"reasoning": "Bearish technical turn"
"confidence": 85
}
]
```
@@ -462,8 +461,7 @@ Your analysis...
"stop_loss": 97000,
"take_profit": 91000,
"confidence": 85,
"risk_usd": 300,
"reasoning": "Bearish technical"
"risk_usd": 300
}
]
```
@@ -500,14 +498,14 @@ Your analysis...
{
"symbol": "BTCUSDT",
"action": "open_long", // Open long
"reasoning": "This is a great long opportunity because..." // Too long
"confidence": 80 // Only necessary fields
}
// Correct
{
"symbol": "BTCUSDT",
"action": "open_long",
"reasoning": "MACD golden cross + volume surge"
"confidence": 85
}
```

View File

@@ -153,8 +153,7 @@ BTC 跌破支撑位MACD 死叉,成交量放大...
"position_size_usd": 5000,
"stop_loss": 97000,
"take_profit": 91000,
"confidence": 85,
"reasoning": "技术面转空"
"confidence": 85
}
]
```
@@ -462,8 +461,7 @@ AI 必须按照以下格式输出决策:
"stop_loss": 97000,
"take_profit": 91000,
"confidence": 85,
"risk_usd": 300,
"reasoning": "技术面转空"
"risk_usd": 300
}
]
```
@@ -500,14 +498,14 @@ AI 必须按照以下格式输出决策:
{
"symbol": "BTCUSDT",
"action": "open_long", // 开多仓
"reasoning": "这是一个很好的做多机会,因为..." // 太长
"confidence": 80 // 只需要必要字段
}
// 正确
{
"symbol": "BTCUSDT",
"action": "open_long",
"reasoning": "MACD金叉+成交量放大"
"confidence": 85
}
```

View File

@@ -6,7 +6,7 @@ import (
const (
ProviderDeepSeek = "deepseek"
DefaultDeepSeekBaseURL = "https://api.deepseek.com/v1"
DefaultDeepSeekBaseURL = "https://api.deepseek.com"
DefaultDeepSeekModel = "deepseek-chat"
)