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
e1597379
authored
Sep 29, 2023
by
JustSong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: sync model schema
parent
7fff6576
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
5 deletions
+4
-5
model/channel.go
+1
-1
model/log.go
+3
-4
No files found.
model/channel.go
View file @
e1597379
...
@@ -11,7 +11,7 @@ type Channel struct {
...
@@ -11,7 +11,7 @@ type Channel struct {
Key
string
`json:"key" gorm:"not null;index"`
Key
string
`json:"key" gorm:"not null;index"`
Status
int
`json:"status" gorm:"default:1"`
Status
int
`json:"status" gorm:"default:1"`
Name
string
`json:"name" gorm:"index"`
Name
string
`json:"name" gorm:"index"`
Weight
int
`json:"weight
"`
Weight
*
uint
`json:"weight" gorm:"default:0
"`
CreatedTime
int64
`json:"created_time" gorm:"bigint"`
CreatedTime
int64
`json:"created_time" gorm:"bigint"`
TestTime
int64
`json:"test_time" gorm:"bigint"`
TestTime
int64
`json:"test_time" gorm:"bigint"`
ResponseTime
int
`json:"response_time"`
// in milliseconds
ResponseTime
int
`json:"response_time"`
// in milliseconds
...
...
model/log.go
View file @
e1597379
...
@@ -9,7 +9,7 @@ import (
...
@@ -9,7 +9,7 @@ import (
type
Log
struct
{
type
Log
struct
{
Id
int
`json:"id"`
Id
int
`json:"id"`
UserId
int
`json:"user_id"`
UserId
int
`json:"user_id"
gorm:"index"
`
CreatedAt
int64
`json:"created_at" gorm:"bigint;index"`
CreatedAt
int64
`json:"created_at" gorm:"bigint;index"`
Type
int
`json:"type" gorm:"index"`
Type
int
`json:"type" gorm:"index"`
Content
string
`json:"content"`
Content
string
`json:"content"`
...
@@ -19,7 +19,7 @@ type Log struct {
...
@@ -19,7 +19,7 @@ type Log struct {
Quota
int
`json:"quota" gorm:"default:0"`
Quota
int
`json:"quota" gorm:"default:0"`
PromptTokens
int
`json:"prompt_tokens" gorm:"default:0"`
PromptTokens
int
`json:"prompt_tokens" gorm:"default:0"`
CompletionTokens
int
`json:"completion_tokens" gorm:"default:0"`
CompletionTokens
int
`json:"completion_tokens" gorm:"default:0"`
Channel
int
`json:"channel" gorm:"default:0
"`
Channel
Id
int
`json:"channel" gorm:"index
"`
}
}
const
(
const
(
...
@@ -47,7 +47,6 @@ func RecordLog(userId int, logType int, content string) {
...
@@ -47,7 +47,6 @@ func RecordLog(userId int, logType int, content string) {
}
}
}
}
func
RecordConsumeLog
(
ctx
context
.
Context
,
userId
int
,
channelId
int
,
promptTokens
int
,
completionTokens
int
,
modelName
string
,
tokenName
string
,
quota
int
,
content
string
)
{
func
RecordConsumeLog
(
ctx
context
.
Context
,
userId
int
,
channelId
int
,
promptTokens
int
,
completionTokens
int
,
modelName
string
,
tokenName
string
,
quota
int
,
content
string
)
{
common
.
LogInfo
(
ctx
,
fmt
.
Sprintf
(
"record consume log: userId=%d, channelId=%d, promptTokens=%d, completionTokens=%d, modelName=%s, tokenName=%s, quota=%d, content=%s"
,
userId
,
channelId
,
promptTokens
,
completionTokens
,
modelName
,
tokenName
,
quota
,
content
))
common
.
LogInfo
(
ctx
,
fmt
.
Sprintf
(
"record consume log: userId=%d, channelId=%d, promptTokens=%d, completionTokens=%d, modelName=%s, tokenName=%s, quota=%d, content=%s"
,
userId
,
channelId
,
promptTokens
,
completionTokens
,
modelName
,
tokenName
,
quota
,
content
))
if
!
common
.
LogConsumeEnabled
{
if
!
common
.
LogConsumeEnabled
{
...
@@ -64,7 +63,7 @@ func RecordConsumeLog(ctx context.Context, userId int, channelId int, promptToke
...
@@ -64,7 +63,7 @@ func RecordConsumeLog(ctx context.Context, userId int, channelId int, promptToke
TokenName
:
tokenName
,
TokenName
:
tokenName
,
ModelName
:
modelName
,
ModelName
:
modelName
,
Quota
:
quota
,
Quota
:
quota
,
Channel
:
channelId
,
Channel
Id
:
channelId
,
}
}
err
:=
DB
.
Create
(
log
)
.
Error
err
:=
DB
.
Create
(
log
)
.
Error
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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