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
6e72e4a5
authored
Jul 14, 2024
by
Calcium-Ion
Committed by
GitHub
Jul 14, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #362 from dalefengs/main
fix: channel timeout auto-ban and auto-enable
parents
fe4665fd
3ef51e92
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
13 deletions
+19
-13
controller/channel-test.go
+19
-13
No files found.
controller/channel-test.go
View file @
6e72e4a5
...
...
@@ -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
{
service
.
DisableChannel
(
channel
.
Id
,
channel
.
Name
,
err
.
Error
())
}
if
!
isChannelEnabled
&&
service
.
ShouldEnableChannel
(
err
,
openaiErr
,
channel
.
Status
)
{
service
.
EnableChannel
(
channel
.
Id
,
channel
.
Name
)
}
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