- Add view mode switch (global vs channel) to ModelSettingsVisualEditor
- Create ChannelPricingView component for channel-specific pricing
- Add pricing tag management tab to RatioSetting
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Integrate channel-specific pricing into the billing logic.
- First tries to get channel pricing using model.GetEffectivePricing
- If found, uses channel pricing (modelRatio, completionRatio, modelPrice, usePrice)
- If not found, falls back to global pricing from ratio_setting
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When a token has BoundChannelId set, the distributor now uses that channel
instead of the normal channel selection process. The bound channel is still
validated to ensure it is enabled and supports the requested model.
Changes:
- Add ContextKeyTokenBoundChannelId constant
- Set bound channel in context during token authentication
- Check and use bound channel in distributor before normal selection
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add BoundChannelId field to support binding a token to a specific channel.
When set, the token will always use the bound channel for requests.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add new route groups for channel pricing and pricing tag management
with AdminAuth middleware.
Routes added:
- /api/channel_pricing/*: CRUD operations for channel pricing
- /api/pricing_tag/*: CRUD operations for pricing tags
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- GetAllChannelPricing: get all channel pricings with pagination
- GetChannelPricingByModel: get pricings for a specific model
- CreateChannelPricing: create or update channel pricing
- BatchCreateChannelPricing: batch create/update pricings
- DeleteChannelPricing: delete channel pricing
- CopyGlobalPricing: copy global pricing from ratio_setting to channel
- GetChannelPricingWithTags: get pricings with tag details
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add the new pricing models to both migrateDB() and migrateDBFast()
functions to enable automatic table creation on database initialization.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The previous implementation only did INSERT without handling conflicts.
Now uses GORM's OnConflict clause to properly update existing records
when (model_name, channel_id) unique constraint is violated.
On conflict updates: quota_type, model_ratio, completion_ratio,
model_price, tag_ids, updated_time
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add new model to support per-channel pricing for models,
allowing the same model to have different prices across
different channels.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When a channel is created or updated, automatically sync its models to the
models table if they don't exist. Models created this way are marked with
SyncOfficial=0 to prevent official sync from overwriting them.