Commit Graph

156 Commits

Author SHA1 Message Date
Seefs
618fce621b Revert "fix: aws text content blocks must be non-empty" 2026-03-02 19:43:00 +08:00
Seefs
04954f1058 Revert "Fix/aws non empty text" 2026-03-02 19:40:53 +08:00
Seefs
7cc8ec2c91 fix: tool responses 2026-03-02 19:22:37 +08:00
Seefs
2df604bbad fix: default empty input_json_delta arguments to {} for tool call parsing 2026-03-02 15:51:55 +08:00
Seefs
da11617776 fix: preserve tool_use on malformed tool arguments to keep tool_result pairing valid 2026-03-02 15:41:03 +08:00
Seefs
4d6f9a94a3 fix: aws text content blocks must be non-empty 2026-03-02 15:31:37 +08:00
Seefs
2cf3c1836c fix: preserve explicit zero values in native relay requests 2026-03-01 15:47:03 +08:00
Calcium-Ion
c494c26236 Merge pull request #2887 from seefs001/fix/claude
fix: 补全 streaming message_delta 事件缺失的 input_tokens 和 cache 相关字段
2026-02-08 00:18:04 +08:00
Seefs
81a94c3027 fix: patch message_delta usage via gjson/sjson and skip on passthrough 2026-02-07 19:13:58 +08:00
Thomas
63f246d403 fix: 补全 streaming message_delta 事件缺失的 input_tokens 和 cache 相关字段 (#2881)
当上游为 AWS Bedrock 时,message_delta 的 usage 可能缺少 input_tokens、
cache_creation_input_tokens、cache_read_input_tokens 等字段,导致与原生
Anthropic 格式不一致。从 message_start 积累的 claudeInfo 中补全这些字段后
重新序列化,确保客户端收到一致的 usage 格式。
2026-02-07 18:17:22 +08:00
Seefs
a972722367 fix: 使用openai兼容接口调用部分渠道在最终端点为claude原生端点下还是走了openai扣减input_token的逻辑 2026-02-07 14:21:19 +08:00
Papersnake
e194b747c3 feat: support adaptive thinking 2026-02-06 11:01:23 +08:00
Papersnake
7ca072b1b0 feat: add claude-opus-4-6 2026-02-06 09:12:45 +08:00
CaIon
330e1e6395 remove: drop support for claude-2 and claude-1 series models
- Remove claude-instant-1.2, claude-2, claude-2.0, claude-2.1 from model lists
- Remove /v1/complete endpoint support (legacy completion API)
- Remove RequestModeCompletion and related code paths
- Simplify handler functions by removing requestMode parameter
- Update all channel adaptors that referenced claude handlers
2026-02-05 17:20:46 +08:00
CaIon
9ef9e78821 feat(file): unify file handling with a new FileSource abstraction for URL and base64 data 2026-02-04 18:23:17 +08:00
Seefs
4f786a3591 Merge pull request #2811 from seefs001/fix/openrouter-claude-cache-usage
fix: openrouter claude cache usage
2026-02-03 00:03:19 +08:00
Seefs
06795ddf39 fix: claude panic 2026-02-02 15:03:30 +08:00
Seefs
b063b25998 fix: disable_parallel_tool_use parameter should be removed for tool_choice=none: 2026-01-28 13:31:14 +08:00
Seefs
d829958f53 fix: reason convert 2026-01-25 15:31:23 +08:00
Seefs
0e76cc3f67 feat: claude refusal reason 2026-01-25 15:21:31 +08:00
feitianbubu
1dc7ab9a97 fix: check claudeResponse delta StopReason nil point 2025-12-24 11:54:23 +08:00
FlowerRealm
a655801017 feat: add claude-haiku-4-5-20251001 model support
- Add model to Claude ModelList
- Add model ratio (0.5, $1/1M input tokens)
- Add completion ratio support (5x, $5/1M output tokens)
- Add cache read ratio (0.1, $0.10/1M tokens)
- Add cache write ratio (1.25, $1.25/1M tokens)

Model specs:
- Context window: 200K tokens
- Max output: 64K tokens
- Release date: October 1, 2025
2025-12-05 18:54:20 +08:00
CaIon
1fededceb3 feat: refactor token estimation logic
- Introduced new OpenAI text models in `common/model.go`.
- Added `IsOpenAITextModel` function to check for OpenAI text models.
- Refactored token estimation methods across various channels to use estimated prompt tokens instead of direct prompt token counts.
- Updated related functions and structures to accommodate the new token estimation approach, enhancing overall token management.
2025-12-02 21:34:39 +08:00
Papersnake
766b6bc795 feat: add claude-opus-4-5-20251101 2025-11-25 10:53:01 +08:00
CaIon
c8bbf7bed8 feat: Add ContextKeyLocalCountTokens and update ResponseText2Usage to use context in multiple channels 2025-11-21 18:17:01 +08:00
Seefs
fd55ba7f2c feat: ShouldPreserveThinkingSuffix (#2189) 2025-11-07 17:43:33 +08:00
Seefs
e1b9317531 feat: claude 1h cache (#2155)
* feat: claude 1h cache

* feat: claude 1h cache

* fix price
2025-11-04 00:20:50 +08:00
yanggh
b6f352735e fix(convert): 修复 OpenAI 转 Claude 流时 thinking 块的格式问题
将 `ClaudeMediaMessage.Thinking` 的类型从 `string` 修改为 `*string`,以解决 `omitempty` 导致 `"thinking": ""` 字段在 JSON 序列化时被忽略的问题。

同时更新了 `service/convert.go` 和 `relay/channel/claude/relay-claude.go` 中的相关逻辑,以兼容新的指针类型,确保生成的 Claude 事件流符合官方规范。
2025-10-13 19:32:17 +08:00
Seefs
5010f2d004 format: package name -> github.com/QuantumNous/new-api (#2017) 2025-10-11 15:30:09 +08:00
CaIon
9d418d0df8 refactor(adaptor): extract common header operations into a separate function 2025-10-02 15:28:09 +08:00
Seefs
853814045a Merge pull request #1925 from seefs001/feature/claude-context-editing
feat: claude context editing
2025-09-30 09:48:32 +08:00
Seefs
bc1971843d Merge pull request #1926 from seefs001/fix/claude-beta
fix: claude beta=true
2025-09-30 09:48:18 +08:00
Seefs
946da49721 fix: claude beta=true 2025-09-30 09:46:46 +08:00
Seefs
a7f6065f42 feat: claude context editing 2025-09-30 09:22:40 +08:00
papersnake
112ab0b17c feat: support claude-sonnet-4-5-20250929 2025-09-30 09:14:12 +08:00
creamlike1024
bbfbce9c67 fix: claude header was not set correctly 2025-09-09 23:18:07 +08:00
Calcium-Ion
b3e67d5ef7 Merge pull request #1692 from yunayj/alpha
修改claude system参数为数组,增加通用性
2025-09-08 14:55:48 +08:00
creamlike1024
de73bfff78 feat(relay-claude): mapping stop reason and send text delta on block start type
- convert claude stop reason "max_tokens" to openai "length"
- send content_block_start content text delta
2025-09-07 23:03:19 +08:00
yunayj
fe71af943c 修改claude system参数为数组格式,提升API兼容性 2025-08-29 19:06:01 +08:00
Nekohy
57b1ddcc5f feats:Standardize ClaudeHandler, add zhipu_4v Anthropic native support 2025-08-18 13:14:48 +08:00
CaIon
77b100ba2b refactor: update function signatures to include context and improve file handling #1599 2025-08-15 18:40:54 +08:00
CaIon
c9e9a24e99 refactor: centralize logging and update resource initialization
This commit refactors the logging mechanism across the application by replacing direct logger calls with a centralized logging approach using the `common` package. Key changes include:

- Replaced instances of `logger.SysLog` and `logger.FatalLog` with `common.SysLog` and `common.FatalLog` for consistent logging practices.
- Updated resource initialization error handling to utilize the new logging structure, enhancing maintainability and readability.
- Minor adjustments to improve code clarity and organization throughout various modules.

This change aims to streamline logging and improve the overall architecture of the codebase.
2025-08-14 21:10:04 +08:00
CaIon
97ea8b6560 refactor: Introduce pre-consume quota and unify relay handlers
This commit introduces a major architectural refactoring to improve quota management, centralize logging, and streamline the relay handling logic.

Key changes:
- **Pre-consume Quota:** Implements a new mechanism to check and reserve user quota *before* making the request to the upstream provider. This ensures more accurate quota deduction and prevents users from exceeding their limits due to concurrent requests.

- **Unified Relay Handlers:** Refactors the relay logic to use generic handlers (e.g., `ChatHandler`, `ImageHandler`) instead of provider-specific implementations. This significantly reduces code duplication and simplifies adding new channels.

- **Centralized Logger:** A new dedicated `logger` package is introduced, and all system logging calls are migrated to use it, moving this responsibility out of the `common` package.

- **Code Reorganization:** DTOs are generalized (e.g., `dalle.go` -> `openai_image.go`) and utility code is moved to more appropriate packages (e.g., `common/http.go` -> `service/http.go`) for better code structure.
2025-08-14 20:05:06 +08:00
CaIon
d37af13b33 feat: support qwen claude format 2025-08-07 18:32:31 +08:00
CaIon
a4b02107dd feat: update MaxTokens handling 2025-08-07 16:15:59 +08:00
Calcium-Ion
e7c657ef87 Merge pull request #1511 from neotf/feat-05
feat: add support for claude-opus-4-1 model and update ratios
2025-08-06 12:03:33 +08:00
neotf
c9bcdc89f0 feat: add support for claude-opus-4-1 model and update ratios 2025-08-06 00:58:46 +08:00
creamlike1024
689dbfe71a feat: convert gemini format to openai chat completions 2025-08-01 22:23:35 +08:00
CaIon
563d056ff7 refactor: update error handling to support dynamic error types 2025-07-31 21:16:01 +08:00
Calcium-Ion
a1609f36c7 Merge pull request #1384 from QuantumNous/RequestOpenAI2ClaudeMessage
feat: 改进 RequestOpenAI2ClaudeMessage 和添加 claude web search 计费
2025-07-17 19:15:54 +08:00