Repository navigation
Codex/fix grok video url #3489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Codex/fix grok video url #3489
Changes from 37 commits
680271d
988b297
9db210d
f5b1a79
6658556
d31fbb6
8446231
90063cb
2186b57
8e89b09
989f667
37f5126
e20c678
629be09
b69a41e
8e19212
2933917
df6cb95
37f727c
b1b647d
b1a56ec
8671548
3ca517d
ca554ba
1ba2229
2c76490
46909d2
6935974
dd00fc6
c1e2dd1
2f2002b
7626c2a
b0fa9d3
99a6c0d
0e364e5
f0c3684
9338346
e7cde69
0277e88
fb1bea0
f8a210c
cdb0895
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| 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 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]) | ||
| } | ||
| }) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,8 @@ type ImageRequest struct { | |||||||||
| Prompt string `json:"prompt" binding:"required"` | ||||||||||
| N *uint `json:"n,omitempty"` | ||||||||||
| Size string `json:"size,omitempty"` | ||||||||||
| AspectRatio string `json:"aspect_ratio,omitempty"` | ||||||||||
| OutputResolution string `json:"output_resolution,omitempty"` | ||||||||||
|
Comment on lines
+19
to
+20
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Check the actual content of dto/openai_image.go around lines 19-20
sed -n '1,30p' dto/openai_image.goRepository: QuantumNous/new-api Length of output: 1296 🏁 Script executed: # Search for ImageRequest usage in relay/convert paths
rg -A 3 -B 3 "ImageRequest" relay/ --type go | head -100Repository: QuantumNous/new-api Length of output: 5864 🏁 Script executed: # Check if there are similar pointer-typed string fields in other relay DTOs
rg '\*string.*json:.*omitempty' dto/ --type go | head -20Repository: QuantumNous/new-api Length of output: 1056 🏁 Script executed: # Verify whether ImageRequest is marshaled/unmarshaled and where
rg "ImageRequest" . --type go | grep -E "(Marshal|Unmarshal|convert)" | head -20Repository: QuantumNous/new-api Length of output: 985 Make the new optional request fields pointer-typed.
Proposed fix- AspectRatio string `json:"aspect_ratio,omitempty"`
- OutputResolution string `json:"output_resolution,omitempty"`
+ AspectRatio *string `json:"aspect_ratio,omitempty"`
+ OutputResolution *string `json:"output_resolution,omitempty"`📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| Quality string `json:"quality,omitempty"` | ||||||||||
| ResponseFormat string `json:"response_format,omitempty"` | ||||||||||
| Style json.RawMessage `json:"style,omitempty"` | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -46,6 +46,13 @@ type GeneralOpenAIRequest struct { | |||||||||||||||||||||||||||||
| Input any `json:"input,omitempty"` | ||||||||||||||||||||||||||||||
| Instruction string `json:"instruction,omitempty"` | ||||||||||||||||||||||||||||||
| Size string `json:"size,omitempty"` | ||||||||||||||||||||||||||||||
| AspectRatio string `json:"aspect_ratio,omitempty"` | ||||||||||||||||||||||||||||||
| OutputResolution string `json:"output_resolution,omitempty"` | ||||||||||||||||||||||||||||||
| Seconds *string `json:"seconds,omitempty"` | ||||||||||||||||||||||||||||||
| Duration *int `json:"duration,omitempty"` | ||||||||||||||||||||||||||||||
| Quality *string `json:"quality,omitempty"` | ||||||||||||||||||||||||||||||
| Resolution string `json:"resolution,omitempty"` | ||||||||||||||||||||||||||||||
| ReferenceMode string `json:"reference_mode,omitempty"` | ||||||||||||||||||||||||||||||
|
Comment on lines
+49
to
+55
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Find the dto/openai_request.go file and examine the GeneralOpenAIRequest struct
cd / && find . -name "openai_request.go" -path "*/dto/*" 2>/dev/null | head -5Repository: QuantumNous/new-api Length of output: 104 🏁 Script executed: # Check the GeneralOpenAIRequest struct definition
rg "type GeneralOpenAIRequest" --type go -A 50 | head -80Repository: QuantumNous/new-api Length of output: 4621 🏁 Script executed: # Search for usage of GeneralOpenAIRequest in relay/convert paths
rg "GeneralOpenAIRequest" --type go | grep -E "(relay|convert)" | head -20Repository: QuantumNous/new-api Length of output: 2710 Use pointers for the new optional string fields.
🔧 Proposed fix- AspectRatio string `json:"aspect_ratio,omitempty"`
- OutputResolution string `json:"output_resolution,omitempty"`
+ AspectRatio *string `json:"aspect_ratio,omitempty"`
+ OutputResolution *string `json:"output_resolution,omitempty"`
Seconds *string `json:"seconds,omitempty"`
Duration *int `json:"duration,omitempty"`
Quality *string `json:"quality,omitempty"`
- Resolution string `json:"resolution,omitempty"`
- ReferenceMode string `json:"reference_mode,omitempty"`
+ Resolution *string `json:"resolution,omitempty"`
+ ReferenceMode *string `json:"reference_mode,omitempty"`Per coding guidelines for 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| Functions json.RawMessage `json:"functions,omitempty"` | ||||||||||||||||||||||||||||||
| FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"` | ||||||||||||||||||||||||||||||
| PresencePenalty *float64 `json:"presence_penalty,omitempty"` | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the access-token restriction consistent on the new
/pghandlers.Playgroundstill rejectsuse_access_token, but these new image/video handlers skip that check and relay immediately after token setup. That opens a policy gap between the existing playground endpoint and/pg/images/*//pg/video/*.🛠️ Proposed fix
Apply the same guard in
PlaygroundImageGenerations,PlaygroundImageEdits, andPlaygroundVideoFetch.🤖 Prompt for AI Agents