Skip to content

alpha -> mian - #2007

Merged
seefs001 merged 106 commits into
alphafrom
main
Oct 11, 2025
Merged

alpha -> mian#2007
seefs001 merged 106 commits into
alphafrom
main

Conversation

@seefs001

@seefs001 seefs001 commented Oct 11, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added OpenAI-compatible video APIs (/v1/videos), proxying, and task viewing.
    • Introduced Sora video generation channel with task lifecycle support.
    • Electron desktop app with tray, packaged builds, and integrated backend.
    • User Agreement and Privacy Policy pages; login/registration require consent when enabled.
    • Top-up management: user history, admin listing, and manual completion.
  • Improvements

    • Flexible quota display: USD, CNY, Tokens, Custom currency.
    • Safer outbound requests with redirect/domain guards.
    • Clearer Gemini block/empty-response errors.
  • Documentation

    • Updated READMEs, added translation glossary.
  • Chores

    • Consolidated release workflows and added Gitee release sync.
    • New issue and pull request templates.

feitianbubu and others added 30 commits July 19, 2025 21:19
…ENS/CUSTOM)

Replace the legacy boolean “DisplayInCurrencyEnabled” with an injected, type-safe
configuration `general_setting.quota_display_type`, and wire it through the
backend and frontend.

Backend
- Add `QuotaDisplayType` to `operation_setting.GeneralSetting` with injected
  registration via `config.GlobalConfig.Register("general_setting", ...)`.
  Helpers: `IsCurrencyDisplay()`, `IsCNYDisplay()`, `GetQuotaDisplayType()`.
- Expose `quota_display_type` in `/api/status` and keep legacy
  `display_in_currency` for backward compatibility.
- Logger: update `LogQuota` and `FormatQuota` to support USD/CNY/TOKENS. When
  CNY is selected, convert using `operation_setting.USDExchangeRate`.
- Controllers:
  - `billing`: compute subscription/usage amounts based on the selected type
    (USD: divide by `QuotaPerUnit`; CNY: USD→CNY; TOKENS: keep raw tokens).
  - `topup` / `topup_stripe`: treat inputs as “amount” for USD/CNY and as
    token-count for TOKENS; adjust min topup and pay money accordingly.
  - `misc`: include `quota_display_type` in status payload.
- Compatibility: in `model/option.UpdateOption`, map updates to
  `DisplayInCurrencyEnabled` → `general_setting.quota_display_type`
  (true→USD, false→TOKENS). Keep exporting the legacy key in `OptionMap`.

Frontend
- Settings: replace the “display in currency” switch with a Select
  (`general_setting.quota_display_type`) offering USD / CNY / Tokens.
  Provide fallback mapping from legacy `DisplayInCurrencyEnabled`.
- Persist `quota_display_type` to localStorage (keep `display_in_currency`
  for legacy components).
- Rendering helpers: base all quota/price rendering on `quota_display_type`;
  use `usd_exchange_rate` for CNY symbol/values.
- Pricing page: default view currency follows site display type (USD/CNY),
  while TOKENS mode still allows per-view currency toggling when needed.

Notes
- No database migrations required.
- Legacy clients remain functional via compatibility fields.
# Conflicts:
#	web/src/components/settings/personal/cards/AccountManagement.jsx
#	web/src/components/table/channels/modals/EditChannelModal.jsx
#	web/src/hooks/channels/useChannelsData.jsx
#	web/src/hooks/common/useSidebar.js
#	web/src/i18n/locales/fr.json
#	web/src/pages/Setting/Operation/SettingsGeneral.jsx
feat: Allow FIM chat requests without messages
refactor: simplify unsupported test channel types
💱 feat(settings): introduce site-wide quota display type
…isplay logic in RechargeCard and render functions
Calcium-Ion and others added 17 commits October 10, 2025 16:44
- replace infinite sleep loop with time.Ticker to avoid goroutine leaks
- add immediate initial test execution before ticker starts
- implement frequency change detection and ticker recreation
- ensure proper ticker cleanup when loop exits or feature disabled
fix(channel): handle dynamic frequency updates
支持可灵使用openai sdk生成视频
feat: sora 增加参数校验与计费
@seefs001
seefs001 merged commit c948f85 into alpha Oct 11, 2025
1 check was pending
@coderabbitai

