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
da79af07
authored
Mar 04, 2025
by
1808837298@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: Extract operation-related settings into a separate package
parent
6f64e6cd
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
12 deletions
+15
-12
controller/misc.go
+3
-2
model/option.go
+7
-6
service/channel.go
+2
-2
setting/model-ratio.go
+2
-1
setting/operation_setting/operation_setting.go
+1
-1
No files found.
controller/misc.go
View file @
da79af07
...
...
@@ -7,6 +7,7 @@ import (
"one-api/common"
"one-api/model"
"one-api/setting"
"one-api/setting/operation_setting"
"strings"
"github.com/gin-gonic/gin"
...
...
@@ -66,8 +67,8 @@ func GetStatus(c *gin.Context) {
"enable_online_topup"
:
setting
.
PayAddress
!=
""
&&
setting
.
EpayId
!=
""
&&
setting
.
EpayKey
!=
""
,
"mj_notify_enabled"
:
setting
.
MjNotifyEnabled
,
"chats"
:
setting
.
Chats
,
"demo_site_enabled"
:
setting
.
DemoSiteEnabled
,
"self_use_mode_enabled"
:
setting
.
SelfUseModeEnabled
,
"demo_site_enabled"
:
operation_
setting
.
DemoSiteEnabled
,
"self_use_mode_enabled"
:
operation_
setting
.
SelfUseModeEnabled
,
},
})
return
...
...
model/option.go
View file @
da79af07
...
...
@@ -4,6 +4,7 @@ import (
"one-api/common"
"one-api/setting"
"one-api/setting/config"
"one-api/setting/operation_setting"
"strconv"
"strings"
"time"
...
...
@@ -110,14 +111,14 @@ func InitOptionMap() {
common
.
OptionMap
[
"MjForwardUrlEnabled"
]
=
strconv
.
FormatBool
(
setting
.
MjForwardUrlEnabled
)
common
.
OptionMap
[
"MjActionCheckSuccessEnabled"
]
=
strconv
.
FormatBool
(
setting
.
MjActionCheckSuccessEnabled
)
common
.
OptionMap
[
"CheckSensitiveEnabled"
]
=
strconv
.
FormatBool
(
setting
.
CheckSensitiveEnabled
)
common
.
OptionMap
[
"DemoSiteEnabled"
]
=
strconv
.
FormatBool
(
setting
.
DemoSiteEnabled
)
common
.
OptionMap
[
"SelfUseModeEnabled"
]
=
strconv
.
FormatBool
(
setting
.
SelfUseModeEnabled
)
common
.
OptionMap
[
"DemoSiteEnabled"
]
=
strconv
.
FormatBool
(
operation_
setting
.
DemoSiteEnabled
)
common
.
OptionMap
[
"SelfUseModeEnabled"
]
=
strconv
.
FormatBool
(
operation_
setting
.
SelfUseModeEnabled
)
common
.
OptionMap
[
"ModelRequestRateLimitEnabled"
]
=
strconv
.
FormatBool
(
setting
.
ModelRequestRateLimitEnabled
)
common
.
OptionMap
[
"CheckSensitiveOnPromptEnabled"
]
=
strconv
.
FormatBool
(
setting
.
CheckSensitiveOnPromptEnabled
)
common
.
OptionMap
[
"StopOnSensitiveEnabled"
]
=
strconv
.
FormatBool
(
setting
.
StopOnSensitiveEnabled
)
common
.
OptionMap
[
"SensitiveWords"
]
=
setting
.
SensitiveWordsToString
()
common
.
OptionMap
[
"StreamCacheQueueLength"
]
=
strconv
.
Itoa
(
setting
.
StreamCacheQueueLength
)
common
.
OptionMap
[
"AutomaticDisableKeywords"
]
=
setting
.
AutomaticDisableKeywordsToString
()
common
.
OptionMap
[
"AutomaticDisableKeywords"
]
=
operation_
setting
.
AutomaticDisableKeywordsToString
()
// 自动添加所有注册的模型配置
modelConfigs
:=
config
.
GlobalConfig
.
ExportAllConfigs
()
...
...
@@ -243,9 +244,9 @@ func updateOptionMap(key string, value string) (err error) {
case
"CheckSensitiveEnabled"
:
setting
.
CheckSensitiveEnabled
=
boolValue
case
"DemoSiteEnabled"
:
setting
.
DemoSiteEnabled
=
boolValue
operation_
setting
.
DemoSiteEnabled
=
boolValue
case
"SelfUseModeEnabled"
:
setting
.
SelfUseModeEnabled
=
boolValue
operation_
setting
.
SelfUseModeEnabled
=
boolValue
case
"CheckSensitiveOnPromptEnabled"
:
setting
.
CheckSensitiveOnPromptEnabled
=
boolValue
case
"ModelRequestRateLimitEnabled"
:
...
...
@@ -365,7 +366,7 @@ func updateOptionMap(key string, value string) (err error) {
case
"SensitiveWords"
:
setting
.
SensitiveWordsFromString
(
value
)
case
"AutomaticDisableKeywords"
:
setting
.
AutomaticDisableKeywordsFromString
(
value
)
operation_
setting
.
AutomaticDisableKeywordsFromString
(
value
)
case
"StreamCacheQueueLength"
:
setting
.
StreamCacheQueueLength
,
_
=
strconv
.
Atoi
(
value
)
}
...
...
service/channel.go
View file @
da79af07
...
...
@@ -6,7 +6,7 @@ import (
"one-api/common"
"one-api/dto"
"one-api/model"
"one-api/setting"
"one-api/setting
/operation_setting
"
"strings"
)
...
...
@@ -67,7 +67,7 @@ func ShouldDisableChannel(channelType int, err *dto.OpenAIErrorWithStatusCode) b
}
lowerMessage
:=
strings
.
ToLower
(
err
.
Error
.
Message
)
search
,
_
:=
AcSearch
(
lowerMessage
,
setting
.
AutomaticDisableKeywords
,
true
)
search
,
_
:=
AcSearch
(
lowerMessage
,
operation_
setting
.
AutomaticDisableKeywords
,
true
)
if
search
{
return
true
}
...
...
setting/model-ratio.go
View file @
da79af07
...
...
@@ -3,6 +3,7 @@ package setting
import
(
"encoding/json"
"one-api/common"
"one-api/setting/operation_setting"
"strings"
"sync"
)
...
...
@@ -326,7 +327,7 @@ func GetModelRatio(name string) (float64, bool) {
ratio
,
ok
:=
modelRatioMap
[
name
]
if
!
ok
{
common
.
SysError
(
"model ratio not found: "
+
name
)
return
37.5
,
SelfUseModeEnabled
return
37.5
,
operation_setting
.
SelfUseModeEnabled
}
return
ratio
,
true
}
...
...
setting/operation_setting.go
→
setting/operation_setting
/operation_setting
.go
View file @
da79af07
package
setting
package
operation_
setting
import
"strings"
...
...
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