Commit Graph

397 Commits

Author SHA1 Message Date
CaIon
28ededaf8e fix: WriteContentType panic 2025-07-30 20:31:51 +08:00
CaIon
9afb9b594d feat: 错误内容脱敏 2025-07-30 19:08:35 +08:00
feitianbubu
ddb497a4a7 fix: page query param is p 2025-07-21 15:39:16 +08:00
IcedTangerine
af65271804 Merge pull request #1352 from wzxjohn/feature/simple_stripe
Add stripe support and fix wrong top up loading state
2025-07-18 22:00:52 +08:00
Calcium-Ion
09e6dbcc8a Merge pull request #1190 from feitianbubu/fix-nil-request-id
fix: default request ID to 'SYSTEM' for background tasks
2025-07-18 20:48:15 +08:00
Calcium-Ion
066d4a7906 Merge pull request #1363 from feitianbubu/pr/add-jimeng-image
feat: 增加即梦生图功能
2025-07-18 20:45:49 +08:00
wzxjohn
252aff1203 Merge branch 'alpha' into feature/simple_stripe 2025-07-16 10:39:11 +08:00
Xyfacai
38c5e0e9f4 refactor: format api page query and err result 2025-07-14 22:03:22 +08:00
feitianbubu
43980b3ad1 feat: add jimeng image 2025-07-13 13:36:33 +08:00
wzxjohn
df69147da9 fix: for AI review problems 2025-07-10 20:55:43 +08:00
wzxjohn
81d474ba3c feat: add stripe pay api support 2025-07-10 16:29:38 +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
CaIon
d7e15a9677 feat(tokens): add cherryConfig support for URL generation and base64 encoding 2025-07-06 20:56:09 +08:00
CaIon
cf11a22c3a 🔧 refactor(auth, channel, context): improve context setup and validation for multi-key channels 2025-07-06 12:37:56 +08:00
CaIon
95775a5a52 feat(endpoint types): add support for image generation models in endpoint type handling 2025-07-05 14:14:40 +08:00
CaIon
14cca53ec8 🔧 refactor(endpoint types): comment out unused endpoint types in constants 2025-07-04 15:53:46 +08:00
t0ng7u
dd9a1534e0 🔌 feat(api): extend endpoint type support & expose in pricing UI
* backend
  - constant/endpoint_type.go
    • Add EndpointTypeMidjourney, EndpointTypeSuno, EndpointTypeKling, EndpointTypeJimeng.
  - common/endpoint_type.go
    • Map Midjourney / MidjourneyPlus, SunoAPI, Kling, Jimeng channel types to the new endpoint types.

* frontend
  - ModelPricing.js
    • Add “Supported Endpoint Type” column.
    • Implement renderSupportedEndpoints with `stringToColor` for consistent tag colors.

These changes allow `/api/pricing` and model lists to return accurate
`supported_endpoint_types` covering all non-OpenAI providers and display
them clearly in the UI.

