Commit Graph

165 Commits

Author SHA1 Message Date
CaIon eab478bdc8 fix: miscellaneous quick fixes from CodeRabbit review
- log_info_generate.go: add nil guard in InjectTieredBillingInfo
- billing_expr_request.go: merge headers instead of replacing
- go.mod: remove incorrect // indirect on expr-lang/expr
- ToolPriceSettings.jsx: add null check in syncToVisual
- tool_billing.go: fix PricePer1K for image_generation (per-call, not per-1K)
- utils.jsx: add minute() to time condition regex
- useUsageLogsData.jsx: pass displayMode to renderTieredModelPrice
- AGENTS.md, CLAUDE.md: fix Rule 6/7 ordering
- relay-gemini.go: add TEXT modality case in CandidatesTokensDetails
2026-04-24 00:34:06 +08:00
CaIon 4d2993e4cc Merge remote-tracking branch 'origin/main' into nightly
# Conflicts:
#	web/src/helpers/render.jsx
#	web/src/hooks/usage-logs/useUsageLogsData.jsx
#	web/src/i18n/locales/en.json
2026-04-09 17:12:21 +08:00
CaIon 03758a4a85 refactor(file-source): unify file source creation and enhance caching mechanisms 2026-04-06 15:54:55 +08:00
RedwindA 79527c0ab1 feat: add HEIC/HEIF image format support
Add detection, MIME type mapping, and dimension parsing for HEIC/HEIF
images via ISOBMFF ftyp brand inspection and ispe box parsing. Update
Gemini relay to accept these formats and refactor getImageConfig to
properly retry decoders using buffered data.
2026-04-02 16:40:45 +08:00
CaIon 35d0704640 Merge branch 'origin/main' into nightly
Resolve 4 conflicts:
- relay/compatible_handler.go: accept main's refactor (postConsumeQuota -> service.PostTextConsumeQuota)
- service/quota.go: accept main's PostClaudeConsumeQuota deletion, keep nightly's tiered billing in PostWssConsumeQuota and PostAudioConsumeQuota
- web/src/i18n/locales/{en,zh-CN}.json: merge both sets of translation keys

Post-merge integration:
- Add tiered billing (TryTieredSettle, InjectTieredBillingInfo) to PostTextConsumeQuota
- Update tool pricing calls to use nightly's generic GetToolPriceForModel/GetToolPrice API
2026-04-02 00:39:13 +08:00
CaIon 5238f279db feat: record stream interruption reasons via StreamStatus
- Add StreamStatus type (relay/common) to track stream end reason
  (done/timeout/client_gone/scanner_error/eof/panic/ping_fail) and
  accumulate soft errors during streaming via sync.Once + sync.Mutex.
- Add StreamResult (relay/helper) as the callback interface: adapters
  call sr.Error() for soft errors, sr.Stop() for fatal, sr.Done() for
  normal completion. No early-return problem — multiple errors per chunk
  are naturally supported.
- Refactor StreamScannerHandler callback from func(string) bool to
  func(string, *StreamResult). All 9 channel adapters updated.
- Write stream_status into log other JSON field (admin-only) with
  status ok/error, end_reason, error_count, and error messages.
- Frontend: display stream status in log detail expansion for admins.
2026-03-31 16:54:39 +08:00
CaIon c5405b2a12 feat: add billing expression system documentation and enhance tiered billing logic
- Introduced a new rule for the Billing Expression System, emphasizing the importance of reading `pkg/billingexpr/expr.md` for dynamic billing.
- Updated the billing expression logic to support new variables and improved handling of image and audio tokens.
- Enhanced the tiered billing functionality with versioning support for expressions and refined quota calculations.
- Added tests to validate the new billing expression features and ensure correctness in pricing calculations.
2026-03-17 16:59:25 +08:00
Seefs 2cf3c1836c fix: preserve explicit zero values in native relay requests 2026-03-01 15:47:03 +08:00
Seefs c97f4524f2 fix: unify usage mapping and include toolUsePromptTokenCount in input tokens 2026-02-17 15:45:14 +08:00
CaIon 92aca9771f feat: refactor extra_body handling for improved configuration parsing 2026-02-11 22:15:22 +08:00
Seefs 99928bcfde fix: charge local input tokens when Gemini returns empty response 2026-02-05 15:57:17 +08:00
CaIon ffef331192 refactor(gemini): remove GeminiVisionMaxImageNum constant and related image count logic 2026-02-04 19:10:06 +08:00
CaIon 9ef9e78821 feat(file): unify file handling with a new FileSource abstraction for URL and base64 data 2026-02-04 18:23:17 +08:00
thirking 4108c404ee fix: remove unnecessary unescapeMapOrSlice call in Gemini relay
The JSON serialization/deserialization already handles escape characters
correctly, so the unescapeMapOrSlice function is redundant.
2026-02-03 11:47:45 +08:00
RedwindA 3985d10ae1 feat(gemini): support cached token billing 2026-02-01 22:50:47 +08:00
RedwindA 9899073ecb feat(gemini): map OpenAI stop to Gemini stopSequences 2026-01-29 21:30:27 +08:00
Seefs 68e1e635e9 feat: logs show reject reason 2026-01-25 14:52:18 +08:00
Seefs 7af4d07843 fix: Charge locally even if there's an error 2026-01-25 14:32:51 +08:00
Seefs c09c272574 Merge branch 'upstream-main' into fix/pr-2540
# Conflicts:
#	relay/channel/gemini/relay-gemini.go
2026-01-25 14:14:05 +08:00
Calcium-Ion 3f208ee365 Merge pull request #2701 from seefs001/fix/gemini-tool-call-index
fix: calls to multiple tools in gemini all return index=0
2026-01-21 23:47:48 +08:00
Seefs 7e90c832e2 fix: issue where consecutive calls to multiple tools in gemini all returned an index of 0 2026-01-20 22:03:19 +08:00
Seefs d694a197d2 fix: openAI function to gemini function field adjusted to whitelist mode 2026-01-15 13:26:42 +08:00
Seefs 14b3dac82c fix: clean propertyNames for gemini function 2026-01-11 23:34:18 +08:00
RedwindA db96248c5b refactor(gemini): 更新 GeminiModelsResponse 以使用 dto.GeminiModel 类型 2026-01-09 18:08:11 +08:00
RedwindA e8eea5d3ee fix(gemini): fetch model list via native v1beta/models endpoint
Use the native Gemini Models API (/v1beta/models) instead of the OpenAI-compatible
path when listing models for Gemini channels, improving compatibility with
third-party Gemini-format providers that don't implement OpenAI routes.

