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
b2680b63
authored
Mar 11, 2024
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复模型映射功能失效 (close #105)
parent
b0eeeeda
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
2 deletions
+4
-2
controller/relay.go
+1
-1
model/redemption.go
+1
-0
relay/relay-text.go
+2
-1
No files found.
controller/relay.go
View file @
b2680b63
...
@@ -38,7 +38,7 @@ func Relay(c *gin.Context) {
...
@@ -38,7 +38,7 @@ func Relay(c *gin.Context) {
retryTimes
=
common
.
RetryTimes
retryTimes
=
common
.
RetryTimes
}
}
if
retryTimes
>
0
{
if
retryTimes
>
0
{
c
.
Redirect
(
http
.
StatusTemporaryRedirect
,
fmt
.
Sprintf
(
"%s?retry=%d
&error=%s"
,
c
.
Request
.
URL
.
Path
,
retryTimes
-
1
,
err
.
Error
.
Message
))
c
.
Redirect
(
http
.
StatusTemporaryRedirect
,
fmt
.
Sprintf
(
"%s?retry=%d
"
,
c
.
Request
.
URL
.
Path
,
retryTimes
-
1
))
}
else
{
}
else
{
if
err
.
StatusCode
==
http
.
StatusTooManyRequests
{
if
err
.
StatusCode
==
http
.
StatusTooManyRequests
{
//err.Error.Message = "当前分组上游负载已饱和,请稍后再试"
//err.Error.Message = "当前分组上游负载已饱和,请稍后再试"
...
...
model/redemption.go
View file @
b2680b63
...
@@ -18,6 +18,7 @@ type Redemption struct {
...
@@ -18,6 +18,7 @@ type Redemption struct {
RedeemedTime
int64
`json:"redeemed_time" gorm:"bigint"`
RedeemedTime
int64
`json:"redeemed_time" gorm:"bigint"`
Count
int
`json:"count" gorm:"-:all"`
// only for api request
Count
int
`json:"count" gorm:"-:all"`
// only for api request
UsedUserId
int
`json:"used_user_id"`
UsedUserId
int
`json:"used_user_id"`
DeletedAt
gorm
.
DeletedAt
`gorm:"index"`
}
}
func
GetAllRedemptions
(
startIdx
int
,
num
int
)
([]
*
Redemption
,
error
)
{
func
GetAllRedemptions
(
startIdx
int
,
num
int
)
([]
*
Redemption
,
error
)
{
...
...
relay/relay-text.go
View file @
b2680b63
...
@@ -60,7 +60,6 @@ func getAndValidateTextRequest(c *gin.Context, relayInfo *relaycommon.RelayInfo)
...
@@ -60,7 +60,6 @@ func getAndValidateTextRequest(c *gin.Context, relayInfo *relaycommon.RelayInfo)
}
}
}
}
relayInfo
.
IsStream
=
textRequest
.
Stream
relayInfo
.
IsStream
=
textRequest
.
Stream
relayInfo
.
UpstreamModelName
=
textRequest
.
Model
return
textRequest
,
nil
return
textRequest
,
nil
}
}
...
@@ -86,9 +85,11 @@ func TextHelper(c *gin.Context) *dto.OpenAIErrorWithStatusCode {
...
@@ -86,9 +85,11 @@ func TextHelper(c *gin.Context) *dto.OpenAIErrorWithStatusCode {
}
}
if
modelMap
[
textRequest
.
Model
]
!=
""
{
if
modelMap
[
textRequest
.
Model
]
!=
""
{
textRequest
.
Model
=
modelMap
[
textRequest
.
Model
]
textRequest
.
Model
=
modelMap
[
textRequest
.
Model
]
// set upstream model name
isModelMapped
=
true
isModelMapped
=
true
}
}
}
}
relayInfo
.
UpstreamModelName
=
textRequest
.
Model
modelPrice
:=
common
.
GetModelPrice
(
textRequest
.
Model
,
false
)
modelPrice
:=
common
.
GetModelPrice
(
textRequest
.
Model
,
false
)
groupRatio
:=
common
.
GetGroupRatio
(
relayInfo
.
Group
)
groupRatio
:=
common
.
GetGroupRatio
(
relayInfo
.
Group
)
...
...
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