No breaking changes.
2025-07-04 03:15:34 +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
CaIon
41d20484f9 Merge branch 'main' into alpha 2025-07-01 13:15:47 +08:00
CaIon
2f04ab0daf feat: enhance environment configuration and resource initialization 2025-07-01 13:13:30 +08:00
CaIon
e2c34bdeb9 🐛 fix: refactor JSON unmarshalling across multiple handlers to use UnmarshalJson and UnmarshalJsonStr for consistency
This update replaces instances of DecodeJson and DecodeJsonStr with UnmarshalJson and UnmarshalJsonStr in various relay handlers, enhancing code consistency and clarity in JSON processing. The changes improve maintainability and align with recent refactoring efforts in the codebase.
2025-06-28 00:02:07 +08:00
CaIon
aae9e81c20 🐛 fix: refactor response body handling in multiple relay handlers to utilize IOCopyBytesGracefully 2025-06-27 23:35:56 +08:00
CaIon
5178e563be feat: introduce IOCopyBytesGracefully function for streamlined response body handling
This update adds the IOCopyBytesGracefully function to the common package, which simplifies the process of copying response bodies in the OpenAI handlers. It enhances error handling and ensures proper resource management by encapsulating the logic for setting headers and writing response data. The OpenAI handlers have been refactored to utilize this new function, improving code clarity and maintainability.
2025-06-27 22:36:12 +08:00
CaIon
ae586e1be9 feat: add CloseResponseBodyGracefully function to handle HTTP response body closure 2025-06-27 21:37:13 +08:00
skynono
221d2b5552 feat: add video channel jimeng 2025-06-27 17:08:20 +08:00
Xiangyuan-liu
b206a7c683 feat: 优化分页组件 2025-06-25 18:42:19 +08:00
Calcium-Ion
c74a86d14d Merge pull request #1267 from t0ng7u/feature/upstream-ratio-sync
🔄 feat(ratio-sync): introduce upstream ratio synchronisation feature #1220
2025-06-20 16:22:00 +08:00
skynono
d7ed0214ad feat: add video channel kling 2025-06-19 11:53:42 +08:00
Apple\Apple
8748425aa2 🚀 feat(ratio-sync): major refactor & UX overhaul for Upstream Ratio Sync 2025-06-19 08:57:34 +08:00
CaIon
2a1ed60738 Merge branch 'alpha' 2025-06-17 14:49:13 +08:00
chenjm
ab5dfd8d97 fix(audio): :bugs: fix webm audio strconv.ParseFloat: parsing "N/A" 2025-06-17 10:04:36 +08:00
chenjm
99dacb1d4b fix(audio): :bugs: fix webm audio strconv.ParseFloat: parsing "N/A" 2025-06-17 09:21:56 +08:00
RedwindA
e34d3c2160 🔧 fix(redis): only set expiration if greater than 0 in RedisHSetObj 2025-06-17 02:37:19 +08:00
CaIon
4371717c78 fix: Resolving conflicts caused by mixing multiple databases 2025-06-14 17:51:05 +08:00
skynono
56646904af fix: default request ID to 'SYSTEM' for background tasks 2025-06-09 22:13:21 +08:00
RedwindA
098c1e8829 refactor: rename RedisHDelObj to RedisDelKey and update references 2025-06-05 21:17:57 +08:00
RedwindA
15607996e6 fix: change RedisHDelObj to use Del instead of HDel 2025-06-05 20:42:56 +08:00
creamlike1024
cd8a2f85db add coze request 2025-05-13 12:52:22 +08:00
han shi
a0017f2235 feat: 增加sendcloud邮件服务器的支持 (#947)
* 增加sendcloud邮件服务器的支持

* 调整代码结构

* Used slince.Contains function

---------

Co-authored-by: shih <shih@knownsec.com>
2025-04-25 18:17:46 +08:00
霍雨佳
e121e77265 Refactor: Optimize the token bucket algorithm, specifically the New method in common/imiterlimiter.go.
Solution: Remove Redis ping. When printing exceptions, use SysLog to print and add additional logging information.
2025-04-16 16:36:07 +08:00
霍雨佳
5aa2076e18 Refactor: Optimize the request rate limiting for ModelRequestRateLimitCount.
Reason: The original steps 1 and 3 in the redisRateLimitHandler method were not atomic, leading to poor precision under high concurrent requests. For example, with a rate limit set to 60, sending 200 concurrent requests would result in none being blocked, whereas theoretically around 140 should be intercepted.
Solution: I chose not to merge steps 1 and 3 into a single Lua script because a single atomic operation involving read, write, and delete operations could suffer from performance issues under high concurrency. Instead, I implemented a token bucket algorithm to optimize this, reducing the atomic operation to just read and write steps while significantly decreasing the memory footprint.
2025-04-16 10:33:43 +08:00
CaIon
577b18a1a1 feat: enhance file handling and logging in the application 2025-04-11 16:23:54 +08:00
CaIon
60a9bd45c6 feat: add xAI handling and response processing 2025-04-10 17:20:59 +08:00
Calcium-Ion
b40bf7c812 Merge pull request #953 from wkxu/main
fix: .env文件配置DEBUG=true等参数不起作用的fix
2025-04-10 16:14:11 +08:00
HynoR
4622c17c83 feat: add xai channel
feat: add xai channel

feat: add xai channel
2025-04-10 13:04:43 +08:00
wkxu
54c5c3118b refactor: 把common/instants.go里的从Getenv获取的参数,放到init.go的LoadEnv函数里获取
把constant/env.go里的从Getenv获取的参数,放到env.go的InitEnv函数里获取。以避免.env文件配置参数不起作用的情况
2025-04-10 09:02:19 +08:00
1808837298@qq.com
62dc82638d feat: Introduce JSON decoding utility functions and update error handling in Claude and OpenAI response structures 2025-03-16 18:34:39 +08:00
1808837298@qq.com
78fc3a191c feat: claude relay 2025-03-12 21:31:46 +08:00