coderabbitai Bot commented Oct 11, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

Introduces Electron desktop app (code and CI), consolidates release workflows, adds OpenAI-compatible video endpoints and Sora task adaptor, implements quota display types (USD/CNY/TOKENS/CUSTOM), adds legal settings with user-facing pages, extends pricing logic (default price map, OtherRatios), enhances top-up flows and admin ops, updates HTTP client redirect safety, and adjusts multiple adapters (Gemini, Perplexity, Anthropic).

Changes

Cohort / File(s) Summary
CI/CD workflows
.github/workflows/release.yml, .github/workflows/electron-build.yml, .github/workflows/sync-to-gitee.yml, .github/workflows/linux-release.yml (removed), .github/workflows/macos-release.yml (removed), .github/workflows/windows-release.yml (removed)
Unified cross-platform release workflow; added Electron build workflow; Gitee release sync; removed separate OS release pipelines.
Electron desktop app
electron/*, electron/... (README.md, build.sh, create-tray-icon.js, entitlements.mac.plist, main.js, package.json, preload.js)
New Electron app scaffolding, build scripts, tray icon generation, hardened runtime entitlements, main/preload logic, and packaging config.
OpenAI video API + Sora channel
router/video-router.go, controller/video_proxy.go, middleware/distributor.go, relay/relay_task.go, relay/channel/adapter.go, relay/common/relay_info.go, relay/common/relay_utils.go, relay/channel/task/sora/*, relay/channel/task/kling/adaptor.go, dto/openai_response.go
Added /v1/videos routes and proxy; request mode detection; OpenAIVideo types and conversion interface; Sora task adaptor and models; Kling/Sora converters; video response wiring.
Quota display types
setting/operation_setting/general_setting.go, controller/billing.go, controller/topup.go, controller/topup_stripe.go, logger/logger.go, controller/misc.go, model/option.go, web/src/components/table/model-pricing/*, web/src/components/settings/OperationSetting.jsx
Introduced quota display type (USD/CNY/TOKENS/CUSTOM) and related formatting/conversion across billing, top-up, logger, status, UI settings.
Legal settings and pages
setting/system_setting/legal.go, controller/misc.go, router/api-router.go, web/src/components/common/DocumentRenderer/index.jsx, web/src/App.jsx, web/src/components/auth/*, web/src/components/settings/OtherSetting.jsx, web/src/components/setup/components/steps/DatabaseStep.jsx
Added legal config (User Agreement, Privacy Policy), API endpoints, frontend renderer/pages, login/register gating, settings UI, and Electron-aware setup messaging.
Per-request pricing and ratios
relay/helper/price.go, setting/ratio_setting/model_ratio.go, types/price_data.go, relay/relay_task.go
Switched to default price map, added Sora prices, introduced OtherRatios multiplier and logging in quota consumption.
Gemini adjustments
dto/gemini.go, relay/channel/gemini/adaptor.go, relay/channel/gemini/relay-gemini.go, service/convert.go
Added PromptFeedback pointer/blockReason; image size mapping by quality; tool-call sanitization in streaming; refined empty/blocked responses.
Perplexity/OpenAI request fields
dto/openai_request.go, relay/channel/perplexity/constants.go, relay/channel/perplexity/relay-perplexity.go, relay/channel/perplexity/adaptor.go
Added search-related fields to OpenAI request; expanded models; delegated handlers to OpenAI adaptor.
Anthropic header selection
controller/channel-billing.go, controller/channel.go
Added Claude auth header builder and used for Anthropic channel model listing.
Top-up enhancements
model/topup.go, controller/topup.go, controller/topup_stripe.go, router/api-router.go
Added PaymentMethod, list/search endpoints, admin manual completion with transactions/locking, and adjusted conversions for token display.
HTTP client redirect guard
service/http_client.go, service/download.go
Introduced redirect checking with fetch safety and unified HTTP client usage for worker/download requests.
OpenAI usage post-processing
relay/channel/openai/relay-openai.go
Centralized cached-tokens extraction and post-processing across handlers.
Ollama refactors (formatting)
relay/channel/ollama/*
Formatting and minor defensive code without behavior change.
Zhipu/JWT import updates
relay/channel/vertex/service_account.go, relay/channel/zhipu/relay-zhipu.go, go.mod
Migrated to jwt/v5 and updated module requirements.
Common/misc
.dockerignore, .gitignore, .github/ISSUE_TEMPLATE/*, .github/PULL_REQUEST_TEMPLATE/pull_request_template.md, README*.md, common/gin.go, common/constants.go, types/error.go, controller/channel-test.go, service/convert.go, service/helper*
Ignore tweaks; templates; docs updates; reusable multipart parser; DisplayInCurrencyEnabled var (compatibility); new error code prompt_blocked; channel test resiliency; ancillary text changes.
Frontend copy/format tweaks
web/src/components/**/*, web/index.html, web/package.json
Added axios upgrade; UI text/formatting changes; usage logs column labels; minor modal/component formatting.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant App as Electron App
  participant Bin as Backend Binary (new-api)
  participant UI as Renderer (Web)
  participant API as Local HTTP API

  User->>App: Launch
  App->>Bin: Spawn backend (PORT=3000, SQLITE_PATH,…)
  App->>API: Health checks (retry)
  alt Backend ready
    App->>UI: Create window/tray, load http://127.0.0.1:3000
  else Crash/Errors
    App->>User: Show error dialog (analyzed logs, actions)
  end
  User->>UI: Interact
  UI->>API: Requests (local)
