mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
fix: 修复temperature参数传递问题
This commit is contained in:
@@ -975,18 +975,10 @@ class DroidRelayService {
|
|||||||
processedBody.stream = true
|
processedBody.stream = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hasTemperatureField = Object.prototype.hasOwnProperty.call(processedBody, 'temperature')
|
||||||
|
|
||||||
// Anthropic 端点:处理 thinking 字段
|
// Anthropic 端点:处理 thinking 字段
|
||||||
if (endpointType === 'anthropic') {
|
if (endpointType === 'anthropic') {
|
||||||
const hasTemperatureField = Object.prototype.hasOwnProperty.call(processedBody, 'temperature')
|
|
||||||
const hasValidTemperature =
|
|
||||||
processedBody.temperature !== undefined && processedBody.temperature !== null
|
|
||||||
const hasValidTopP = processedBody.top_p !== undefined && processedBody.top_p !== null
|
|
||||||
|
|
||||||
if (hasValidTemperature && hasValidTopP) {
|
|
||||||
// Claude API 仅允许 temperature 或 top_p 其一,同时优先保留 temperature
|
|
||||||
delete processedBody.top_p
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.systemPrompt) {
|
if (this.systemPrompt) {
|
||||||
const promptBlock = { type: 'text', text: this.systemPrompt }
|
const promptBlock = { type: 'text', text: this.systemPrompt }
|
||||||
if (Array.isArray(processedBody.system)) {
|
if (Array.isArray(processedBody.system)) {
|
||||||
@@ -1064,6 +1056,16 @@ class DroidRelayService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理 temperature 和 top_p 参数
|
||||||
|
const hasValidTemperature =
|
||||||
|
processedBody.temperature !== undefined && processedBody.temperature !== null
|
||||||
|
const hasValidTopP = processedBody.top_p !== undefined && processedBody.top_p !== null
|
||||||
|
|
||||||
|
if (hasValidTemperature && hasValidTopP) {
|
||||||
|
// 仅允许 temperature 或 top_p 其一,同时优先保留 temperature
|
||||||
|
delete processedBody.top_p
|
||||||
|
}
|
||||||
|
|
||||||
return processedBody
|
return processedBody
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user