Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
307 commits
Select commit Hold shift + click to select a range
30aa621
refactor: align creative center with reference layout
LJR199887 Mar 30, 2026
f47b799
Update index.jsx
LJR199887 Mar 30, 2026
4f1d75e
refactor: improve CreativeCenter UI hierarchy
Mar 30, 2026
c8d43bc
fix: pause CreativeCenter third-party image generation
Mar 30, 2026
7b17ebf
Update index.jsx
LJR199887 Mar 30, 2026
da83c0c
Merge pull request #9 from LJR199887/ui/creative-center-design
LJR199887 Mar 30, 2026
61dc59e
fix: remove creative center tailwind flicker
LJR199887 Mar 30, 2026
b216a3d
fix: restore tailwind palette for creative center
LJR199887 Mar 30, 2026
7997d54
chore: remove creative center quick prompts
LJR199887 Mar 30, 2026
4e01e21
feat: sync creative center models from tags
LJR199887 Mar 30, 2026
e8b960a
feat: align creative center model requests with playground
LJR199887 Mar 30, 2026
d7606f1
feat: refine creative center guest and model states
LJR199887 Mar 30, 2026
e120824
fix: show public creative center models for guests
LJR199887 Mar 30, 2026
6f837ae
feat: expose creative center media settings
LJR199887 Mar 30, 2026
bd97f9f
fix: align creative center media controls with playground
LJR199887 Mar 30, 2026
3e76fb7
fix: send veo metadata from creative center
LJR199887 Mar 30, 2026
2d5a900
fix: route adobe video models through chat completions
LJR199887 Mar 30, 2026
b7b72cf
feat: support multi creative generations and scrolling
LJR199887 Mar 30, 2026
2be68f3
feat: persist creative center history
LJR199887 Mar 30, 2026
ee2dc89
fix: sync creative center icons and history routes
LJR199887 Mar 30, 2026
41b0524
feat: stream creative center media history
LJR199887 Mar 30, 2026
da671d3
feat: refine creative center media task progress
LJR199887 Mar 31, 2026
bf51f1d
feat: polish creative center task progress
LJR199887 Mar 31, 2026
6034ea1
fix: use real creative center task progress
LJR199887 Mar 31, 2026
1bd866f
fix: allow switching creative center chat models
LJR199887 Mar 31, 2026
c8f49ff
fix: preserve creative center request params
LJR199887 Mar 31, 2026
79c8492
feat: add creative center image uploads
LJR199887 Mar 31, 2026
3eccd2e
feat: add resolution-based model pricing
LJR199887 Mar 31, 2026
948328c
fix: clean up pricing card labels
LJR199887 Mar 31, 2026
9303edc
feat: merge adobe 4k image model variants
LJR199887 Mar 31, 2026
93605fb
feat: preview creative results as they complete
LJR199887 Mar 31, 2026
9a71c67
feat: randomize creative task seeds per request
LJR199887 Mar 31, 2026
93cbb95
feat: add creative image preview and multi-download
LJR199887 Mar 31, 2026
afae443
fix: diversify creative batch requests
LJR199887 Mar 31, 2026
7d68fe0
fix: simplify creative image actions
LJR199887 Mar 31, 2026
a075547
fix: restore parallel creative image requests
LJR199887 Mar 31, 2026
ca2dd1e
feat: add creative video preview and batch download
LJR199887 Mar 31, 2026
93cbab7
refactor: simplify creative video task cards
LJR199887 Mar 31, 2026
fe4452b
refactor: align creative video cards with image layout
LJR199887 Mar 31, 2026
39fccf3
fix: stagger creative batch requests
LJR199887 Mar 31, 2026
04caa0c
feat: show adobe creative request progress
LJR199887 Mar 31, 2026
937d322
fix: keep creative progress polling on original channel
LJR199887 Mar 31, 2026
0f13d85
fix: allow creative progress status polling
LJR199887 Mar 31, 2026
cf61ff1
fix: bypass distributor for creative status polling
LJR199887 Mar 31, 2026
4038d6d
fix: stop showing fake creative progress
LJR199887 Mar 31, 2026
5fe0601
revert: remove creative progress polling
LJR199887 Mar 31, 2026
cd0e160
Add estimated progress for banana and veo tasks
LJR199887 Mar 31, 2026
a319ab6
Use estimated progress for all creative media tasks
LJR199887 Mar 31, 2026
48d2f8a
Hide duplicate auto size for banana models
LJR199887 Mar 31, 2026
1d2e110
Show grok media sizes as aspect ratios
LJR199887 Mar 31, 2026
6753641
Rename grok media ratios to Chinese labels
LJR199887 Mar 31, 2026
89a972e
Simplify grok ratio labels
LJR199887 Mar 31, 2026
df22ab7
Allow continuous creative submissions
LJR199887 Mar 31, 2026
706fe2c
Rename grok video preset label
LJR199887 Mar 31, 2026
a5d66ba
Fix creative video completion fallback
LJR199887 Mar 31, 2026
edece27
Optimize creative center media rendering
LJR199887 Mar 31, 2026
e57db03
Add collapsible creative history cards
LJR199887 Mar 31, 2026
4321508
Show creative video thumbnails
LJR199887 Mar 31, 2026
77a8b30
Open creative video previews in new tab
LJR199887 Mar 31, 2026
64ee1d1
Simplify creative video card actions
LJR199887 Mar 31, 2026
f10cfe2
Restore video preview hint overlay
LJR199887 Mar 31, 2026
425432a
Polish creative video card layout
LJR199887 Mar 31, 2026
b0fcd02
Revert creative video cards to minimal layout
LJR199887 Mar 31, 2026
115cc94
Restore video preview CTA label
LJR199887 Mar 31, 2026
1a752ef
Fix creative video card badge and CTA layout
LJR199887 Mar 31, 2026
29f2a22
Show upstream creative request errors
LJR199887 Mar 31, 2026
91efeaf
Revert "Show upstream creative request errors"
LJR199887 Apr 1, 2026
814b3bb
Fix xai image edit multipart relay
LJR199887 Apr 1, 2026
39000da
Allow JSON image edit payloads on OpenAI relay
LJR199887 Apr 1, 2026
4e0a341
Use chat image_url flow for grok image edit
LJR199887 Apr 1, 2026
fbbad62
Allow xAI channel to handle grok video tasks
LJR199887 Apr 1, 2026
437e465
feat: configure creative center image bed in settings
LJR199887 Apr 2, 2026
ec1e058
fix: send grok image edit size via edits api
LJR199887 Apr 2, 2026
14922aa
fix: stabilize grok image edit rendering
LJR199887 Apr 2, 2026
2151375
fix: use blob previews for creative uploads
LJR199887 Apr 2, 2026
0cf0f52
feat: limit creative upload counts by model
LJR199887 Apr 2, 2026
0ee32de
fix: restore creative center page render
LJR199887 Apr 2, 2026
aec5d1d
chore: clarify grok edit ratio label
LJR199887 Apr 2, 2026
2e910a7
Merge pull request #10 from LJR199887/codex/fix-grok-video-url
LJR199887 Apr 2, 2026
4be0d59
fix: lock veo31 ref creative defaults
LJR199887 Apr 2, 2026
b4969de
fix: stabilize creative center video previews
LJR199887 Apr 2, 2026
1febf3d
fix: open creative video previews in new page
LJR199887 Apr 2, 2026
aec92bd
feat: enrich creative video preview page
LJR199887 Apr 2, 2026
cd17ed3
fix: restore creative image preview loading
LJR199887 Apr 2, 2026
442ae74
fix: send image references for grok video
LJR199887 Apr 2, 2026
150afbe
feat: upload creative center images directly to image bed
LJR199887 Apr 2, 2026
b57e257
fix: upload creative center images sequentially
LJR199887 Apr 2, 2026
6fd3264
fix: limit creative center image uploads to 10mb
LJR199887 Apr 2, 2026
37a1eba
chore: adjust creative center upload hint
LJR199887 Apr 2, 2026
c8e4577
feat: add creative center session management
LJR199887 Apr 2, 2026
32aeb5c
fix: reposition creative center session actions
LJR199887 Apr 2, 2026
a222b57
fix: show creative center session toolbar below header
LJR199887 Apr 2, 2026
f183a6f
fix: restore creative center session controls
LJR199887 Apr 2, 2026
e06a57d
fix: support banana image edit sessions
LJR199887 Apr 2, 2026
9050b0f
fix: hide creative center session summary
LJR199887 Apr 2, 2026
36ae48e
fix: align creative center chat payloads
LJR199887 Apr 2, 2026
4b1fb10
fix creative center model metadata display
LJR199887 Apr 2, 2026
458af31
refine creative center sidebar model preview
LJR199887 Apr 2, 2026
75a79ee
Add creative center asset library
LJR199887 Apr 2, 2026
158849a
Refine creative center asset library
LJR199887 Apr 2, 2026
e4f6af5
Polish asset library interactions
LJR199887 Apr 2, 2026
8ccbb55
Fix creative center asset downloads
LJR199887 Apr 3, 2026
cb405de
Fix creative center video recovery
LJR199887 Apr 3, 2026
bf233bd
Limit creative center startup recovery
LJR199887 Apr 3, 2026
cf941e6
Harden creative center video recovery
LJR199887 Apr 3, 2026
47bcfb1
Recover creative center videos from task history
LJR199887 Apr 3, 2026
8b237ab
Recover creative center images from task history
LJR199887 Apr 3, 2026
a9acbc6
Record creative center media chat tasks
LJR199887 Apr 3, 2026
2e3830f
Refine asset and task log previews
LJR199887 Apr 3, 2026
b768c49
Improve task log image preview and duration
LJR199887 Apr 3, 2026
fb9f43c
Refine image preview actions and nav label
LJR199887 Apr 3, 2026
1250529
Update contact labels and image model options
LJR199887 Apr 3, 2026
01d7dcf
Add task logs dashboard and stats filters
LJR199887 Apr 3, 2026
b6025bd
Refine task logs dashboard stats display
LJR199887 Apr 3, 2026
cf9b9a8
Fix task log duration and task stats counts
LJR199887 Apr 3, 2026
7be7008
Fix task log duration and stats breakdown
LJR199887 Apr 3, 2026
ddefd3e
Fix grok video task duration fallback
LJR199887 Apr 3, 2026
329bc67
Use upstream timestamps for grok video tasks
LJR199887 Apr 3, 2026
10d6ab2
Improve grok video duration fallback
LJR199887 Apr 3, 2026
8f06032
Record non-success task states in task logs
LJR199887 Apr 3, 2026
d541f4c
Sync pending tasks into task logs
LJR199887 Apr 3, 2026
19b2b7a
Avoid premature task failures during polling
LJR199887 Apr 3, 2026
bb661c8
Track playground media tasks before completion
LJR199887 Apr 3, 2026
eeae5a5
Fix async task prompt and usage duration logging
LJR199887 Apr 3, 2026
030085d
Show hourly task stats for today
LJR199887 Apr 3, 2026
4fb662e
Preserve nano banana image ratio params
LJR199887 Apr 3, 2026
d5b9806
Add seed compatibility for creative media batches
LJR199887 Apr 3, 2026
2103c9e
Restore nano banana chat image ratios
LJR199887 Apr 3, 2026
fdddf19
Handle presigned media results in task logs
LJR199887 Apr 3, 2026
3df056e
Merge pull request #11 from LJR199887/codex/fix-grok-video-url
LJR199887 Apr 3, 2026
8af22f7
Optimize task stats and creative polling
LJR199887 Apr 3, 2026
e253fa6
Merge pull request #12 from LJR199887/codex/fix-grok-video-url
LJR199887 Apr 3, 2026
3f4b4d3
feat(ui): optimize Creative Center UI design and layout
LJR199887 Apr 3, 2026
f87a33f
feat: redesign creative center ui with premium dark glassmorphism theme
LJR199887 Apr 6, 2026
d2d20a7
fix: creative center top layout clipping issue by adding relative and…
LJR199887 Apr 6, 2026
a187acc
fix: added min-h-0 to flex-1 items to prevent global scroll layout ov…
LJR199887 Apr 6, 2026
eca1bb2
fix: add mt-16 to offset fixed navbar overlap on creative center
LJR199887 Apr 6, 2026
b1f2fd5
feat(ui): complete minimalist dark theme redesign for creative center…
LJR199887 Apr 6, 2026
1caf32a
feat(ui): modernize creative center with light blue glassmorphism theme
LJR199887 Apr 6, 2026
212f45d
style(ui): update creative center color scheme to match SkyFlow pure …
LJR199887 Apr 6, 2026
4c0f1bd
style(ui): fix tooltip overlapping and enhance empty state + drop but…
LJR199887 Apr 6, 2026
d63c8a1
style(ui): final adjustments to creative center UI padding, pricing, …
LJR199887 Apr 6, 2026
37401d3
style(ui): redesign sidebar header, model card layout, and hover popups
LJR199887 Apr 6, 2026
4f5a572
style(ui): re-align text, add assets button to sidebar bottom, and re…
LJR199887 Apr 6, 2026
6bf9865
fix(ui): unclip hover popup from scroll container and adjust z-index
LJR199887 Apr 6, 2026
e4426d2
style(ui): remove '深度解析' text from hovered model popup to fix wrapping
LJR199887 Apr 6, 2026
5db0861
style(ui): ensure full model name is displayed in hover tooltip witho…
LJR199887 Apr 6, 2026
a953b89
style(ui): hide price from hovered popup and enforce single-line mode…
LJR199887 Apr 6, 2026
d1ce582
style: swap positions of Asset Library and Task Log in sidebar
LJR199887 Apr 6, 2026
eb11b63
style: optimize ui for the asset library with pro max guidelines
LJR199887 Apr 6, 2026
41ba766
fix: asset library - 5 cols grid and scroll to top on page change
LJR199887 Apr 6, 2026
6253a92
feat: 控制台侧边栏资产库与任务日志位置互换
LJR199887 Apr 6, 2026
8797742
Merge pull request #13 from LJR199887/feature/optimize-creative-cente…
LJR199887 Apr 6, 2026
2f445ae
Fix asset library pagination filters
LJR199887 Apr 6, 2026
ebf6a77
Tighten creative center chat layout
LJR199887 Apr 6, 2026
e5b14b9
Refine creative chat bubbles and asset grid
LJR199887 Apr 6, 2026
ccce7a7
Lock web theme to light mode
LJR199887 Apr 6, 2026
2c6b7d1
Merge pull request #14 from LJR199887/codex/fix-grok-video-url
LJR199887 Apr 7, 2026
2e2b778
Remove recharge price display toggle
LJR199887 Apr 7, 2026
6030194
Merge pull request #15 from LJR199887/codex/fix-grok-video-url
LJR199887 Apr 7, 2026
bcc90fc
fix creative center chat response parsing
LJR199887 Apr 7, 2026
457b247
fix creative center mapped model capabilities
LJR199887 Apr 7, 2026
3415aed
improve creative center chat response fallback
LJR199887 Apr 7, 2026
73f0581
sanitize creative center chat retry context
LJR199887 Apr 7, 2026
70d96f6
expand creative center chat message parsing
LJR199887 Apr 7, 2026
968d43c
fix playground nonstream text extraction
LJR199887 Apr 7, 2026
d060b7b
use stream for creative center gpt chat
LJR199887 Apr 7, 2026
b9d5857
cleanup creative center chat fallback
LJR199887 Apr 7, 2026
d0b079f
Merge pull request #16 from LJR199887/codex/fix-grok-video-url
LJR199887 Apr 7, 2026
5e36a01
Revert "fix creative center mapped model capabilities"
LJR199887 Apr 7, 2026
1ef6cdc
use current model for creative chat streaming
LJR199887 Apr 7, 2026
fa19035
Merge pull request #17 from LJR199887/codex/fix-grok-video-url
LJR199887 Apr 7, 2026
14b31db
fix chat-compatible video duration pricing
LJR199887 Apr 7, 2026
4f24f99
Merge pull request #18 from LJR199887/codex/fix-grok-video-url
LJR199887 Apr 7, 2026
73b1425
fix duration and resolution only media billing
LJR199887 Apr 9, 2026
679a759
Merge pull request #19 from LJR199887/codex/fix-grok-video-url
LJR199887 Apr 9, 2026
dc575d4
refactor asset library to use task records
LJR199887 Apr 9, 2026
064b3bc
optimize asset library pagination flow
LJR199887 Apr 9, 2026
6b6622b
Merge pull request #20 from LJR199887/codex/fix-grok-video-url
LJR199887 Apr 9, 2026
c10df81
Fix creative center task recovery state
LJR199887 Apr 9, 2026
1551688
Add drag upload and image reuse
LJR199887 Apr 9, 2026
48f93ac
Show backend quota errors in web UI
LJR199887 Apr 9, 2026
1bae7f9
Fail creative tasks on quota errors
LJR199887 Apr 9, 2026
40a5ae2
Restore quota error toast after API refresh
LJR199887 Apr 9, 2026
f6b211e
Show creative submit quota errors
LJR199887 Apr 9, 2026
b5ac355
Improve creative quota error extraction
LJR199887 Apr 9, 2026
332a414
Skip generic creative submit error toast
LJR199887 Apr 9, 2026
eeb3c50
Revert "Skip generic creative submit error toast"
LJR199887 Apr 9, 2026
f5841ca
Revert "Improve creative quota error extraction"
LJR199887 Apr 9, 2026
f211a50
Revert "Show creative submit quota errors"
LJR199887 Apr 9, 2026
c131400
Revert "Restore quota error toast after API refresh"
LJR199887 Apr 9, 2026
d6abe70
Merge pull request #21 from LJR199887/codex/fix-grok-video-url
LJR199887 Apr 9, 2026
28ac77f
Fix MySQL creative history payload migration
LJR199887 Apr 10, 2026
72de73b
Harden frontend against 429 refresh failures
LJR199887 Apr 10, 2026
c4c25c0
Reduce creative center sync pressure
LJR199887 Apr 10, 2026
3c26e56
Avoid ambiguous video session recovery
LJR199887 Apr 10, 2026
8f27f4a
Recover video tasks by request id
LJR199887 Apr 10, 2026
b915a92
Stabilize creative video recovery and 429 fallback
LJR199887 Apr 10, 2026
1bca117
Use task state to recover creative videos
LJR199887 Apr 10, 2026
2f2d1f8
Use task resolver for creative video recovery
LJR199887 Apr 10, 2026
2065476
Fix creative video recovery request ID mapping
LJR199887 Apr 11, 2026
d53fb83
Stabilize creative video status recovery
LJR199887 Apr 11, 2026
dae85c9
Hide creative center until bootstrap completes
LJR199887 Apr 11, 2026
0f0b876
Limit grok video duration options
LJR199887 Apr 13, 2026
ad441de
Fix creative video failure state sync
LJR199887 Apr 13, 2026
6ad0c0d
Limit nano-banana uploads in creative center
LJR199887 Apr 13, 2026
5be127d
Add group fixed pricing for media models
LJR199887 Apr 14, 2026
25761ee
Prefer user group for media fixed pricing
LJR199887 Apr 14, 2026
c05e805
Show billing group for fixed media pricing logs
LJR199887 Apr 14, 2026
7be2b2c
Prevent failed image tasks from recovering other results
LJR199887 Apr 14, 2026
3ff325f
Add async image task endpoints
LJR199887 Apr 14, 2026
d764104
fix creative center failed video status
LJR199887 Apr 14, 2026
49ab232
fix creative center video failure recovery
LJR199887 Apr 14, 2026
924a17c
Add async video task endpoints
LJR199887 Apr 15, 2026
56d378e
Fix async video transient status handling
LJR199887 Apr 15, 2026
34d42bd
Remove async video transient display grace
LJR199887 Apr 15, 2026
9ddabab
Use async media tasks in creative center
LJR199887 Apr 15, 2026
e1a08a9
Fix playground async media dispatch
LJR199887 Apr 15, 2026
4cd5b0d
Fix async video task status fallback
LJR199887 Apr 15, 2026
2b97a66
Skip token billing for unlimited playground tokens
LJR199887 Apr 15, 2026
e5b6160
Keep polling async video task status
LJR199887 Apr 15, 2026
ee3c1f4
Refresh async video status on fetch
LJR199887 Apr 15, 2026
ee92940
Fix creative video live task status
LJR199887 Apr 15, 2026
dbbc4ee
Fix creative task polling cache
LJR199887 Apr 15, 2026
08b8bfe
Prevent task status regressions during relay updates
LJR199887 Apr 15, 2026
63e5283
Revert async video tweaks after 2b97a668
LJR199887 Apr 15, 2026
80140ec
Optimize creative center async task polling
LJR199887 Apr 15, 2026
872d256
Route creative center Veo via async video API
LJR199887 Apr 15, 2026
f0323e5
Fix async video upstream polling path
LJR199887 Apr 15, 2026
77d8b0e
Limit video generations upstream path to Veo
LJR199887 Apr 15, 2026
ceb8cfd
Support async Sora uploads in creative center
LJR199887 Apr 16, 2026
c9454d6
Fix sora async video request normalization
LJR199887 Apr 16, 2026
e621912
Fix sora async video endpoint routing
LJR199887 Apr 16, 2026
2702c47
Align sora creative-center video payloads
LJR199887 Apr 17, 2026
d86d277
fix banana async image urls
LJR199887 Apr 17, 2026
0d6245a
Fix sora async video generation
LJR199887 Apr 17, 2026
44bbe37
Handle async video data url responses
LJR199887 Apr 17, 2026
261d299
Prefer sora task id for polling
LJR199887 Apr 17, 2026
6a00a4a
Fix creative video result matching
LJR199887 Apr 17, 2026
0cce2a6
Tighten video task polling timeouts
LJR199887 Apr 18, 2026
c25e873
Lower task timeout default
LJR199887 Apr 20, 2026
1938952
Grace Sora and Veo not found polling
LJR199887 Apr 20, 2026
0fc1489
Handle string video poll errors
LJR199887 Apr 20, 2026
20e46b5
Fix creative center Sora2 task mapping
LJR199887 Apr 21, 2026
b2ae918
Adapt creative center for mobile
LJR199887 Apr 21, 2026
b051ff6
Refine creative center mobile layout
LJR199887 Apr 21, 2026
c99a6fb
Fix creative center model description clamp
LJR199887 Apr 21, 2026
06b7e1f
Add gpt-image2 image support
LJR199887 Apr 22, 2026
d45b710
Fix creative center gpt-image2 controls
LJR199887 Apr 22, 2026
3d72cab
Fix gpt-image2 request payload
LJR199887 Apr 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions common/billing_model.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package common

