Commit Graph

829 Commits

Author SHA1 Message Date
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
CaIon
c7281a353f fix(env): update STREAMING_TIMEOUT default value to 300 seconds 2025-08-12 19:58:04 +08:00
CaIon
1382ec4f20 fix(adaptor): optimize multipart form handling and resource management 2025-08-12 19:57:56 +08:00
IcedTangerine
9717af7dcd Merge pull request #1553 from feitianbubu/pr/add-jimeng-officail-api
feat: add jimeng video official api
2025-08-12 16:32:49 +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
feitianbubu
73609f50d0 feat: add jimeng video official api 2025-08-10 16:54:44 +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
RedwindA
1dcb9a01ce Merge branch 'alpha' into 'feat/support-native-gemini-embedding' 2025-08-09 18:05:11 +08:00
CaIon
f2dbdbc445 feat: update relay-text to conditionally include usage based on StreamOptions #696 2025-08-09 17:51:49 +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
Calcium-Ion
2c4dc44661 Merge pull request #1500 from antecanis8/gemini_batchembedcontents
fix: Gemini embedding model only embeds the first text in a batch
2025-08-09 11:42:08 +08:00
RedwindA
74057324b2 fix typo; add ParamOverride for Gemini Embedding 2025-08-09 01:07:48 +08:00
RedwindA
8127ad9929 feat: support native Gemini Embedding 2025-08-09 00:27:33 +08:00
Yincmewy
e7d91d018d feats:replace GLM-4v authentication headers to support customize api key 2025-08-08 23:26:29 +08:00
CaIon
9682c46cc4 feat: implement moonshot adaptor for request handling and response processing 2025-08-08 17:28:21 +08:00
CaIon
5b5b97eb30 feat: 完善格式抓换,修复gemini渠道和openai渠道在claude code中使用的问题 2025-08-08 16:45:37 +08:00
Calcium-Ion
c144bc7f91 Merge pull request #1524 from feitianbubu/pr/fix-last-resp
fix: ensure last message is sent successfully
2025-08-08 14:55:47 +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
e81113e488 feat: add support for openrouter reasoning efforts in request handling 2025-08-08 13:04:33 +08:00
CaIon
c833e07ee3 feat: add support for gpt-5 models and adjust temperature settings
- Updated the model list to include various gpt-5 variants.
- Enhanced the ConvertOpenAIRequest function to handle gpt-5 model temperature settings based on specific model prefixes.
- Adjusted default cache and model ratios for new gpt-5 models.
2025-08-08 10:43:07 +08:00
HynoR
660b129b75 feat: sync gpt-5 model ratio and support new reasoning effort 2025-08-08 09:11:28 +08:00
feitianbubu
e434c0c9e3 fix: ensure last message is sent successfully 2025-08-08 08:38:09 +08:00
Calcium-Ion
cdc6ab61df Merge pull request #1518 from RedwindA/fix/disable-gemini-sse
Fix/disable-gemini-ping
2025-08-07 20:44:24 +08:00
CaIon
ef2bed2fe7 feat: enhance Adaptor to support multiple relay modes in request handling 2025-08-07 19:30:42 +08:00
CaIon
deb6fbbe21 feat: implement ConvertClaudeRequest method in baidu_v2 Adaptor 2025-08-07 19:19:59 +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
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
c4666934be Revert "feat: update Usage struct to support dynamic token handling with ceil function #1503"
This reverts commit 97b8d7de9e.
2025-08-07 16:22:40 +08:00
CaIon
a4b02107dd feat: update MaxTokens handling 2025-08-07 16:15:59 +08:00
CaIon
97b8d7de9e feat: update Usage struct to support dynamic token handling with ceil function #1503 2025-08-07 15:40:12 +08:00
feitianbubu
ea7fd9875b feat: enable thinking mode on ali thinking model 2025-08-07 11:59:54 +08:00
RedwindA
342bf59c91 fix: 调整Disable Ping标志的设置位置 2025-08-07 06:18:22 +08:00
CaIon
2e41362f2e fix: update budget calculation logic in relay-gemini to use clamping function 2025-08-06 16:25:48 +08:00
CaIon
6960a06322 feat: enhance ThinkingAdaptor with effort-based budget clamping and extra body handling 2025-08-06 16:20:38 +08:00
CaIon
4f6d16e365 feat: add reasoning support for Openrouter requests with "-thinking" suffix 2025-08-06 12:50:26 +08:00
Calcium-Ion
f1faa08c1e Merge pull request #1508 from wzxjohn/feature/aws_new_apikey_support
feat: support aws bedrock apikey
2025-08-06 12:04:28 +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