mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-03-30 02:49:34 +00:00
Merge pull request #983 from Wei-Shaw/revert-982-feat/add-gpt-5.3-codex-spark
Revert "feat: add gpt-5.3-codex-spark model support"
This commit is contained in:
29
.github/workflows/auto-release-pipeline.yml
vendored
29
.github/workflows/auto-release-pipeline.yml
vendored
@@ -269,10 +269,16 @@ jobs:
|
||||
id: image_names
|
||||
if: steps.check.outputs.needs_bump == 'true'
|
||||
run: |
|
||||
# 只使用 GitHub Container Registry
|
||||
DOCKER_USERNAME="${{ secrets.DOCKERHUB_USERNAME }}"
|
||||
if [ -z "$DOCKER_USERNAME" ]; then
|
||||
DOCKER_USERNAME="weishaw"
|
||||
fi
|
||||
|
||||
DOCKER_IMAGE=$(echo "${DOCKER_USERNAME}/claude-relay-service" | tr '[:upper:]' '[:lower:]')
|
||||
GHCR_IMAGE=$(echo "ghcr.io/${{ github.repository_owner }}/claude-relay-service" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
{
|
||||
echo "docker_image=${DOCKER_IMAGE}"
|
||||
echo "ghcr_image=${GHCR_IMAGE}"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
@@ -283,9 +289,11 @@ jobs:
|
||||
tag_name: ${{ steps.next_version.outputs.new_tag }}
|
||||
name: Release ${{ steps.next_version.outputs.new_version }}
|
||||
body: |
|
||||
## 🐳 Docker 镜像 (GHCR)
|
||||
## 🐳 Docker 镜像
|
||||
|
||||
```bash
|
||||
docker pull ${{ steps.image_names.outputs.docker_image }}:${{ steps.next_version.outputs.new_tag }}
|
||||
docker pull ${{ steps.image_names.outputs.docker_image }}:latest
|
||||
docker pull ${{ steps.image_names.outputs.ghcr_image }}:${{ steps.next_version.outputs.new_tag }}
|
||||
docker pull ${{ steps.image_names.outputs.ghcr_image }}:latest
|
||||
```
|
||||
@@ -410,6 +418,14 @@ jobs:
|
||||
if: steps.check.outputs.needs_bump == 'true'
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
if: steps.check.outputs.needs_bump == 'true'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: docker.io
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
if: steps.check.outputs.needs_bump == 'true'
|
||||
uses: docker/login-action@v3
|
||||
@@ -426,6 +442,9 @@ jobs:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: |
|
||||
${{ steps.image_names.outputs.docker_image }}:${{ steps.next_version.outputs.new_tag }}
|
||||
${{ steps.image_names.outputs.docker_image }}:latest
|
||||
${{ steps.image_names.outputs.docker_image }}:${{ steps.next_version.outputs.new_version }}
|
||||
${{ steps.image_names.outputs.ghcr_image }}:${{ steps.next_version.outputs.new_tag }}
|
||||
${{ steps.image_names.outputs.ghcr_image }}:latest
|
||||
${{ steps.image_names.outputs.ghcr_image }}:${{ steps.next_version.outputs.new_version }}
|
||||
@@ -441,6 +460,7 @@ jobs:
|
||||
env:
|
||||
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
||||
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
|
||||
DOCKER_IMAGE: ${{ steps.image_names.outputs.docker_image }}
|
||||
GHCR_IMAGE: ${{ steps.image_names.outputs.ghcr_image }}
|
||||
continue-on-error: true
|
||||
run: |
|
||||
@@ -460,14 +480,17 @@ jobs:
|
||||
MESSAGE+="📦 版本号: \`${VERSION}\`"$'\n'$'\n'
|
||||
MESSAGE+="📝 *更新内容:*"$'\n'
|
||||
MESSAGE+="${CHANGELOG_TRUNCATED}"$'\n'$'\n'
|
||||
MESSAGE+="🐳 *Docker 部署 (GHCR):*"$'\n'
|
||||
MESSAGE+="🐳 *Docker 部署:*"$'\n'
|
||||
MESSAGE+="\`\`\`bash"$'\n'
|
||||
MESSAGE+="docker pull ${DOCKER_IMAGE}:${TAG}"$'\n'
|
||||
MESSAGE+="docker pull ${DOCKER_IMAGE}:latest"$'\n'
|
||||
MESSAGE+="docker pull ${GHCR_IMAGE}:${TAG}"$'\n'
|
||||
MESSAGE+="docker pull ${GHCR_IMAGE}:latest"$'\n'
|
||||
MESSAGE+="\`\`\`"$'\n'$'\n'
|
||||
MESSAGE+="🔗 *相关链接:*"$'\n'
|
||||
MESSAGE+="• [GitHub Release](https://github.com/${REPO}/releases/tag/${TAG})"$'\n'
|
||||
MESSAGE+="• [完整更新日志](https://github.com/${REPO}/releases)"$'\n'
|
||||
MESSAGE+="• [Docker Hub](https://hub.docker.com/r/${DOCKER_IMAGE%/*}/claude-relay-service)"$'\n'
|
||||
MESSAGE+="• [GHCR](https://ghcr.io/${GHCR_IMAGE#ghcr.io/})"$'\n'$'\n'
|
||||
MESSAGE+="#ClaudeRelay #Update #v${VERSION//./_}"
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ const OPENAI_MODELS = [
|
||||
{ value: 'gpt-5.2', label: 'GPT-5.2' },
|
||||
{ value: 'gpt-5.2-codex', label: 'GPT-5.2 Codex' },
|
||||
{ value: 'gpt-5.3-codex', label: 'GPT-5.3 Codex' },
|
||||
{ value: 'gpt-5.3-codex-spark', label: 'GPT-5.3 Codex Spark' },
|
||||
{ value: 'codex-mini', label: 'Codex Mini' }
|
||||
]
|
||||
|
||||
|
||||
@@ -52,9 +52,7 @@ class ModelService {
|
||||
'gpt-5.1-codex',
|
||||
'gpt-5.1-codex-max',
|
||||
'gpt-5-2025-08-07',
|
||||
'gpt-5-codex',
|
||||
'gpt-5.3-codex',
|
||||
'gpt-5.3-codex-spark'
|
||||
'gpt-5-codex'
|
||||
]
|
||||
},
|
||||
gemini: {
|
||||
|
||||
@@ -19,68 +19,6 @@ class ClaudeConsoleRelayService {
|
||||
this.defaultUserAgent = 'claude-cli/2.0.52 (external, cli)'
|
||||
}
|
||||
|
||||
/**
|
||||
* 🔄 转换 messages 数组中的 system role 消息
|
||||
* Console API 不支持 role="system",需要将 system 内容合并到第一条 user 消息
|
||||
* @param {Object} requestBody - 原始请求体
|
||||
* @returns {Object} 转换后的请求体
|
||||
*/
|
||||
_transformSystemMessages(requestBody) {
|
||||
if (!requestBody || !Array.isArray(requestBody.messages)) {
|
||||
return requestBody
|
||||
}
|
||||
|
||||
// 收集所有 system messages 的内容
|
||||
const systemContents = []
|
||||
const nonSystemMessages = []
|
||||
|
||||
for (const msg of requestBody.messages) {
|
||||
if (msg && msg.role === 'system') {
|
||||
systemContents.push(msg.content)
|
||||
} else {
|
||||
nonSystemMessages.push(msg)
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有 system messages,直接返回原请求
|
||||
if (systemContents.length === 0) {
|
||||
return requestBody
|
||||
}
|
||||
|
||||
// 合并 system 内容到第一条 user 消息
|
||||
const systemText = systemContents.join('\n\n')
|
||||
let transformedMessages = nonSystemMessages
|
||||
|
||||
// 查找第一条 user 消息
|
||||
const firstUserIndex = nonSystemMessages.findIndex((m) => m && m.role === 'user')
|
||||
|
||||
if (firstUserIndex !== -1) {
|
||||
// 将 system 内容前置到第一条 user 消息
|
||||
const firstUserMsg = nonSystemMessages[firstUserIndex]
|
||||
const mergedContent = `${systemText}\n\n${firstUserMsg.content}`
|
||||
transformedMessages = [...nonSystemMessages]
|
||||
transformedMessages[firstUserIndex] = {
|
||||
...firstUserMsg,
|
||||
content: mergedContent
|
||||
}
|
||||
} else {
|
||||
// 如果没有 user 消息,创建一个包含 system 内容的 user 消息
|
||||
logger.warn(
|
||||
`⚠️ Console API: No user message found to merge system prompt, creating new user message with system content`
|
||||
)
|
||||
transformedMessages = [{ role: 'user', content: systemText }, ...nonSystemMessages]
|
||||
}
|
||||
|
||||
logger.debug(
|
||||
`🔄 Console API: Transformed ${systemContents.length} system message(s) into user message context`
|
||||
)
|
||||
|
||||
return {
|
||||
...requestBody,
|
||||
messages: transformedMessages
|
||||
}
|
||||
}
|
||||
|
||||
// 🚀 转发请求到Claude Console API
|
||||
async relayRequest(
|
||||
requestBody,
|
||||
@@ -225,9 +163,6 @@ class ClaudeConsoleRelayService {
|
||||
model: mappedModel
|
||||
}
|
||||
|
||||
// 🔄 转换 system messages (Console API 不支持 role="system")
|
||||
const transformedRequestBody = this._transformSystemMessages(modifiedRequestBody)
|
||||
|
||||
// 模型兼容性检查已经在调度器中完成,这里不需要再检查
|
||||
|
||||
// 创建代理agent
|
||||
@@ -284,7 +219,7 @@ class ClaudeConsoleRelayService {
|
||||
const requestConfig = {
|
||||
method: 'POST',
|
||||
url: apiEndpoint,
|
||||
data: transformedRequestBody,
|
||||
data: modifiedRequestBody,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'anthropic-version': '2023-06-01',
|
||||
@@ -714,9 +649,6 @@ class ClaudeConsoleRelayService {
|
||||
model: mappedModel
|
||||
}
|
||||
|
||||
// 🔄 转换 system messages (Console API 不支持 role="system")
|
||||
const transformedRequestBody = this._transformSystemMessages(modifiedRequestBody)
|
||||
|
||||
// 模型兼容性检查已经在调度器中完成,这里不需要再检查
|
||||
|
||||
// 创建代理agent
|
||||
@@ -724,7 +656,7 @@ class ClaudeConsoleRelayService {
|
||||
|
||||
// 发送流式请求
|
||||
await this._makeClaudeConsoleStreamRequest(
|
||||
transformedRequestBody,
|
||||
modifiedRequestBody,
|
||||
account,
|
||||
proxyAgent,
|
||||
clientHeaders,
|
||||
|
||||
Reference in New Issue
Block a user