Commit Graph

170 Commits

Author SHA1 Message Date
Xyfacai
9055698b4f feat: 显式指定 error 跳过重试 2025-07-30 22:35:31 +08:00
CaIon
2cb7b9ae62 fix: improve error messaging and JSON schema handling in distributor and relay components 2025-07-26 12:11:20 +08:00
feitianbubu
d10c7a3548 fix: playground chat vip group 2025-07-24 09:38:00 +08:00
CaIon
127d1d692f fix(distributor): add validation for model name in channel selection 2025-07-23 16:46:06 +08:00
CaIon
5418bb3b7c fix: improve error messages for channel retrieval failures in distributor and relay 2025-07-23 16:32:52 +08:00
feitianbubu
b3c4d97286 chore: opt video channel and platform 2025-07-22 20:14:24 +08:00
t0ng7u
d2ef70f6b0 feat(kling): send both model_name and model fields for upstream compatibility
Some upstream Kling deployments still expect the legacy `model` key
instead of `model_name`.
This change adds the `model` field to `requestPayload` and populates it
with the same value as `model_name`, ensuring the generated JSON works
with both old and new versions.

Changes:
• Added `Model string "json:\"model,omitempty\""` to `requestPayload`
• Set `Model` alongside `ModelName` in `convertToRequestPayload`
• Updated comments to clarify compatibility purpose

Result:
Kling task requests now contain both `model_name` and `model`, removing
integration issues with upstreams that only recognize one of the keys.
2025-07-22 01:21:56 +08:00
t0ng7u
200faadb4a feat(middleware): enhance Kling request adapter to support both 'model' and 'model_name' fields
Previously, the KlingRequestConvert middleware only extracted model name from
the 'model_name' field, which caused 503 errors when requests used the 'model'
field instead. This enhancement improves API compatibility by supporting both
field names.

Changes:
- Modified KlingRequestConvert() to check for 'model' field if 'model_name' is empty
- Maintains backward compatibility with existing 'model_name' usage
- Fixes "no available channels for model" error when model field was not recognized

This resolves issues where valid Kling API requests were failing due to field
name mismatches, improving the overall user experience for video generation APIs.
2025-07-22 00:06:29 +08:00
Calcium-Ion
4a46b50e90 Merge pull request #1349 from feitianbubu/pr/fix-kling-image-mode-name
fix: KlingText2VideoRequest image and model_name
2025-07-18 20:47:10 +08:00
CaIon
c773584ecd fix: 修复playground优先级失效 2025-07-17 22:26:38 +08:00
feitianbubu
79522d7688 fix: playground chat 2025-07-16 23:47:59 +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
skynono
fec1016c97 fix: KlingText2VideoRequest image and model_name
feat: add video channel kling swag
2025-07-09 07:34:04 +00: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
cf11a22c3a 🔧 refactor(auth, channel, context): improve context setup and validation for multi-key channels 2025-07-06 12:37:56 +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
skynono
111dc18d26 feat: video action to constant 2025-06-27 23:19:34 +08:00
skynono
221d2b5552 feat: add video channel jimeng 2025-06-27 17:08:20 +08:00
Xyfacai
416a357c34 Merge pull request #1291 from feitianbubu/pr/add-origin-kling-api
feat: add origin kling api
2025-06-27 16:08:03 +08:00
CaIon
04d525e317 🚀 feat(auth): support new model API paths in authentication and routing
- Updated TokenAuth middleware to handle requests for both `/v1beta/models/` and `/v1/models/`.
- Adjusted distributor middleware to recognize the new model path.
- Enhanced relay mode determination to include the new model path.
- Added route for handling POST requests to `/models/*path`.

These changes ensure compatibility with the new model API structure, improving the overall routing and authentication flow.
2025-06-25 00:19:38 +08:00
skynono
34693e338f feat: add origin kling api 2025-06-23 22:36:23 +08:00
CaIon
32366d1e1b refactor: streamline price calculation in RelaySwapFace and RelayMidjourneySubmit functions 2025-06-22 17:52:48 +08:00
skynono
d7ed0214ad feat: add video channel kling 2025-06-19 11:53:42 +08:00
Apple\Apple
175ea56fdd 🚚 Refactor(ratio_setting): refactor ratio management into standalone ratio_setting package
Summary
• Migrated all ratio-related sources into `setting/ratio_setting/`
  – `model_ratio.go` (renamed from model-ratio.go)
  – `cache_ratio.go`
  – `group_ratio.go`