Loading
sequenceDiagram
  autonumber
  actor Client
  participant GW as Gateway (/v1/videos)
  participant Task as Task Subsystem
  participant Chan as Channel Adaptor (Sora/Kling/…)
  participant Up as Upstream Provider

  Client->>GW: POST /v1/videos (submit)
  GW->>Task: Validate & create task
  Task->>Chan: BuildRequest & DoRequest
  Chan->>Up: Submit job
  Up-->>Chan: Task accepted (id)
  Chan-->>Task: Response (task_id, data)
  Task-->>Client: 202 Accepted (task_id)

  Client->>GW: GET /v1/videos/:task_id
  GW->>Task: Fetch status/data
  alt OpenAI video path
    Task->>Chan: ConvertToOpenAIVideo
    Chan-->>GW: OpenAIVideo JSON
    GW-->>Client: 200 OpenAIVideo
  else Default
    GW-->>Client: 200 Task JSON
  end

  Client->>GW: GET /v1/videos/:task_id/content
  GW->>Up: Proxy GET content with Authorization
  Up-->>GW: Stream video
  GW-->>Client: Stream with headers (cacheable)
Loading
sequenceDiagram
  autonumber
  participant FE as Frontend
  participant API as Backend API
  participant Settings as Operation/System Settings

  FE->>API: GET /api/status
  API->>Settings: GetQuotaDisplayType, currency symbol/rate
  Settings-->>API: DisplayType (USD/CNY/TOKENS/CUSTOM)
  API-->>FE: Status (quota_display_type, symbols, flags)

  FE->>API: Billing/Usage requests
  API->>Settings: Resolve display mode
  API-->>FE: Amounts formatted per mode
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120+ minutes

Possibly related PRs

Suggested reviewers

  • Calcium-Ion
  • creamlike1024

Poem

Hops on the build, my paws tap-tap,
A desktop burrow packaged in an app.
Videos stream, Sora sings,
Tokens, dollars—many things.
Legal leaves are neatly pressed—
All set; this rabbit’s CI-obsessed. 🐇⚙️🎬

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch main

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 68d9751 and 0ff98b1.

