From 76ae2fed51e3f97489ea42e55cebbd29848fc29a Mon Sep 17 00:00:00 2001 From: CJACK Date: Tue, 17 Feb 2026 14:01:31 +0800 Subject: [PATCH] feat: Add comprehensive historical and current Claude model IDs for API compatibility and dynamic Docker port configuration. --- API.en.md | 6 ++++-- API.md | 6 ++++-- DEPLOY.en.md | 9 ++++++++- DEPLOY.md | 9 ++++++++- README.MD | 3 ++- README.en.md | 3 ++- docker-compose.dev.yml | 2 +- docker-compose.yml | 4 ++-- internal/config/models.go | 35 +++++++++++++++++++++++++++++++++-- 9 files changed, 64 insertions(+), 13 deletions(-) diff --git a/API.en.md b/API.en.md index 13e39b4..e570dee 100644 --- a/API.en.md +++ b/API.en.md @@ -247,12 +247,14 @@ No auth required. "object": "list", "data": [ {"id": "claude-sonnet-4-5", "object": "model", "created": 1715635200, "owned_by": "anthropic"}, - {"id": "claude-3-5-haiku-latest", "object": "model", "created": 1715635200, "owned_by": "anthropic"}, + {"id": "claude-haiku-4-5", "object": "model", "created": 1715635200, "owned_by": "anthropic"}, {"id": "claude-opus-4-6", "object": "model", "created": 1715635200, "owned_by": "anthropic"} ] } ``` +> Note: the example is partial; the real response includes historical Claude 1.x/2.x/3.x/4.x IDs and common aliases. + ### `POST /anthropic/v1/messages` **Headers**: @@ -267,7 +269,7 @@ anthropic-version: 2023-06-01 | Field | Type | Required | Notes | | --- | --- | --- | --- | -| `model` | string | ✅ | `claude-sonnet-4-5` / `claude-opus-4-6` / `claude-3-5-haiku-latest` | +| `model` | string | ✅ | For example `claude-sonnet-4-5` / `claude-opus-4-6` / `claude-haiku-4-5` (compatible with `claude-3-5-haiku-latest`), plus historical Claude model IDs | | `messages` | array | ✅ | Claude-style messages | | `max_tokens` | number | ❌ | Not strictly enforced by upstream bridge | | `stream` | boolean | ❌ | Default `false` | diff --git a/API.md b/API.md index 95ecbfe..6be7f65 100644 --- a/API.md +++ b/API.md @@ -247,12 +247,14 @@ data: [DONE] "object": "list", "data": [ {"id": "claude-sonnet-4-5", "object": "model", "created": 1715635200, "owned_by": "anthropic"}, - {"id": "claude-3-5-haiku-latest", "object": "model", "created": 1715635200, "owned_by": "anthropic"}, + {"id": "claude-haiku-4-5", "object": "model", "created": 1715635200, "owned_by": "anthropic"}, {"id": "claude-opus-4-6", "object": "model", "created": 1715635200, "owned_by": "anthropic"} ] } ``` +> 说明:示例仅展示部分模型;实际返回包含 Claude 1.x/2.x/3.x/4.x 历史模型 ID 与常见别名。 + ### `POST /anthropic/v1/messages` **请求头**: @@ -267,7 +269,7 @@ anthropic-version: 2023-06-01 | 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | -| `model` | string | ✅ | `claude-sonnet-4-5` / `claude-opus-4-6` / `claude-3-5-haiku-latest` | +| `model` | string | ✅ | 例如 `claude-sonnet-4-5` / `claude-opus-4-6` / `claude-haiku-4-5`(兼容 `claude-3-5-haiku-latest`),并支持历史 Claude 模型 ID | | `messages` | array | ✅ | Claude 风格消息数组 | | `max_tokens` | number | ❌ | 当前实现不会硬性截断上游输出 | | `stream` | boolean | ❌ | 默认 `false` | diff --git a/DEPLOY.en.md b/DEPLOY.en.md index ffdbf50..b7caf8c 100644 --- a/DEPLOY.en.md +++ b/DEPLOY.en.md @@ -145,13 +145,20 @@ Docker Compose includes a built-in health check: ```yaml healthcheck: - test: ["CMD", "wget", "-qO-", "http://localhost:5001/healthz"] + test: ["CMD", "wget", "-qO-", "http://localhost:${PORT:-5001}/healthz"] interval: 30s timeout: 10s retries: 3 start_period: 10s ``` +### 2.6 Docker Troubleshooting + +If container logs look normal but the admin panel is unreachable, check these first: + +1. **Port alignment**: when `PORT` is not `5001`, use the same port in your URL (for example `http://localhost:8080/admin`). +2. **WebUI assets in dev compose**: `docker-compose.dev.yml` runs `go run` in a dev image and does not auto-install Node.js inside the container; if `static/admin` is missing in your repo, `/admin` will return 404. Build once on host: `./scripts/build-webui.sh`. + --- ## 3. Vercel Deployment diff --git a/DEPLOY.md b/DEPLOY.md index e3c6f80..b7fbf9a 100644 --- a/DEPLOY.md +++ b/DEPLOY.md @@ -145,13 +145,20 @@ Docker Compose 已配置内置健康检查: ```yaml healthcheck: - test: ["CMD", "wget", "-qO-", "http://localhost:5001/healthz"] + test: ["CMD", "wget", "-qO-", "http://localhost:${PORT:-5001}/healthz"] interval: 30s timeout: 10s retries: 3 start_period: 10s ``` +### 2.6 Docker 常见排查 + +如果容器日志正常但面板打不开,优先检查: + +1. **端口是否一致**:`PORT` 改成非 `5001` 时,访问地址也要改成对应端口(如 `http://localhost:8080/admin`)。 +2. **开发 compose 的 WebUI 静态文件**:`docker-compose.dev.yml` 使用 `go run` 开发镜像,不会在容器内自动安装 Node.js;若仓库里没有 `static/admin`,`/admin` 会返回 404。可先在宿主机构建一次:`./scripts/build-webui.sh`。 + --- ## 三、Vercel 部署 diff --git a/README.MD b/README.MD index 52779da..b438b75 100644 --- a/README.MD +++ b/README.MD @@ -80,10 +80,11 @@ flowchart LR | 模型 | 默认映射 | | --- | --- | | `claude-sonnet-4-5` | `deepseek-chat` | -| `claude-3-5-haiku-latest` | `deepseek-chat` | +| `claude-haiku-4-5`(兼容 `claude-3-5-haiku-latest`) | `deepseek-chat` | | `claude-opus-4-6` | `deepseek-reasoner` | 可通过配置中的 `claude_mapping` 或 `claude_model_mapping` 覆盖映射关系。 +另外,`/anthropic/v1/models` 现已包含 Claude 1.x/2.x/3.x/4.x 历史模型 ID 与常见别名,便于旧客户端直接兼容。 ## 快速开始 diff --git a/README.en.md b/README.en.md index 189d719..bbad73b 100644 --- a/README.en.md +++ b/README.en.md @@ -80,10 +80,11 @@ flowchart LR | Model | Default Mapping | | --- | --- | | `claude-sonnet-4-5` | `deepseek-chat` | -| `claude-3-5-haiku-latest` | `deepseek-chat` | +| `claude-haiku-4-5` (compatible with `claude-3-5-haiku-latest`) | `deepseek-chat` | | `claude-opus-4-6` | `deepseek-reasoner` | Override mapping via `claude_mapping` or `claude_model_mapping` in config. +In addition, `/anthropic/v1/models` now includes historical Claude 1.x/2.x/3.x/4.x IDs and common aliases for legacy client compatibility. ## Quick Start diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index c378129..39cb6b5 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -16,7 +16,7 @@ services: container_name: ds2api-dev command: ["go", "run", "./cmd/ds2api"] ports: - - "${PORT:-5001}:5001" + - "${PORT:-5001}:${PORT:-5001}" env_file: - .env environment: diff --git a/docker-compose.yml b/docker-compose.yml index d984420..a3f93f7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,14 +4,14 @@ services: image: ds2api:latest container_name: ds2api ports: - - "${PORT:-5001}:5001" + - "${PORT:-5001}:${PORT:-5001}" env_file: - .env environment: - HOST=0.0.0.0 restart: unless-stopped healthcheck: - test: ["CMD", "wget", "-qO-", "http://localhost:5001/healthz"] + test: ["CMD", "wget", "-qO-", "http://localhost:${PORT:-5001}/healthz"] interval: 30s timeout: 10s retries: 3 diff --git a/internal/config/models.go b/internal/config/models.go index 51f6126..13fa63d 100644 --- a/internal/config/models.go +++ b/internal/config/models.go @@ -16,13 +16,44 @@ var DeepSeekModels = []ModelInfo{ } var ClaudeModels = []ModelInfo{ - {ID: "claude-sonnet-4-5", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, - {ID: "claude-sonnet-4-5-20250929", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + // Current aliases {ID: "claude-opus-4-6", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-sonnet-4-5", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-haiku-4-5", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + + // Current snapshots + {ID: "claude-opus-4-5-20251101", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, {ID: "claude-opus-4-1", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, {ID: "claude-opus-4-1-20250805", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-opus-4-0", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-opus-4-20250514", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-sonnet-4-5-20250929", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-sonnet-4-0", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-sonnet-4-20250514", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-haiku-4-5-20251001", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + + // Claude 3.x (legacy/deprecated snapshots and aliases) {ID: "claude-3-7-sonnet-latest", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-3-7-sonnet-20250219", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-3-5-sonnet-latest", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-3-5-sonnet-20240620", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-3-5-sonnet-20241022", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-3-opus-20240229", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-3-sonnet-20240229", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, {ID: "claude-3-5-haiku-latest", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-3-5-haiku-20241022", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-3-haiku-20240307", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + + // Claude 2.x and 1.x (retired but accepted for compatibility) + {ID: "claude-2.1", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-2.0", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-1.3", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-1.2", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-1.1", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-1.0", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-instant-1.2", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-instant-1.1", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, + {ID: "claude-instant-1.0", Object: "model", Created: 1715635200, OwnedBy: "anthropic"}, } func GetModelConfig(model string) (thinking bool, search bool, ok bool) {