Commit Graph

683 Commits

Author SHA1 Message Date
CaIon
906f797be5 refactor: replace json.Marshal with common.Marshal for consistency and error handling 2025-08-28 13:51:07 +08:00
creamlike1024
13d14dc8a8 Merge branch 'alpha' of github.com:iszcz/new-api into iszcz-alpha 2025-08-27 22:26:15 +08:00
CaIon
3401abe4d2 fix(relay-gemini): update media handling in candidate content processing 2025-08-27 12:14:50 +08:00
CaIon
8004b4ff5f Merge remote-tracking branch 'origin/alpha' into alpha 2025-08-26 20:38:32 +08:00
Calcium-Ion
6e62b76105 Merge pull request #1652 from HynoR/feat/ds3.1
feat: adapt Volcengine adaptor for deepseek3.1 with thinking mode
2025-08-26 20:35:29 +08:00
CaIon
67719dc087 fix: update web search handling and request structure in adaptor and openai_request 2025-08-26 18:15:18 +08:00
CaIon
b0f86bd82e fix: update PromptTokens assignment logic in relay_responses 2025-08-26 14:21:10 +08:00
CaIon
3e5bc637de fix: Invalid type for 'input[x].summary': expected an array of objects, but got null instead 2025-08-26 13:17:31 +08:00
CaIon
f249cf9acc fix: ensure reasoning is not nil before setting effort in OpenAI responses 2025-08-25 22:46:45 +08:00
iszcz
d904f9b486 task_relay_info 2025-08-25 18:01:10 +08:00
CaIon
781a708173 feat: support qwen-image-edit 2025-08-25 14:33:12 +08:00
HynoR
c94a74c398 feat: adapt Volcengine adaptor for deepseek3.1 model with thinking suffix 2025-08-25 11:16:43 +08:00
CaIon
3d7a05bdac feat: update ali image response handling 2025-08-24 22:50:45 +08:00
CaIon
488f6a2e71 feat: enhance image request handling and add async support 2025-08-24 21:52:56 +08:00
Nekohy
2d1512096a feats:add custom headers override 2025-08-24 01:02:23 +08:00
Calcium-Ion
fe53424ed8 Merge pull request #1611 from nekohy/feats-zhipu_4v-anthropic
Feats:Standardize ClaudeHandler, add Zhipu_4v Anthropic native channel support
2025-08-23 13:48:18 +08:00
CaIon
858585d974 fix: update response body handling in OpenAI relay format 2025-08-22 17:33:20 +08:00
Calcium-Ion
d09b99c1f0 Merge pull request #1606 from funnycups/patch-1
fix: prompt calculation
2025-08-22 17:30:53 +08:00
creamlike1024
47ddf76af9 fix: Guard against negative or zero n from ExtraBody to prevent uint underflow 2025-08-18 23:35:01 +08:00
Sh1n3zZ
8a1f6534fc feat: imagen for vertex channel 2025-08-18 21:49:55 +08:00
Nekohy
57b1ddcc5f feats:Standardize ClaudeHandler, add zhipu_4v Anthropic native support 2025-08-18 13:14:48 +08:00
CaIon
61601d38c4 feat: 完善gemini格式转换 2025-08-17 19:08:06 +08:00
CaIon
3e61e6eb52 refactor: extract FlushWriter function for improved stream flushing 2025-08-17 15:30:31 +08:00
funnycups
2f176cff7f fix: prompt calculation
User will correctly get estimated prompt usage when upstream returns either zero or nothing.
2025-08-16 22:54:00 +08:00
CaIon
4e3f008ae9 fix: update token usage calculation 2025-08-16 19:11:15 +08:00
Calcium-Ion
5fbbb24201 Merge pull request #1597 from wzxjohn/feature/add_openai_models
feat(relay): add OpenAI gpt-4.1 o3 o4 gpt-image-1 models
2025-08-16 12:27:20 +08:00
CaIon
77b100ba2b refactor: update function signatures to include context and improve file handling #1599 2025-08-15 18:40:54 +08:00
wzxjohn
269bb0c896 feat(relay): add OpenAI gpt-4.1 o3 o4 gpt-image-1 models 2025-08-15 17:10:16 +08:00
CaIon
63e7fb697f Merge remote-tracking branch 'origin/alpha' into alpha 2025-08-15 16:47:36 +08:00
Calcium-Ion
30e4679384 Merge pull request #1577 from nekohy/feats-better-adaptor-for-openrouter
Fix reasoning adaptor for openrouter
2025-08-15 16:19:24 +08:00
CaIon
8284cff9b7 refactor: set prompt tokens when not provided in usage 2025-08-15 15:55:01 +08:00
CaIon
5084a43aa9 refactor: ensure graceful closure of response body in relay responses 2025-08-15 15:10:54 +08:00
CaIon
8eb17f24bb refactor: improve request type validation and enhance sensitive information masking 2025-08-15 13:20:36 +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
Nekohy
ebb624148b feats:the Openrouter Claude thinking 2025-08-12 22:39:32 +08:00
Nekohy
4a49a80d10 fix:Delete the excess ReasoningEffort from the Openrouter OpenAI thinking model. 2025-08-12 21:37:12 +08:00
CaIon
1382ec4f20 fix(adaptor): optimize multipart form handling and resource management 2025-08-12 19:57:56 +08:00
Calcium-Ion
9ec326714e Merge pull request #1569 from duyazhe/codex/cloudflare-responses
feat: add responses support for cloudflare
2025-08-12 14:13:14 +08:00
nekohy
5478d2fb59 fix: zhipu_v4 thinking 2025-08-11 21:37:10 +08:00
CaIon
32978f9cd9 feat: Simplify response handling by returning raw response body directly 2025-08-11 20:07:24 +08:00
CaIon
ce74e94fc7 feat: Refactor Gemini tools handling to support JSON raw message format 2025-08-11 19:48:04 +08:00
CaIon
a80ecb8896 feat: Refactor model handling to use UpstreamModelName for request processing 2025-08-11 17:32:58 +08:00
CaIon
37f0383941 feat: Update request URL handling for Claude relay format in adaptor #1557 2025-08-11 17:17:56 +08:00
CaIon
be77f3d763 feat: Update Azure responses API version handling in adaptor 2025-08-11 16:34:07 +08:00
duyazhe
8df5a45805 feat: add responses support for cloudflare 2025-08-11 15:29:16 +08:00
CaIon
8907e5cf6d feat: Add ChannelOtherSettings to manage additional channel configurations 2025-08-10 20:21:30 +08:00
Calcium-Ion
c59253ea6e Merge pull request #1537 from RedwindA/feat/support-native-gemini-embedding
feat: 支持原生Gemini Embedding格式
2025-08-10 10:26:46 +08:00
CaIon
4c0c9ffd0a feat: add AWS invoke error handling and new error code 2025-08-09 19:26:41 +08:00
RedwindA
f5a52bc5b5 feat: update dto for embeddings 2025-08-09 18:31:56 +08:00