⛔ Files ignored due to path filters (6)
  • electron/icon.png is excluded by !**/*.png
  • electron/package-lock.json is excluded by !**/package-lock.json
  • electron/tray-icon-windows.png is excluded by !**/*.png
  • electron/tray-iconTemplate.png is excluded by !**/*.png
  • electron/tray-iconTemplate@2x.png is excluded by !**/*.png
  • web/bun.lock is excluded by !**/*.lock
📒 Files selected for processing (107)
  • .dockerignore (1 hunks)
  • .github/ISSUE_TEMPLATE/bug_report_en.md (1 hunks)
  • .github/ISSUE_TEMPLATE/feature_request_en.md (1 hunks)
  • .github/PULL_REQUEST_TEMPLATE/pull_request_template.md (0 hunks)
  • .github/workflows/electron-build.yml (1 hunks)
  • .github/workflows/linux-release.yml (0 hunks)
  • .github/workflows/macos-release.yml (0 hunks)
  • .github/workflows/release.yml (1 hunks)
  • .github/workflows/sync-to-gitee.yml (1 hunks)
  • .github/workflows/windows-release.yml (0 hunks)
  • .gitignore (1 hunks)
  • README.en.md (4 hunks)
  • README.fr.md (4 hunks)
  • README.ja.md (2 hunks)
  • README.md (2 hunks)
  • common/constants.go (1 hunks)
  • common/database.go (1 hunks)
  • common/gin.go (2 hunks)
  • constant/api_type.go (1 hunks)
  • constant/channel.go (2 hunks)
  • controller/billing.go (3 hunks)
  • controller/channel-billing.go (1 hunks)
  • controller/channel-test.go (3 hunks)
  • controller/channel.go (1 hunks)
  • controller/misc.go (4 hunks)
  • controller/setup.go (1 hunks)
  • controller/task_video.go (2 hunks)
  • controller/topup.go (5 hunks)
  • controller/topup_stripe.go (3 hunks)
  • controller/video_proxy.go (1 hunks)
  • docs/translation-glossary.md (1 hunks)
  • dto/gemini.go (2 hunks)
  • dto/openai_image.go (1 hunks)
  • dto/openai_request.go (1 hunks)
  • dto/openai_response.go (1 hunks)
  • electron/README.md (1 hunks)
  • electron/build.sh (1 hunks)
  • electron/create-tray-icon.js (1 hunks)
  • electron/entitlements.mac.plist (1 hunks)
  • electron/main.js (1 hunks)
  • electron/package.json (1 hunks)
  • electron/preload.js (1 hunks)
  • go.mod (1 hunks)
  • logger/logger.go (2 hunks)
  • middleware/distributor.go (1 hunks)
  • model/channel.go (1 hunks)
  • model/option.go (1 hunks)
  • model/topup.go (2 hunks)
  • relay/channel/adapter.go (2 hunks)
  • relay/channel/gemini/adaptor.go (2 hunks)
  • relay/channel/gemini/relay-gemini.go (2 hunks)
  • relay/channel/ollama/adaptor.go (4 hunks)
  • relay/channel/ollama/dto.go (3 hunks)
  • relay/channel/ollama/relay-ollama.go (4 hunks)
  • relay/channel/ollama/stream.go (1 hunks)
  • relay/channel/openai/relay-openai.go (3 hunks)
  • relay/channel/perplexity/adaptor.go (2 hunks)
  • relay/channel/perplexity/constants.go (1 hunks)
  • relay/channel/perplexity/relay-perplexity.go (1 hunks)
  • relay/channel/siliconflow/adaptor.go (1 hunks)
  • relay/channel/submodel/constants.go (1 hunks)
  • relay/channel/task/kling/adaptor.go (2 hunks)
  • relay/channel/task/sora/adaptor.go (1 hunks)
  • relay/channel/task/sora/constants.go (1 hunks)
  • relay/channel/vertex/service_account.go (1 hunks)
  • relay/channel/zhipu/relay-zhipu.go (1 hunks)
  • relay/common/relay_info.go (2 hunks)
  • relay/common/relay_utils.go (3 hunks)
  • relay/helper/price.go (1 hunks)
  • relay/helper/valid_request.go (1 hunks)
  • relay/relay_adaptor.go (2 hunks)
  • relay/relay_task.go (5 hunks)
  • router/api-router.go (3 hunks)
  • router/video-router.go (1 hunks)
  • service/channel.go (1 hunks)
  • service/convert.go (0 hunks)
  • service/download.go (2 hunks)
  • service/http_client.go (4 hunks)
  • setting/operation_setting/general_setting.go (2 hunks)
  • setting/ratio_setting/model_ratio.go (2 hunks)
  • setting/system_setting/legal.go (1 hunks)
  • types/error.go (3 hunks)
  • types/price_data.go (1 hunks)
  • web/index.html (1 hunks)
  • web/package.json (1 hunks)
  • web/src/App.jsx (2 hunks)
  • web/src/components/auth/LoginForm.jsx (14 hunks)
  • web/src/components/auth/RegisterForm.jsx (5 hunks)
  • web/src/components/common/DocumentRenderer/index.jsx (1 hunks)
  • web/src/components/common/examples/ChannelKeyViewExample.jsx (3 hunks)
  • web/src/components/common/modals/SecureVerificationModal.jsx (8 hunks)
  • web/src/components/settings/OperationSetting.jsx (1 hunks)
  • web/src/components/settings/OtherSetting.jsx (4 hunks)
  • web/src/components/settings/PersonalSetting.jsx (2 hunks)
  • web/src/components/settings/SystemSetting.jsx (8 hunks)
  • web/src/components/settings/personal/cards/AccountManagement.jsx (5 hunks)
  • web/src/components/settings/personal/cards/NotificationSettings.jsx (2 hunks)
  • web/src/components/setup/components/steps/DatabaseStep.jsx (1 hunks)
  • web/src/components/table/channels/modals/EditTagModal.jsx (1 hunks)
  • web/src/components/table/channels/modals/ModelTestModal.jsx (2 hunks)
  • web/src/components/table/model-pricing/filter/PricingDisplaySettings.jsx (1 hunks)
  • web/src/components/table/model-pricing/layout/header/SearchActions.jsx (1 hunks)
  • web/src/components/table/task-logs/modals/ContentModal.jsx (3 hunks)
  • web/src/components/table/usage-logs/UsageLogsColumnDefs.jsx (2 hunks)
  • web/src/components/table/users/UsersColumnDefs.jsx (1 hunks)
  • web/src/components/table/users/modals/ResetPasskeyModal.jsx (1 hunks)
  • web/src/components/table/users/modals/ResetTwoFAModal.jsx (1 hunks)