• Changed package name to `ratio_setting` and relocated initialization (`ratio_setting.InitRatioSettings()` in main).
• Updated every import & call site:
  – Model / cache / completion / image ratio helpers
  – Group ratio helpers (`GetGroupRatio*`, `ContainsGroupRatio`, `CheckGroupRatio`, etc.)
  – JSON-serialization & update helpers (`*Ratio2JSONString`, `Update*RatioByJSONString`)
• Adjusted controllers, middleware, relay helpers, services and models to reference the new package.
• Removed obsolete `setting` / `operation_setting` imports; added missing `ratio_setting` imports.
• Adopted idiomatic map iteration (`for key := range m`) where value is unused.
• Ran static checks to ensure clean build.

This commit centralises all ratio configuration (model, cache and group) in one cohesive module, simplifying future maintenance and improving code clarity.
2025-06-18 18:00:49 +08:00
creamlike1024
c6a9df67b1 feat: auto分组 2025-06-16 22:15:12 +08:00
CaIon
ad4d3efd2e feat(middleware): add HTTP statistics middleware 2025-06-10 19:29:32 +08:00
RedwindA
5e88e76001 feat: 支持从 x-goog-api-key header 中获取授权密钥 2025-06-04 15:41:25 +08:00
creamlike1024
75d859dce2 gemini text generation 2025-05-26 13:34:41 +08:00
Calcium-Ion
bb18f64d1f Merge pull request #1067 from QuantumNous/coze
Coze 渠道
2025-05-16 16:11:02 +08:00
CaIon
f88b7cd7f2 fix: update model selection logic for image edits in distributor middleware 2025-05-14 17:01:50 +08:00
creamlike1024
5e8217db0f use channel bot id 2025-05-13 22:23:38 +08:00
creamlike1024
c483c7df5f Merge branch 'tbphp_model_request_rate_limit_for_group' of github.com:tbphp/new-api into tbphp-tbphp_model_request_rate_limit_for_group 2025-05-08 23:16:06 +08:00
CaIon
54f69c7d80 feat: add AzureNoRemoveDotTime constant and update channel handling #1044
- Introduced a new constant `AzureNoRemoveDotTime` in `constant/azure.go` to manage model name formatting for channels created after May 10, 2025.
- Updated `distributor.go` to set `channel_create_time` in the context.
- Modified `adaptor.go` to conditionally remove dots from model names based on the channel creation time.
- Enhanced `relay_info.go` to include `ChannelCreateTime` in the `RelayInfo` struct.
- Updated English localization files to reflect changes in model name handling for new channels.
2025-05-08 22:39:55 +08:00
tbphp
b648b3cf98 fix: 缩进修复还原 2025-05-05 23:53:05 +08:00
tbphp
cd40bdbdc6 refactor: 调整代码,符合项目现有规范 2025-05-05 19:32:22 +08:00
tbphp
2a0e1ab914 fix: Redis limit ignoring max eq 0 2025-05-05 12:55:48 +08:00
tbphp
c9ce1210be feat: 优化代码,去除多余注释和修改 2025-05-05 11:34:57 +08:00
tbphp
b32ed55624 feat: 增加分组速率功能 2025-05-05 07:31:54 +08:00
CaIon
1ab9892090 Merge remote-tracking branch 'new-api/main' into gpt-image
# Conflicts:
#	relay/relay-image.go
2025-04-26 15:54:08 +08:00
xyfacai
873ebcf0c7 feat: support /images/edit
(cherry picked from commit 1c0a1238787d490f02dd9269b616580a16604180)
2025-04-26 15:44:56 +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
JoeyLearnsToCode
f00ac5f27b feat: Add Parameters Override 2025-03-29 14:39:39 +08:00
1808837298@qq.com
78fc3a191c feat: claude relay 2025-03-12 21:31:46 +08:00
1808837298@qq.com
fa20af817f refactor: Improve model request rate limit middleware execution 2025-03-06 16:32:11 +08:00
1808837298@qq.com
3f1e340391 refactor: Update rate limit configuration to use dynamic expiration duration 2025-03-02 17:34:39 +08:00
1808837298@qq.com
d04d78a116 refactor: Enhance user context and quota management
- Add new context keys for user-related information
- Modify user cache and authentication middleware to populate context
- Refactor quota and notification services to use context-based user data
- Remove redundant database queries by leveraging context information
- Update various components to use new context-based user retrieval methods
2025-02-25 20:56:16 +08:00
1808837298@qq.com
1763145fea feat: Add model request rate limiting functionality 2025-02-24 16:20:55 +08:00
1808837298@qq.com
cc61f85bdd fix: Remove redundant error handling in distributor and relay modules 2025-02-19 18:47:28 +08:00