import "strings"

func normalizeBillingModelName(modelName string) string {
return strings.ToLower(strings.TrimSpace(modelName))
}

func IsDurationOnlyBillingModel(modelName string) bool {
name := normalizeBillingModelName(modelName)
if name == "" {
return false
}
if strings.HasPrefix(name, "veo") {
return true
}
return strings.Contains(name, "grok-imagine") && strings.Contains(name, "video")
}

func IsResolutionOnlyBillingModel(modelName string) bool {
name := normalizeBillingModelName(modelName)
if name == "" {
return false
}
return strings.Contains(name, "banana")
}

func FilterOtherRatiosForBillingModel(modelName string, ratios map[string]float64) map[string]float64 {
if len(ratios) == 0 {
return map[string]float64{}
}

filtered := make(map[string]float64, len(ratios))
switch {
case IsDurationOnlyBillingModel(modelName):
if ratio, ok := ratios["seconds"]; ok && ratio > 0 {
filtered["seconds"] = ratio
}
case IsResolutionOnlyBillingModel(modelName):
return filtered
default:
for key, ratio := range ratios {
if ratio > 0 {
filtered[key] = ratio
}
}
}

return filtered
}
30 changes: 30 additions & 0 deletions common/billing_model_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package common

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestFilterOtherRatiosForDurationOnlyModel(t *testing.T) {
filtered := FilterOtherRatiosForBillingModel("grok-imagine-1.0-video", map[string]float64{
"seconds": 6,
"size": 1.666667,
"resolution": 1.5,
})

assert.Equal(t, map[string]float64{
"seconds": 6,
}, filtered)
}

