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
3d69bb7e
authored
Jan 25, 2024
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add midjourney price log
parent
ddec450b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
4 deletions
+6
-4
common/model-ratio.go
+4
-2
controller/relay-mj.go
+1
-1
controller/relay-text.go
+1
-1
No files found.
common/model-ratio.go
View file @
3d69bb7e
...
...
@@ -103,13 +103,15 @@ func UpdateModelPriceByJSONString(jsonStr string) error {
return
json
.
Unmarshal
([]
byte
(
jsonStr
),
&
ModelPrice
)
}
func
GetModelPrice
(
name
string
)
float64
{
func
GetModelPrice
(
name
string
,
printErr
bool
)
float64
{
if
strings
.
HasPrefix
(
name
,
"gpt-4-gizmo"
)
{
name
=
"gpt-4-gizmo-*"
}
price
,
ok
:=
ModelPrice
[
name
]
if
!
ok
{
//SysError("model price not found: " + name)
if
printErr
{
SysError
(
"model price not found: "
+
name
)
}
return
-
1
}
return
price
...
...
controller/relay-mj.go
View file @
3d69bb7e
...
...
@@ -392,7 +392,7 @@ func relayMidjourneySubmit(c *gin.Context, relayMode int) *MidjourneyResponse {
requestBody
=
c
.
Request
.
Body
}
mjAction
:=
"mj_"
+
strings
.
ToLower
(
midjRequest
.
Action
)
modelPrice
:=
common
.
GetModelPrice
(
mjAction
)
modelPrice
:=
common
.
GetModelPrice
(
mjAction
,
true
)
// 如果没有配置价格,则使用默认价格
if
modelPrice
==
-
1
{
defaultPrice
,
ok
:=
DefaultModelPrice
[
mjAction
]
...
...
controller/relay-text.go
View file @
3d69bb7e
...
...
@@ -232,7 +232,7 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
case
RelayModeModerations
:
promptTokens
=
countTokenInput
(
textRequest
.
Input
,
textRequest
.
Model
)
}
modelPrice
:=
common
.
GetModelPrice
(
textRequest
.
Model
)
modelPrice
:=
common
.
GetModelPrice
(
textRequest
.
Model
,
false
)
groupRatio
:=
common
.
GetGroupRatio
(
group
)
var
preConsumedQuota
int
...
...
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