Commit Graph

149 Commits

Author SHA1 Message Date
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
CaIon
28295e0168 feat: restrict automatic channel testing to master node only 2025-11-06 21:12:59 +08:00
CaIon
e7012e7e0a fix: reduce auto test channel sleep duration to 1 minute 2025-10-28 23:35:20 +08:00
Seefs
25de94e292 fix: test channel frequency (#2119) 2025-10-28 23:23:24 +08:00
Seefs
5010f2d004 format: package name -> github.com/QuantumNous/new-api (#2017) 2025-10-11 15:30:09 +08:00
anime
ec4603942f fix(channel): move log statement after sleep in auto-test loop 2025-10-11 00:59:13 +08:00
anime
bbb160510e fix(channel): handle dynamic frequency updates 2025-10-11 00:53:26 +08:00
anime
cac0be2e66 fix(channel): handle dynamic frequency updates
- replace infinite sleep loop with time.Ticker to avoid goroutine leaks
- add immediate initial test execution before ticker starts
- implement frequency change detection and ticker recreation
- ensure proper ticker cleanup when loop exits or feature disabled
2025-10-11 00:34:15 +08:00
Seefs
015d488069 fix: test model #1993 2025-10-10 15:01:24 +08:00
feitianbubu
0e6ccea09b refactor: simplify unsupported test channel types 2025-10-03 12:41:39 +08:00
feitianbubu
c25ca9a791 feat: add doubao video generate 2025-10-02 04:00:43 +08:00
CaIon
63bbd9e3c3 feat: add endpoint type selection to channel testing functionality 2025-09-30 16:52:14 +08:00
huanghejian
97755c2e94 fix: VolcEngine doubao-seedream-4-0-250828 2025-09-16 14:30:12 +08:00
Xyfacai
3f9adc9992 fix: openai 格式请求 claude 没计费 create cache token 2025-09-10 15:30:23 +08:00
CaIon
1bbabda081 feat(monitor_setting): implement automatic channel testing configuration 2025-09-03 14:00:52 +08:00
CaIon
3c30b7c4cb fix: refactor processChannelError to use goroutine for asynchronous handling 2025-08-16 15:15:19 +08:00
CaIon
dba74e5b05 refactor: add email masking function and enhance RelayInfo logging
This commit introduces a new function, MaskEmail, to mask user email addresses in logs, preventing PII leakage. Additionally, the RelayInfo logging has been updated to utilize this new masking function, ensuring sensitive information is properly handled. The channel test logic has also been improved to dynamically determine the relay format based on the request path.
2025-08-15 12:50:27 +08:00
CaIon
f6f9e73fa3 refactor: improve channel base URL handling and enhance RelayInfo logging 2025-08-14 22:15:18 +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
IcedTangerine
76753cea7d Merge pull request #1519 from feitianbubu/pr/fix-qwen3-thinking-test
feat: enable thinking mode on ali thinking model
2025-08-07 17:39:27 +08:00
CaIon
a4b02107dd feat: update MaxTokens handling 2025-08-07 16:15:59 +08:00
feitianbubu
ea7fd9875b feat: enable thinking mode on ali thinking model 2025-08-07 11:59:54 +08:00
CaIon
590e6db670 fix: 修复被禁用的渠道无法测试的问题 2025-07-31 10:56:51 +08:00
CaIon
efb7c6a15e fix: auto ban 2025-07-29 23:08:16 +08:00
feitianbubu
4378e0f96d feat: add vidu video channel 2025-07-24 10:14:25 +08:00
Calcium-Ion
db159451df Merge pull request #1368 from RedwindA/fix/embedding-test
fix: 修复Gemini渠道的向量模型测试
2025-07-17 19:16:10 +08:00
Xyfacai
38c5e0e9f4 refactor: format api page query and err result 2025-07-14 22:03:22 +08:00
RedwindA
bc65c82745 🎨 feat(channel-test): Enhance request conversion for Embedding models and update input type 2025-07-14 16:59:48 +08:00
CaIon
9fd92977c7 feat(channel): improve channel cache handling and add error checks for disabled channels 2025-07-12 14:20:59 +08:00
CaIon
dc5e4be403 feat(channel): implement thread-safe polling 2025-07-12 11:17:08 +08:00
CaIon
8e11b67ece feat(channel): enhance channel status management 2025-07-10 17:49:53 +08:00
CaIon
1437ceaa56 Merge branch 'alpha' into refactor_error
# Conflicts:
#	controller/channel.go
#	middleware/distributor.go
#	model/channel.go
#	model/user.go
#	model/user_cache.go
#	relay/common/relay_info.go
2025-07-10 15:11:55 +08:00
CaIon
4a9ca4209a refactor: Introduce standardized API error
This commit refactors the application's error handling mechanism by introducing a new standardized error type, `types.NewAPIError`. It also renames common JSON utility functions for better clarity.

Previously, internal error handling was tightly coupled to the `dto.OpenAIError` format. This change decouples the internal logic from the external API representation.

Key changes:
- A new `types.NewAPIError` struct is introduced to serve as a canonical internal representation for all API errors.
- All relay adapters (OpenAI, Claude, Gemini, etc.) are updated to return `*types.NewAPIError`.
- Controllers now convert the internal `NewAPIError` to the client-facing `OpenAIError` format at the API boundary, ensuring backward compatibility.
- Channel auto-disable/enable logic is updated to use the new standardized error type.
- JSON utility functions are renamed to align with Go's standard library conventions (e.g., `UnmarshalJson` -> `Unmarshal`, `EncodeJson` -> `Marshal`).
2025-07-10 15:02:40 +08:00
CaIon
60bfadb84d 🔧 refactor(channel): add validation for CHANNEL_TEST_FREQUENCY in automatic tests 2025-07-10 11:31:07 +08:00
Xiangyuan-liu
db98c0f4b1 refactor: log params and channel params
refactor: log params and channel params
2025-07-07 14:26:37 +08:00
Calcium-Ion
5cb4c4e644 Merge pull request #1314 from vickyyd/main
修复使用gemini-balance作为上游时,测试gemini2.5pro模型时出现的错误问题
2025-07-03 15:53:32 +08:00
CaIon
f14f4eaf1a feat: refactor environment variable initialization and introduce new constant types for API and context keys 2025-07-03 13:10:25 +08:00
kikii16
400a7e6e5b 修复gemini-balance测试gemini2.5pro的错误问题 2025-06-29 13:36:19 +08:00
skynono
221d2b5552 feat: add video channel jimeng 2025-06-27 17:08:20 +08:00
CaIon
32366d1e1b refactor: streamline price calculation in RelaySwapFace and RelayMidjourneySubmit functions 2025-06-22 17:52:48 +08:00
Calcium-Ion
e8da9d7dd7 Merge pull request #1270 from QuantumNous/refactor_model_mapping
feat: implement new handlers for relay processing
2025-06-20 16:12:41 +08:00
CaIon
13277cf838 feat: implement new handlers for audio, image, embedding, and responses processing
- Added new handlers: AudioHelper, ImageHelper, EmbeddingHelper, and ResponsesHelper to manage respective requests.
- Updated ModelMappedHelper to accept request parameters for better model mapping.
- Enhanced error handling and validation across new handlers to ensure robust request processing.
- Introduced support for new relay formats in relay_info and updated relevant functions accordingly.
2025-06-20 16:02:23 +08:00
skynono
5d9cf11466 feat: add unsupported test case for kling channel 2025-06-19 11:53:47 +08:00
CaIon
4ec7012974 feat: enhance group ratio handling in pricing calculations 2025-06-17 21:05:35 +08:00
Calcium-Ion
158d621fd7 Merge pull request #1207 from QuantumNous/user_group_ratio
feat: 分组特殊倍率
2025-06-13 01:25:46 +08:00
creamlike1024
2a0bf7f991 feat: 分组特殊倍率 2025-06-11 23:46:59 +08:00
CaIon
b23416bbb4 🔧 fix(channel-test): ensure proper state reset to prevent deadlocks 2025-06-10 03:54:18 +08:00
Xyfacai
8343fe0740 refactor: message content 改成 any
refactor: message content 改成 any
2025-06-07 23:47:22 +08:00
creamlike1024
b16c05ead4 fix: remove apikey from test channel log, close #1000 2025-04-25 17:08:26 +08:00