func TestFilterOtherRatiosForResolutionOnlyModel(t *testing.T) {
filtered := FilterOtherRatiosForBillingModel("nano-banana-pro", map[string]float64{
"resolution": 2,
"quality": 1.5,
"output_resolution": 4,
"n": 3,
})

assert.Empty(t, filtered)
}
2 changes: 2 additions & 0 deletions common/endpoint_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ var defaultEndpointInfoMap = map[constant.EndpointType]EndpointInfo{
constant.EndpointTypeGemini: {Path: "/v1beta/models/{model}:generateContent", Method: "POST"},
constant.EndpointTypeJinaRerank: {Path: "/v1/rerank", Method: "POST"},
constant.EndpointTypeImageGeneration: {Path: "/v1/images/generations", Method: "POST"},
constant.EndpointTypeImageEdit: {Path: "/v1/images/edits", Method: "POST"},
constant.EndpointTypeEmbeddings: {Path: "/v1/embeddings", Method: "POST"},
constant.EndpointTypeOpenAIVideo: {Path: "/v1/video/generations", Method: "POST"},
}

// GetDefaultEndpointInfo 返回指定端点类型的默认信息以及是否存在
Expand Down
6 changes: 5 additions & 1 deletion common/endpoint_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ func GetEndpointTypesByChannelType(channelType int, modelName string) []constant
endpointTypes = []constant.EndpointType{constant.EndpointTypeOpenAI}
}
}
if IsImageGenerationModel(modelName) {
if IsOpenAIVideoModel(modelName) {
endpointTypes = append([]constant.EndpointType{constant.EndpointTypeOpenAIVideo}, endpointTypes...)
} else if IsImageEditModel(modelName) {
endpointTypes = append([]constant.EndpointType{constant.EndpointTypeImageEdit}, endpointTypes...)
} else if IsImageGenerationModel(modelName) {
// add to first
endpointTypes = append([]constant.EndpointType{constant.EndpointTypeImageGeneration}, endpointTypes...)
}
Expand Down
59 changes: 59 additions & 0 deletions common/endpoint_type_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package common

import (
"testing"

"github.com/QuantumNous/new-api/constant"
)

func TestGetEndpointTypesByChannelTypeRecognizesGrokImagineImageModels(t *testing.T) {
tests := []struct {
name string
channel int
model string
expected constant.EndpointType
}{
{
name: "grok imagine 1.0 generation",
channel: constant.ChannelTypeXai,
model: "grok-imagine-1.0",
expected: constant.EndpointTypeImageGeneration,
},
{
name: "grok imagine 1.0 fast generation",
channel: constant.ChannelTypeXai,
model: "grok-imagine-1.0-fast",
expected: constant.EndpointTypeImageGeneration,
},
{
name: "grok imagine 1.0 edit",
channel: constant.ChannelTypeXai,
model: "grok-imagine-1.0-edit",
expected: constant.EndpointTypeImageEdit,
},
{
name: "grok imagine 1.0 video on xai",
channel: constant.ChannelTypeXai,
model: "grok-imagine-1.0-video",
expected: constant.EndpointTypeOpenAIVideo,
},
{
name: "grok imagine video stays video",
channel: constant.ChannelTypeSora,
model: "grok-imagine-1.0-video",
expected: constant.EndpointTypeOpenAIVideo,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := GetEndpointTypesByChannelType(tt.channel, tt.model)
if len(got) == 0 {
t.Fatalf("expected endpoint types for %s", tt.model)
}
if got[0] != tt.expected {
t.Fatalf("expected first endpoint %s, got %s", tt.expected, got[0])
}
})
}
}
4 changes: 3 additions & 1 deletion common/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ func initConstantEnv() {
// 任务轮询时查询的最大数量
constant.TaskQueryLimit = GetEnvOrDefault("TASK_QUERY_LIMIT", 1000)
// 异步任务超时时间(分钟),超过此时间未完成的任务将被标记为失败并退款。0 表示禁用。
constant.TaskTimeoutMinutes = GetEnvOrDefault("TASK_TIMEOUT_MINUTES", 1440)
constant.TaskTimeoutMinutes = GetEnvOrDefault("TASK_TIMEOUT_MINUTES", 20)
// 视频轮询遇到泛化 404 Not Found 时的宽限时间(分钟)。0 表示立即失败。
constant.TaskNotFoundGraceMinutes = GetEnvOrDefault("TASK_NOT_FOUND_GRACE_MINUTES", 10)

soraPatchStr := GetEnvOrDefaultString("TASK_PRICE_PATCH", "")
if soraPatchStr != "" {
Expand Down
45 changes: 45 additions & 0 deletions common/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@ var (
"dall-e-3",
"dall-e-2",
"gpt-image-1",
"gpt-image2",
"exact:grok-imagine-1.0",
"exact:grok-imagine-1.0-fast",
"prefix:imagen-",
"flux-",
"flux.1-",
}
ImageEditModels = []string{
"exact:grok-imagine-1.0-edit",
}
OpenAIVideoModels = []string{
"exact:grok-imagine-1.0-video",
"exact:grok-imagine-video",
}
OpenAITextModels = []string{
"gpt-",
"o1",
Expand All @@ -38,6 +48,41 @@ func IsOpenAIResponseOnlyModel(modelName string) bool {
func IsImageGenerationModel(modelName string) bool {
modelName = strings.ToLower(modelName)
for _, m := range ImageGenerationModels {
if strings.HasPrefix(m, "exact:") && modelName == strings.TrimPrefix(m, "exact:") {
return true
}
if strings.Contains(modelName, m) {
return true
}
if strings.HasPrefix(m, "prefix:") && strings.HasPrefix(modelName, strings.TrimPrefix(m, "prefix:")) {
return true
}
}
return false
}

func IsImageEditModel(modelName string) bool {
modelName = strings.ToLower(modelName)
for _, m := range ImageEditModels {
if strings.HasPrefix(m, "exact:") && modelName == strings.TrimPrefix(m, "exact:") {
return true
}
if strings.Contains(modelName, m) {
return true
}
if strings.HasPrefix(m, "prefix:") && strings.HasPrefix(modelName, strings.TrimPrefix(m, "prefix:")) {
return true
}
}
return false
}

func IsOpenAIVideoModel(modelName string) bool {
modelName = strings.ToLower(modelName)
for _, m := range OpenAIVideoModels {
if strings.HasPrefix(m, "exact:") && modelName == strings.TrimPrefix(m, "exact:") {
return true
}
if strings.Contains(modelName, m) {
return true
}
Expand Down
1 change: 1 addition & 0 deletions constant/endpoint_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const (
EndpointTypeGemini EndpointType = "gemini"
EndpointTypeJinaRerank EndpointType = "jina-rerank"
EndpointTypeImageGeneration EndpointType = "image-generation"
EndpointTypeImageEdit EndpointType = "image-edit"
EndpointTypeEmbeddings EndpointType = "embeddings"
EndpointTypeOpenAIVideo EndpointType = "openai-video"
//EndpointTypeMidjourney EndpointType = "midjourney-proxy"
Expand Down
1 change: 1 addition & 0 deletions constant/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var GenerateDefaultToken bool
var ErrorLogEnabled bool
var TaskQueryLimit int
var TaskTimeoutMinutes int
var TaskNotFoundGraceMinutes int

// temporary variable for sora patch, will be removed in future
var TaskPricePatches []string
Expand Down
2 changes: 2 additions & 0 deletions constant/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const (
SunoActionMusic = "MUSIC"
SunoActionLyrics = "LYRICS"

TaskActionImageGenerate = "imageGenerate"
TaskActionImageEdit = "imageEdit"
TaskActionGenerate = "generate"
TaskActionTextGenerate = "textGenerate"
TaskActionFirstTailGenerate = "firstTailGenerate"
Expand Down
Loading