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
40735b9d
authored
Jan 07, 2024
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复mj固定价格设置无效的问题
parent
2903c230
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
common/model-ratio.go
+1
-1
controller/relay-mj.go
+7
-7
No files found.
common/model-ratio.go
View file @
40735b9d
...
...
@@ -109,7 +109,7 @@ func GetModelPrice(name string) float64 {
}
price
,
ok
:=
ModelPrice
[
name
]
if
!
ok
{
//
SysError("model price not found: " + name)
SysError
(
"model price not found: "
+
name
)
return
-
1
}
return
price
...
...
controller/relay-mj.go
View file @
40735b9d
...
...
@@ -263,8 +263,6 @@ func relayMidjourneySubmit(c *gin.Context, relayMode int) *MidjourneyResponse {
}
}
action
:=
midjRequest
.
Action
if
relayMode
==
RelayModeMidjourneyImagine
{
//绘画任务,此类任务可重复
if
midjRequest
.
Prompt
==
""
{
return
&
MidjourneyResponse
{
...
...
@@ -296,7 +294,7 @@ func relayMidjourneySubmit(c *gin.Context, relayMode int) *MidjourneyResponse {
Description
:
"index_can_only_be_1_2_3_4"
,
}
}
action
=
midjRequest
.
Action
//
action = midjRequest.Action
mjId
=
midjRequest
.
TaskId
}
else
if
relayMode
==
RelayModeMidjourneySimpleChange
{
if
midjRequest
.
Content
==
""
{
...
...
@@ -313,8 +311,9 @@ func relayMidjourneySubmit(c *gin.Context, relayMode int) *MidjourneyResponse {
}
}
mjId
=
params
.
ID
a
ction
=
params
.
Action
midjRequest
.
A
ction
=
params
.
Action
}
originTask
:=
model
.
GetByMJId
(
userId
,
mjId
)
if
originTask
==
nil
{
return
&
MidjourneyResponse
{
...
...
@@ -391,8 +390,9 @@ func relayMidjourneySubmit(c *gin.Context, relayMode int) *MidjourneyResponse {
}
else
{
requestBody
=
c
.
Request
.
Body
}
mjAction
:=
"mj_"
+
strings
.
ToLower
(
a
ction
)
mjAction
:=
"mj_"
+
strings
.
ToLower
(
midjRequest
.
A
ction
)
modelPrice
:=
common
.
GetModelPrice
(
mjAction
)
// 如果没有配置价格,则使用默认价格
if
modelPrice
==
-
1
{
defaultPrice
,
ok
:=
DefaultModelPrice
[
mjAction
]
if
!
ok
{
...
...
@@ -476,7 +476,7 @@ func relayMidjourneySubmit(c *gin.Context, relayMode int) *MidjourneyResponse {
}
if
quota
!=
0
{
tokenName
:=
c
.
GetString
(
"token_name"
)
logContent
:=
fmt
.
Sprintf
(
"模型固定价格 %.2f,分组倍率 %.2f,操作 %s"
,
modelPrice
,
groupRatio
,
a
ction
)
logContent
:=
fmt
.
Sprintf
(
"模型固定价格 %.2f,分组倍率 %.2f,操作 %s"
,
modelPrice
,
groupRatio
,
midjRequest
.
A
ction
)
model
.
RecordConsumeLog
(
ctx
,
userId
,
channelId
,
0
,
0
,
imageModel
,
tokenName
,
quota
,
logContent
,
tokenId
,
userQuota
)
model
.
UpdateUserUsedQuotaAndRequestCount
(
userId
,
quota
)
channelId
:=
c
.
GetInt
(
"channel_id"
)
...
...
@@ -530,7 +530,7 @@ func relayMidjourneySubmit(c *gin.Context, relayMode int) *MidjourneyResponse {
midjourneyTask
:=
&
model
.
Midjourney
{
UserId
:
userId
,
Code
:
midjResponse
.
Code
,
Action
:
a
ction
,
Action
:
midjRequest
.
A
ction
,
MjId
:
midjResponse
.
Result
,
Prompt
:
midjRequest
.
Prompt
,
PromptEn
:
""
,
...
...
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