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
3ef51e92
authored
Jul 14, 2024
by
FENG
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: channel timeout auto-ban and auto-enable
parent
fe4665fd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
controller/channel-test.go
+15
-9
No files found.
controller/channel-test.go
View file @
3ef51e92
...
...
@@ -231,27 +231,33 @@ func testAllChannels(notify bool) error {
err
=
errors
.
New
(
fmt
.
Sprintf
(
"响应时间 %.2fs 超过阈值 %.2fs"
,
float64
(
milliseconds
)
/
1000.0
,
float64
(
disableThreshold
)
/
1000.0
))
ban
=
true
}
// request error disables the channel
if
openaiErr
!=
nil
{
err
=
errors
.
New
(
fmt
.
Sprintf
(
"type %s, code %v, message %s"
,
openaiErr
.
Type
,
openaiErr
.
Code
,
openaiErr
.
Message
))
ban
=
true
}
// parse *int to bool
if
channel
.
AutoBan
!=
nil
&&
*
channel
.
AutoBan
==
0
{
ban
=
false
}
if
openaiErr
!=
nil
{
openAiErrWithStatus
:=
dto
.
OpenAIErrorWithStatusCode
{
StatusCode
:
-
1
,
Error
:
*
openaiErr
,
LocalError
:
false
,
}
if
isChannelEnabled
&&
service
.
ShouldDisableChannel
(
channel
.
Type
,
&
openAiErrWithStatus
)
&&
ban
{
ban
=
service
.
ShouldDisableChannel
(
channel
.
Type
,
&
openAiErrWithStatus
)
}
// parse *int to bool
if
channel
.
AutoBan
!=
nil
&&
*
channel
.
AutoBan
==
0
{
ban
=
false
}
// disable channel
if
ban
&&
isChannelEnabled
{
service
.
DisableChannel
(
channel
.
Id
,
channel
.
Name
,
err
.
Error
())
}
// enable channel
if
!
isChannelEnabled
&&
service
.
ShouldEnableChannel
(
err
,
openaiErr
,
channel
.
Status
)
{
service
.
EnableChannel
(
channel
.
Id
,
channel
.
Name
)
}
}
channel
.
UpdateResponseTime
(
milliseconds
)
time
.
Sleep
(
common
.
RequestInterval
)
}
...
...
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