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
8344b66b
authored
Sep 17, 2023
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
合并最新代码
parent
23d95544
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
5 deletions
+7
-5
controller/log.go
+2
-0
controller/relay-mj.go
+5
-4
controller/relay-text.go
+0
-1
No files found.
controller/log.go
View file @
8344b66b
...
...
@@ -2,6 +2,7 @@ package controller
import
(
"github.com/gin-gonic/gin"
"net/http"
"one-api/common"
"one-api/model"
"strconv"
...
...
@@ -123,6 +124,7 @@ func GetLogsStat(c *gin.Context) {
tokenName
:=
c
.
Query
(
"token_name"
)
username
:=
c
.
Query
(
"username"
)
modelName
:=
c
.
Query
(
"model_name"
)
channel
,
_
:=
strconv
.
Atoi
(
c
.
Query
(
"channel"
))
stat
:=
model
.
SumUsedQuota
(
logType
,
startTimestamp
,
endTimestamp
,
modelName
,
username
,
tokenName
,
channel
)
//tokenNum := model.SumUsedToken(logType, startTimestamp, endTimestamp, modelName, username, "")
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
...
...
controller/relay-mj.go
View file @
8344b66b
...
...
@@ -2,6 +2,7 @@ package controller
import
(
"bytes"
"context"
"encoding/json"
"fmt"
"io"
...
...
@@ -145,7 +146,7 @@ func relayMidjourneySubmit(c *gin.Context, relayMode int) *MidjourneyResponse {
userId
:=
c
.
GetInt
(
"id"
)
consumeQuota
:=
c
.
GetBool
(
"consume_quota"
)
group
:=
c
.
GetString
(
"group"
)
channelId
:=
c
.
GetInt
(
"channel_id"
)
var
midjRequest
MidjourneyRequest
if
consumeQuota
{
err
:=
common
.
UnmarshalBodyReusable
(
c
,
&
midjRequest
)
...
...
@@ -308,7 +309,7 @@ func relayMidjourneySubmit(c *gin.Context, relayMode int) *MidjourneyResponse {
}
var
midjResponse
MidjourneyResponse
defer
func
()
{
defer
func
(
ctx
context
.
Context
)
{
if
consumeQuota
{
err
:=
model
.
PostConsumeTokenQuota
(
tokenId
,
quota
)
if
err
!=
nil
{
...
...
@@ -321,13 +322,13 @@ func relayMidjourneySubmit(c *gin.Context, relayMode int) *MidjourneyResponse {
if
quota
!=
0
{
tokenName
:=
c
.
GetString
(
"token_name"
)
logContent
:=
fmt
.
Sprintf
(
"模型倍率 %.2f,分组倍率 %.2f"
,
modelRatio
,
groupRatio
)
model
.
RecordConsumeLog
(
user
Id
,
0
,
0
,
imageModel
,
tokenName
,
quota
,
logContent
,
tokenId
)
model
.
RecordConsumeLog
(
ctx
,
userId
,
channel
Id
,
0
,
0
,
imageModel
,
tokenName
,
quota
,
logContent
,
tokenId
)
model
.
UpdateUserUsedQuotaAndRequestCount
(
userId
,
quota
)
channelId
:=
c
.
GetInt
(
"channel_id"
)
model
.
UpdateChannelUsedQuota
(
channelId
,
quota
)
}
}
}()
}(
c
.
Request
.
Context
()
)
//if consumeQuota {
//
...
...
controller/relay-text.go
View file @
8344b66b
...
...
@@ -372,7 +372,6 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
var
textResponse
TextResponse
tokenName
:=
c
.
GetString
(
"token_name"
)
channelId
:=
c
.
GetInt
(
"channel_id"
)
defer
func
(
ctx
context
.
Context
)
{
// c.Writer.Flush()
...
...
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