mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 09:38:02 +00:00
fix: 修复codex传递的gpt-5模型无法使用droid账号的问题
This commit is contained in:
@@ -65,6 +65,30 @@ class DroidRelayService {
|
|||||||
return 'anthropic'
|
return 'anthropic'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_normalizeRequestBody(requestBody, endpointType) {
|
||||||
|
if (!requestBody || typeof requestBody !== 'object') {
|
||||||
|
return requestBody
|
||||||
|
}
|
||||||
|
|
||||||
|
const normalizedBody = { ...requestBody }
|
||||||
|
|
||||||
|
if (endpointType === 'openai' && typeof normalizedBody.model === 'string') {
|
||||||
|
const originalModel = normalizedBody.model
|
||||||
|
const trimmedModel = originalModel.trim()
|
||||||
|
const lowerModel = trimmedModel.toLowerCase()
|
||||||
|
|
||||||
|
if (lowerModel === 'gpt-5') {
|
||||||
|
const mappedModel = 'gpt-5-2025-08-07'
|
||||||
|
if (originalModel !== mappedModel) {
|
||||||
|
logger.info(`🔄 将请求模型从 ${originalModel} 映射为 ${mappedModel}`)
|
||||||
|
}
|
||||||
|
normalizedBody.model = mappedModel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return normalizedBody
|
||||||
|
}
|
||||||
|
|
||||||
async _applyRateLimitTracking(rateLimitInfo, usageSummary, model, context = '') {
|
async _applyRateLimitTracking(rateLimitInfo, usageSummary, model, context = '') {
|
||||||
if (!rateLimitInfo) {
|
if (!rateLimitInfo) {
|
||||||
return
|
return
|
||||||
@@ -155,6 +179,7 @@ class DroidRelayService {
|
|||||||
} = options
|
} = options
|
||||||
const keyInfo = apiKeyData || {}
|
const keyInfo = apiKeyData || {}
|
||||||
const normalizedEndpoint = this._normalizeEndpointType(endpointType)
|
const normalizedEndpoint = this._normalizeEndpointType(endpointType)
|
||||||
|
const normalizedRequestBody = this._normalizeRequestBody(requestBody, normalizedEndpoint)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.info(
|
logger.info(
|
||||||
@@ -205,7 +230,7 @@ class DroidRelayService {
|
|||||||
// 构建请求头
|
// 构建请求头
|
||||||
const headers = this._buildHeaders(
|
const headers = this._buildHeaders(
|
||||||
accessToken,
|
accessToken,
|
||||||
requestBody,
|
normalizedRequestBody,
|
||||||
normalizedEndpoint,
|
normalizedEndpoint,
|
||||||
clientHeaders
|
clientHeaders
|
||||||
)
|
)
|
||||||
@@ -217,7 +242,7 @@ class DroidRelayService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 处理请求体(注入 system prompt 等)
|
// 处理请求体(注入 system prompt 等)
|
||||||
const processedBody = this._processRequestBody(requestBody, normalizedEndpoint, {
|
const processedBody = this._processRequestBody(normalizedRequestBody, normalizedEndpoint, {
|
||||||
disableStreaming
|
disableStreaming
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -236,7 +261,7 @@ class DroidRelayService {
|
|||||||
clientResponse,
|
clientResponse,
|
||||||
account,
|
account,
|
||||||
keyInfo,
|
keyInfo,
|
||||||
requestBody,
|
normalizedRequestBody,
|
||||||
normalizedEndpoint,
|
normalizedEndpoint,
|
||||||
skipUsageRecord
|
skipUsageRecord
|
||||||
)
|
)
|
||||||
@@ -264,7 +289,7 @@ class DroidRelayService {
|
|||||||
response,
|
response,
|
||||||
account,
|
account,
|
||||||
keyInfo,
|
keyInfo,
|
||||||
requestBody,
|
normalizedRequestBody,
|
||||||
clientRequest,
|
clientRequest,
|
||||||
normalizedEndpoint,
|
normalizedEndpoint,
|
||||||
skipUsageRecord
|
skipUsageRecord
|
||||||
|
|||||||
Reference in New Issue
Block a user