Commit Graph

232 Commits

Author SHA1 Message Date
CaIon
7e698f658a fix(pre_consume_quota): improve error messages for insufficient user quota 2025-08-28 13:57:16 +08:00
CaIon
d1f3f2c395 fix(token_counter): update token counting logic to handle media token conditions 2025-08-27 17:11:33 +08:00
CaIon
d92c9db61c fix(image): add error handling for empty base64 string in image decoding 2025-08-27 16:38:32 +08:00
Calcium-Ion
59a5cb8d32 Merge pull request #1579 from wzxjohn/hotfix/openai_claude_convert
fix(adaptor): missing first text delta while convert OpenAI to Claude
2025-08-26 20:37:54 +08:00
CaIon
a69f166e9e feat: add SaveWithoutKey method to Channel and update status saving logic 2025-08-25 11:20:16 +08:00
Calcium-Ion
87d0d12d39 Merge pull request #1647 from aotsukiqx/main
fix: update channel.go fix #1641
2025-08-25 10:25:06 +08:00
aotsuki
3b50fcb72b Update channel.go 2025-08-24 11:39:38 +08:00
CaIon
22125a6dd8 fix: correct argument passing in DoDownloadRequest for MIME type retrieval 2025-08-16 15:03:42 +08:00
CaIon
3a90d5054c feat: implement file type detection from URL with enhanced MIME type handling 2025-08-16 14:56:29 +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
215546a805 feat: 优化ac自动机 2025-08-15 16:54:26 +08:00
yyhhyyyyyy
ccd1930838 Merge remote-tracking branch 'origin/alpha' into fix/openrouter-custom-ratio-billing 2025-08-15 14:58:42 +08:00
CaIon
9da13fdabe refactor: enhance logging messages for user quota handling in pre-consume logic 2025-08-15 14:08:15 +08:00
CaIon
07137e6bb8 refactor: update token type handling and improve token counting logic 2025-08-15 13:28:03 +08:00
CaIon
8eb17f24bb refactor: improve request type validation and enhance sensitive information masking 2025-08-15 13:20:36 +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
112de0b6a6 refactor: enhance quota handling and logging for pre-consume operations 2025-08-14 21:30:03 +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
yyhhyyyyyy
7d2a9469f0 fix: prevent OpenRouter cache calculation with custommodel ratios 2025-08-14 17:10:36 +08:00
wzxjohn
c2e49f2b2a fix(adaptor): missing first text delta while convert OpenAI to Claude 2025-08-13 09:57:06 +08:00
CaIon
ce74e94fc7 feat: Refactor Gemini tools handling to support JSON raw message format 2025-08-11 19:48:04 +08:00
CaIon
05af05e449 feat: add system prompt override functionality in channel settings and request handling #1468 2025-08-09 12:53:06 +08:00
CaIon
5b5b97eb30 feat: 完善格式抓换,修复gemini渠道和openai渠道在claude code中使用的问题 2025-08-08 16:45:37 +08:00
CaIon
f69a4f7153 feat: enhance request handling to support tool calls and improve stream options 2025-08-08 13:47:39 +08:00
CaIon
b8b59a134e feat: support deepseek claude format (convert) 2025-08-07 19:01:49 +08:00
CaIon
d37af13b33 feat: support qwen claude format 2025-08-07 18:32:31 +08:00
creamlike1024
502c5dde9c Merge remote-tracking branch 'origin/alpha' into ConvertGeminiRequest 2025-08-01 22:42:48 +08:00
creamlike1024
689dbfe71a feat: convert gemini format to openai chat completions 2025-08-01 22:23:35 +08:00
Seefs
3b34afa8c9 Revert "feat: add Claude Code channel support with OAuth integration" 2025-07-31 22:08:16 +08:00
Calcium-Ion
7eccf42513 Merge pull request #1445 from seefs001/feature/claude-code
feat: add Claude Code channel support with OAuth integration
2025-07-31 21:28:23 +08:00
Seefs
2bc8de398e fix: handle authorization code format in ExchangeCode function and update placeholder in EditChannelModal 2025-07-31 21:27:24 +08:00
Seefs
c45676e3ca Merge branch 'alpha' into feature/claude-code
# Conflicts:
#	web/src/components/table/channels/modals/EditChannelModal.jsx
2025-07-31 21:19:43 +08:00
CaIon
563d056ff7 refactor: update error handling to support dynamic error types 2025-07-31 21:16:01 +08:00
Xyfacai
9055698b4f feat: 显式指定 error 跳过重试 2025-07-30 22:35:31 +08:00
CaIon
efb7c6a15e fix: auto ban 2025-07-29 23:08:16 +08:00
Seefs
1389cc7acd feat: add claude code channel 2025-07-26 18:06:46 +08:00
CaIon
6ddeab2f2f fix(adaptor): enhance response handling and error logging for Claude format 2025-07-23 20:59:56 +08:00
CaIon
c73b5886b9 feat: support ollama claude format 2025-07-23 20:01:03 +08:00
Xyfacai
76855bc28a fix(price): 未设置价格,错误返回模型价格匹配的名字 2025-07-20 10:12:36 +08:00
CaIon
386c254682 fix: set ErrorType to OpenAIError in RelayErrorHandler for better error categorization 2025-07-19 11:15:34 +08:00
feitianbubu
b1cf5d7705 fix: usage cost(any) to support claude and gemini 2025-07-16 16:58:34 +08:00
CaIon
9881bfc3c9 feat(logs): add multi-key support in LogsTable and enhance log info generation 2025-07-12 15:14:55 +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
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
aa0edd8dce Merge pull request #1321 from iszcz/main
支持Midjourney视频任务和图片编辑
2025-07-05 15:28:33 +08:00
CaIon
14cca53ec8 🔧 refactor(endpoint types): comment out unused endpoint types in constants 2025-07-04 15:53:46 +08:00