⛔ Files not processed due to max files limit (24)
  • web/src/components/topup/RechargeCard.jsx
  • web/src/components/topup/index.jsx
  • web/src/components/topup/modals/TopupHistoryModal.jsx
  • web/src/constants/channel.constants.js
  • web/src/helpers/data.js
  • web/src/helpers/passkey.js
  • web/src/helpers/render.jsx
  • web/src/helpers/secureApiCall.js
  • web/src/helpers/utils.jsx
  • web/src/hooks/channels/useChannelsData.jsx
  • web/src/hooks/common/useSecureVerification.jsx
  • web/src/hooks/model-pricing/useModelPricingData.jsx
  • web/src/hooks/usage-logs/useUsageLogsData.jsx
  • web/src/hooks/users/useUsersData.jsx
  • web/src/i18n/locales/en.json
  • web/src/i18n/locales/fr.json
  • web/src/i18n/locales/zh.json
  • web/src/pages/PrivacyPolicy/index.jsx
  • web/src/pages/Setting/Chat/SettingsChats.jsx
  • web/src/pages/Setting/Operation/SettingsGeneral.jsx
  • web/src/pages/Setting/Operation/SettingsLog.jsx
  • web/src/pages/Setting/index.jsx
  • web/src/pages/UserAgreement/index.jsx
  • web/src/services/secureVerification.js

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.