Commit Graph

1069 Commits

Author SHA1 Message Date
Seefs
04954f1058 Revert "Fix/aws non empty text" 2026-03-02 19:40:53 +08:00
Calcium-Ion
0d81053e56 fix: tool responses (#3080) 2026-03-02 19:23:50 +08:00
Seefs
7cc8ec2c91 fix: tool responses 2026-03-02 19:22:37 +08:00
Seefs
ad326beb10 Merge pull request #3066 from seefs001/fix/aws-header-override
Fix/aws header override
2026-03-02 18:54:56 +08:00
Seefs
2df604bbad fix: default empty input_json_delta arguments to {} for tool call parsing 2026-03-02 15:51:55 +08:00
Seefs
da11617776 fix: preserve tool_use on malformed tool arguments to keep tool_result pairing valid 2026-03-02 15:41:03 +08:00
Seefs
4d6f9a94a3 fix: aws text content blocks must be non-empty 2026-03-02 15:31:37 +08:00
Seefs
2cf3c1836c fix: preserve explicit zero values in native relay requests 2026-03-01 15:47:03 +08:00
CaIon
e22f59e449 feat(gemini): update request structures for Veo predictLongRunning
- Refactored the request URL and body construction methods to align with the Veo predictLongRunning endpoint.
- Introduced new data structures for Veo instances and parameters, replacing the previous Gemini video generation configurations.
- Updated the Vertex adaptor to utilize the new Veo request payload format.
2026-02-28 18:42:54 +08:00
Seefs
8103b4b1a7 Merge pull request #3009 from seefs001/feature/improve-param-override
feat: improve channel override ui/ux
2026-02-28 18:19:40 +08:00
CaIon
32d9ae1f83 feat(gemini): implement video generation configuration and billing estimation
- Added Gemini video generation configuration structures and payloads.
- Introduced functions for parsing and resolving video duration and resolution from metadata.
- Enhanced the Vertex adaptor to support Gemini video generation requests and billing estimation based on duration and resolution.
- Updated model pricing settings for new Gemini video models.
2026-02-28 17:37:08 +08:00
Seefs
a955d4102d refactor(override): simplify header overrides to a lowercase single map 2026-02-25 17:24:18 +08:00
Seefs
3034fb8899 fix: merge runtime and channel header overrides, skip missing source headers 2026-02-25 16:12:34 +08:00
Seefs
58fcd9cbca fix pass_headers 2026-02-25 15:39:49 +08:00
Seefs
0f09dbda2b Merge branch 'upstream-main' into feature/improve-param-override
# Conflicts:
#	relay/channel/api_request_test.go
#	relay/common/override_test.go
#	web/src/components/table/channels/modals/EditChannelModal.jsx
2026-02-25 13:39:54 +08:00
CaIon
8f14687d61 fix: improve multipart form data handling by detecting content type. fix #3007 2026-02-25 12:51:46 +08:00
hekx
b32e1c9ef1 fix: skip Accept-Encoding during header passthrough (#2214) 2026-02-24 09:58:50 +08:00
Calcium-Ion
053ee18637 Merge pull request #2959 from seefs001/fix/gemini-tool-use-token
fix: unify usage mapping and include toolUsePromptTokenCount
2026-02-22 23:35:09 +08:00
Calcium-Ion
f8f3ee29de Merge pull request #2960 from seefs001/feature/minimax-native-claude
feat: minimax native /v1/messages
2026-02-22 23:32:53 +08:00
CaIon
c1b05d3b5a refactor: clean up unused code and improve error logging in adaptor and mjp modules 2026-02-22 22:11:05 +08:00
CaIon
06fe03e34c feat(task): add model redirection, per-call billing, and multipart retry fix for async tasks
1. Async task model redirection (aligned with sync tasks):
   - Integrate ModelMappedHelper in RelayTaskSubmit after model name
     determination, populating OriginModelName / UpstreamModelName on RelayInfo.
   - All task adaptors now send UpstreamModelName to upstream providers:
     - Gemini & Vertex: BuildRequestURL uses UpstreamModelName.
     - Doubao & Ali: BuildRequestBody conditionally overwrites body.Model.
     - Vidu, Kling, Hailuo, Jimeng: convertToRequestPayload accepts RelayInfo
       and unconditionally uses info.UpstreamModelName.
     - Sora: BuildRequestBody parses JSON and multipart bodies to replace
       the "model" field with UpstreamModelName.
   - Frontend log visibility: LogTaskConsumption and taskBillingOther now
     emit is_model_mapped / upstream_model_name in the "other" JSON field.
   - Billing safety: RecalculateTaskQuotaByTokens reads model name from
     BillingContext.OriginModelName (via taskModelName) instead of
     task.Data["model"], preventing billing leaks from upstream model names.

2. Per-call billing (TaskPricePatches lifecycle):
   - Rename TaskBillingContext.ModelName → OriginModelName; add PerCallBilling
     bool field, populated from TaskPricePatches at submission time.
   - settleTaskBillingOnComplete short-circuits when PerCallBilling is true,
     skipping both adaptor adjustments and token-based recalculation.
   - Remove ModelName from TaskSubmitResult; use relayInfo.OriginModelName
     consistently in controller/relay.go for billing context and logging.

3. Multipart retry boundary mismatch fix:
   - Root cause: after Sora (or OpenAI audio) rebuilds a multipart body with a
     new boundary and overwrites c.Request.Header["Content-Type"], subsequent
     calls to ParseMultipartFormReusable on retry would parse the cached
     original body with the wrong boundary, causing "NextPart: EOF".
   - Fix: ParseMultipartFormReusable now caches the original Content-Type in
     gin context key "_original_multipart_ct" on first call and reuses it for
     all subsequent parses, making multipart parsing retry-safe globally.
   - Sora adaptor reverted to the standard pattern (direct header set/get),
     which is now safe thanks to the root fix.

4. Tests:
   - task_billing_test.go: update makeTask to use OriginModelName; add
     PerCallBilling settlement tests (skip adaptor adjust, skip token recalc);
     add non-per-call adaptor adjustment test with refund verification.
2026-02-22 16:33:00 +08:00
CaIon
7d5fc3ff51 refactor(relay): rename RelayTask to RelayTaskFetch and update routing
- Renamed RelayTask function to RelayTaskFetch for clarity.
- Updated routing in relay-router.go and video-router.go to use RelayTaskFetch for fetch operations.
- Enhanced error handling in RelayTaskFetch function.
- Adjusted task data conversion in TaskAdaptor to include task ID.
2026-02-22 16:01:19 +08:00
CaIon
8374a83084 feat(task): add adaptor billing interface and async settlement framework
Add three billing lifecycle methods to the TaskAdaptor interface:
- EstimateBilling: compute OtherRatios from user request before pricing
- AdjustBillingOnSubmit: adjust ratios from upstream submit response
- AdjustBillingOnComplete: determine final quota at task terminal state

Introduce BaseBilling as embeddable no-op default for adaptors without
custom billing. Move Sora/Ali OtherRatios logic from shared validation
into per-adaptor EstimateBilling implementations.

Add TaskBillingContext to persist pricing params (model_price, group_ratio,
other_ratios) in task private data for async polling settlement.

Extract RecalculateTaskQuota as a general-purpose delta settlement
function and unify polling billing via settleTaskBillingOnComplete
(adaptor-first, then token-based fallback).
2026-02-22 16:00:27 +08:00
CaIon
ba25ba88fe refactor(task): extract billing and polling logic from controller to service layer
Restructure the task relay system for better separation of concerns:
- Extract task billing into service/task_billing.go with unified settlement flow
- Move task polling loop from controller to service/task_polling.go (supports Suno + video platforms)
- Split RelayTask into fetch/submit paths with dedicated retry logic (taskSubmitWithRetry)
- Add TaskDto, TaskResponse generics, and FetchReq to dto/task.go
- Add taskcommon/helpers.go for shared task adaptor utilities
- Remove controller/task_video.go (logic consolidated into service layer)
- Update all task adaptors (ali, doubao, gemini, hailuo, jimeng, kling, sora, suno, vertex, vidu)
- Simplify frontend task logs to use new TaskDto response format
2026-02-22 16:00:27 +08:00
Seefs
7633863c96 feat: unify param/header overrides with retry-aware conditions and flexible header operations 2026-02-22 00:45:49 +08:00
wellsgz
86def71df0 feat: add aws claude-sonnet-4-6 model mapping 2026-02-21 13:24:30 +08:00
Seefs
50ed552943 feat: minimax native /v1/messages 2026-02-17 17:27:57 +08:00
Seefs
c97f4524f2 fix: unify usage mapping and include toolUsePromptTokenCount in input tokens 2026-02-17 15:45:14 +08:00
Seefs
8dbc5641ef fix: ignore header passthrough during channel tests 2026-02-12 15:16:24 +08:00
CaIon
29d48e262e feat: refactor request body handling to use BodyStorage for improved efficiency 2026-02-12 01:51:27 +08:00
funkpopo
0aa3dcb56c feat(xai): 为xAI渠道添加/v1/responses支持 (#2897)
* feat(xai): 为xAI渠道添加/v1/responses支持

* Add video generation model to constants

* fix: 修正先前更改中对于grok-3-mini的思考预算和"-search"设计
2026-02-12 00:42:39 +08:00
CaIon
92aca9771f feat: refactor extra_body handling for improved configuration parsing 2026-02-11 22:15:22 +08:00
Calcium-Ion
6c28de8965 Merge pull request #2889 from seefs001/feature/messages2responses
feat: /v1/messages -> /v1/responses
2026-02-08 00:25:27 +08:00
Calcium-Ion
c494c26236 Merge pull request #2887 from seefs001/fix/claude
fix: 补全 streaming message_delta 事件缺失的 input_tokens 和 cache 相关字段
2026-02-08 00:18:04 +08:00
Calcium-Ion
47cdac3e64 Merge pull request #2883 from seefs001/fix/claude-relay-info-input-token
fix: 使用openai兼容接口调用部分渠道在最终端点为claude原生端点下还是走了openai扣减input_token的逻辑
2026-02-08 00:17:50 +08:00
Seefs
3d0c75f42c Merge branch 'feature/messages2responses' into upstream-main
# Conflicts:
#	service/openaicompat/chat_to_responses.go
2026-02-08 00:16:35 +08:00
Calcium-Ion
e6f36e7999 Merge pull request #2864 from seefs001/fix/thining-summary
fix: add paragraph breaks between reasoning summary chunks
2026-02-08 00:15:32 +08:00
Calcium-Ion
e6b43f4279 Merge pull request #2852 from seefs001/fix/codex-tips
feat: add Codex channel disclaimer (i18n, OpenAI terms)
2026-02-08 00:07:41 +08:00
Seefs
81a94c3027 fix: patch message_delta usage via gjson/sjson and skip on passthrough 2026-02-07 19:13:58 +08:00
Thomas
63f246d403 fix: 补全 streaming message_delta 事件缺失的 input_tokens 和 cache 相关字段 (#2881)
当上游为 AWS Bedrock 时,message_delta 的 usage 可能缺少 input_tokens、
cache_creation_input_tokens、cache_read_input_tokens 等字段,导致与原生
Anthropic 格式不一致。从 message_start 积累的 claudeInfo 中补全这些字段后
重新序列化,确保客户端收到一致的 usage 格式。
2026-02-07 18:17:22 +08:00
Seefs
a972722367 fix: 使用openai兼容接口调用部分渠道在最终端点为claude原生端点下还是走了openai扣减input_token的逻辑 2026-02-07 14:21:19 +08:00
Seefs
8f52072f53 feat: /v1/messages -> /v1/responses 2026-02-06 15:22:32 +08:00
Seefs
517b6ba50d feat: gpt-5.3-codex 2026-02-06 14:47:23 +08:00
Seefs
d5f0ab01df fix: add paragraph breaks between reasoning summary chunks in chat2responses stream 2026-02-06 14:46:29 +08:00
Papersnake
e194b747c3 feat: support adaptive thinking 2026-02-06 11:01:23 +08:00
Papersnake
27825ec377 fix: aws claude 2026-02-06 09:51:15 +08:00
Papersnake
7ca072b1b0 feat: add claude-opus-4-6 2026-02-06 09:12:45 +08:00
CaIon
0e095d4ad8 feat(api): add 'cookie' to passthroughSkipHeaderNamesLower 2026-02-05 22:16:35 +08:00
CaIon
330e1e6395 remove: drop support for claude-2 and claude-1 series models
- Remove claude-instant-1.2, claude-2, claude-2.0, claude-2.1 from model lists
- Remove /v1/complete endpoint support (legacy completion API)
- Remove RequestModeCompletion and related code paths
- Simplify handler functions by removing requestMode parameter
- Update all channel adaptors that referenced claude handlers
2026-02-05 17:20:46 +08:00
Seefs
99928bcfde fix: charge local input tokens when Gemini returns empty response 2026-02-05 15:57:17 +08:00