- Add paginated model listing with timeout and optional proxy support
- Select an enabled key for multi-key Gemini channels
2026-01-09 18:00:40 +08:00
Xyfacai eeccb2146f fix: 修复 gemini 文件类型不支持 image/jpg 2026-01-04 22:09:03 +08:00
Your Name 9c243d1fb8 feat(gemini): 支持 tool_choice 参数转换,优化错误处理 2025-12-27 18:33:09 +08:00
RedwindA 518563c7eb feat: map OpenAI developer role to Gemini system instructions 2025-12-27 02:52:33 +08:00
Seefs 39df47486c fix(gemini): handle minimal reasoning effort budget
- Add minimal case to clampThinkingBudgetByEffort to avoid defaulting to full thinking budget
2025-12-18 08:10:46 +08:00
Calcium-Ion 4c54836a53 Merge pull request #2344 from seefs001/feature/gemini-thinking-level
feat: gemini 3 thinking level gemini-3-pro-preview-high
2025-12-02 21:55:43 +08:00
CaIon 1fededceb3 feat: refactor token estimation logic
- Introduced new OpenAI text models in `common/model.go`.
- Added `IsOpenAITextModel` function to check for OpenAI text models.
- Refactored token estimation methods across various channels to use estimated prompt tokens instead of direct prompt token counts.
- Updated related functions and structures to accommodate the new token estimation approach, enhancing overall token management.
2025-12-02 21:34:39 +08:00
CaIon e19e9ad2fa feat(gemini): implement markdown image handling in text processing 2025-12-01 17:54:41 +08:00
Seefs 607f7305b7 feat: gemini 3 thinking level gemini-3-pro-preview-high 2025-12-01 16:40:46 +08:00
CaIon 5d05cd9d32 feat(gemini): add validation and conversion for imageConfig parameters in extra_body 2025-11-30 19:31:08 +08:00
Seefs c074ed2eb5 Revert "OAI生图接口支持gemini 3 pro image preview" 2025-11-30 18:49:18 +08:00
Calcium-Ion d33e4c8d35 Merge pull request #2338 from QuantumNous/revert-2321-pr/gemini-image-edit
Revert "Gemini Image系列支持图像编辑"
2025-11-30 18:48:01 +08:00
Seefs b827d1f778 Revert "Gemini Image系列支持图像编辑" 2025-11-30 18:45:54 +08:00
Seefs 2fb1fa08d2 Revert "fix: gemini image correct generationConfig" 2025-11-30 18:45:23 +08:00
feitianbubu fb55d56089 feat: gemini image support edit 2025-11-27 16:04:04 +08:00
feitianbubu 156229ce92 fix: gemini image correct generationConfig 2025-11-26 15:54:11 +08:00
feitianbubu 2d6f8fb58f feat: gemini-3-pro-image-preview add extra param 2025-11-26 12:03:24 +08:00
Claude 7645300f96 feat: enable thoughtSignature for non-function-call messages
Previously thoughtSignature was only attached to messages with function
calls. This change extends the feature to also attach thoughtSignature
to the first text part of assistant/model messages when no tool_calls
are present, ensuring compatibility with Gemini thinking models in
regular conversation scenarios.
2025-11-24 00:31:20 +00:00
CaIon c8bbf7bed8 feat: Add ContextKeyLocalCountTokens and update ResponseText2Usage to use context in multiple channels 2025-11-21 18:17:01 +08:00
Seefs 4ac4849ab6 feat: Fill thoughtSignature only for Gemini/Vertex channels using the OpenAI format 2025-11-20 15:54:33 +08:00
CaIon 7391b15b4b fix: remove redundant error handling for empty Gemini API response 2025-10-13 21:58:50 +08:00
CaIon 063926dd29 fix: update error messages for unsupported parameter names in Google extra body 2025-10-12 22:21:45 +08:00
Seefs 5010f2d004 format: package name -> github.com/QuantumNous/new-api (#2017) 2025-10-11 15:30:09 +08:00
CaIon 35105b3da5 feat: update Gemini API response handling to include block reason and improve error reporting 2025-10-05 19:33:47 +08:00
Moment b2d3fa5d95 fix: Gemini missing func name for multi-streaming tool calls (except the first). 2025-10-04 13:21:07 +08:00
Seefs 23c1bd472e feat: gemini urlContext 2025-09-27 16:16:34 +08:00