Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d4fbe1ce
authored
Nov 30, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(vertex): ensure sampleCount is a positive integer and update OtherRatios
parent
c2d604b4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
2 deletions
+28
-2
relay/channel/task/vertex/adaptor.go
+28
-2
No files found.
relay/channel/task/vertex/adaptor.go
View file @
d4fbe1ce
...
@@ -12,7 +12,6 @@ import (
...
@@ -12,7 +12,6 @@ import (
"github.com/QuantumNous/new-api/common"
"github.com/QuantumNous/new-api/common"
"github.com/QuantumNous/new-api/model"
"github.com/QuantumNous/new-api/model"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"github.com/QuantumNous/new-api/constant"
"github.com/QuantumNous/new-api/constant"
...
@@ -147,13 +146,40 @@ func (a *TaskAdaptor) BuildRequestBody(c *gin.Context, info *relaycommon.RelayIn
...
@@ -147,13 +146,40 @@ func (a *TaskAdaptor) BuildRequestBody(c *gin.Context, info *relaycommon.RelayIn
body
.
Parameters
[
"storageUri"
]
=
v
body
.
Parameters
[
"storageUri"
]
=
v
}
}
if
v
,
ok
:=
req
.
Metadata
[
"sampleCount"
];
ok
{
if
v
,
ok
:=
req
.
Metadata
[
"sampleCount"
];
ok
{
body
.
Parameters
[
"sampleCount"
]
=
v
if
i
,
ok
:=
v
.
(
int
);
ok
{
body
.
Parameters
[
"sampleCount"
]
=
i
}
if
f
,
ok
:=
v
.
(
float64
);
ok
{
body
.
Parameters
[
"sampleCount"
]
=
int
(
f
)
}
}
}
}
}
if
_
,
ok
:=
body
.
Parameters
[
"sampleCount"
];
!
ok
{
if
_
,
ok
:=
body
.
Parameters
[
"sampleCount"
];
!
ok
{
body
.
Parameters
[
"sampleCount"
]
=
1
body
.
Parameters
[
"sampleCount"
]
=
1
}
}
if
body
.
Parameters
[
"sampleCount"
]
.
(
int
)
<=
0
{
return
nil
,
fmt
.
Errorf
(
"sampleCount must be greater than 0"
)
}
// if req.Duration > 0 {
// body.Parameters["durationSeconds"] = req.Duration
// } else if req.Seconds != "" {
// seconds, err := strconv.Atoi(req.Seconds)
// if err != nil {
// return nil, errors.Wrap(err, "convert seconds to int failed")
// }
// body.Parameters["durationSeconds"] = seconds
// }
info
.
PriceData
.
OtherRatios
=
map
[
string
]
float64
{
"sampleCount"
:
float64
(
body
.
Parameters
[
"sampleCount"
]
.
(
int
)),
}
// if v, ok := body.Parameters["durationSeconds"]; ok {
// info.PriceData.OtherRatios["durationSeconds"] = float64(v.(int))
// }
data
,
err
:=
json
.
Marshal
(
body
)
data
,
err
:=
json
.
Marshal
(
body
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment