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
be2c13fb
authored
Mar 20, 2024
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 保留功能
parent
580f2894
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
0 deletions
+20
-0
constant/sensitive.go
+3
-0
model/option.go
+3
-0
web/src/components/OperationSetting.js
+14
-0
No files found.
constant/sensitive.go
View file @
be2c13fb
...
@@ -9,6 +9,9 @@ var CheckSensitiveOnCompletionEnabled = true
...
@@ -9,6 +9,9 @@ var CheckSensitiveOnCompletionEnabled = true
// StopOnSensitiveEnabled 如果检测到敏感词,是否立刻停止生成,否则替换敏感词
// StopOnSensitiveEnabled 如果检测到敏感词,是否立刻停止生成,否则替换敏感词
var
StopOnSensitiveEnabled
=
true
var
StopOnSensitiveEnabled
=
true
// StreamCacheQueueLength 流模式缓存队列长度,0表示无缓存
var
StreamCacheQueueLength
=
0
// SensitiveWords 敏感词
// SensitiveWords 敏感词
// var SensitiveWords []string
// var SensitiveWords []string
var
SensitiveWords
=
[]
string
{
var
SensitiveWords
=
[]
string
{
...
...
model/option.go
View file @
be2c13fb
...
@@ -95,6 +95,7 @@ func InitOptionMap() {
...
@@ -95,6 +95,7 @@ func InitOptionMap() {
common
.
OptionMap
[
"CheckSensitiveOnCompletionEnabled"
]
=
strconv
.
FormatBool
(
constant
.
CheckSensitiveOnCompletionEnabled
)
common
.
OptionMap
[
"CheckSensitiveOnCompletionEnabled"
]
=
strconv
.
FormatBool
(
constant
.
CheckSensitiveOnCompletionEnabled
)
common
.
OptionMap
[
"StopOnSensitiveEnabled"
]
=
strconv
.
FormatBool
(
constant
.
StopOnSensitiveEnabled
)
common
.
OptionMap
[
"StopOnSensitiveEnabled"
]
=
strconv
.
FormatBool
(
constant
.
StopOnSensitiveEnabled
)
common
.
OptionMap
[
"SensitiveWords"
]
=
constant
.
SensitiveWordsToString
()
common
.
OptionMap
[
"SensitiveWords"
]
=
constant
.
SensitiveWordsToString
()
common
.
OptionMap
[
"StreamCacheQueueLength"
]
=
strconv
.
Itoa
(
constant
.
StreamCacheQueueLength
)
common
.
OptionMapRWMutex
.
Unlock
()
common
.
OptionMapRWMutex
.
Unlock
()
loadOptionsFromDatabase
()
loadOptionsFromDatabase
()
...
@@ -288,6 +289,8 @@ func updateOptionMap(key string, value string) (err error) {
...
@@ -288,6 +289,8 @@ func updateOptionMap(key string, value string) (err error) {
common
.
QuotaPerUnit
,
_
=
strconv
.
ParseFloat
(
value
,
64
)
common
.
QuotaPerUnit
,
_
=
strconv
.
ParseFloat
(
value
,
64
)
case
"SensitiveWords"
:
case
"SensitiveWords"
:
constant
.
SensitiveWordsFromString
(
value
)
constant
.
SensitiveWordsFromString
(
value
)
case
"StreamCacheQueueLength"
:
constant
.
StreamCacheQueueLength
,
_
=
strconv
.
Atoi
(
value
)
}
}
return
err
return
err
}
}
web/src/components/OperationSetting.js
View file @
be2c13fb
...
@@ -10,6 +10,7 @@ const OperationSetting = () => {
...
@@ -10,6 +10,7 @@ const OperationSetting = () => {
QuotaForInvitee
:
0
,
QuotaForInvitee
:
0
,
QuotaRemindThreshold
:
0
,
QuotaRemindThreshold
:
0
,
PreConsumedQuota
:
0
,
PreConsumedQuota
:
0
,
StreamCacheQueueLength
:
0
,
ModelRatio
:
''
,
ModelRatio
:
''
,
ModelPrice
:
''
,
ModelPrice
:
''
,
GroupRatio
:
''
,
GroupRatio
:
''
,
...
@@ -307,6 +308,8 @@ const OperationSetting = () => {
...
@@ -307,6 +308,8 @@ const OperationSetting = () => {
name
=
"CheckSensitiveOnCompletionEnabled"
name
=
"CheckSensitiveOnCompletionEnabled"
onChange
=
{
handleInputChange
}
onChange
=
{
handleInputChange
}
/
>
/
>
<
/Form.Group
>
<
Form
.
Group
inline
>
<
Form
.
Checkbox
<
Form
.
Checkbox
checked
=
{
inputs
.
StopOnSensitiveEnabled
===
'true'
}
checked
=
{
inputs
.
StopOnSensitiveEnabled
===
'true'
}
label
=
"在检测到屏蔽词时,立刻停止生成,否则替换屏蔽词"
label
=
"在检测到屏蔽词时,立刻停止生成,否则替换屏蔽词"
...
@@ -314,6 +317,17 @@ const OperationSetting = () => {
...
@@ -314,6 +317,17 @@ const OperationSetting = () => {
onChange
=
{
handleInputChange
}
onChange
=
{
handleInputChange
}
/
>
/
>
<
/Form.Group
>
<
/Form.Group
>
{
/*<Form.Group>*/
}
{
/* <Form.Input*/
}
{
/* label="流模式下缓存队列,默认不缓存,设置越大检测越准确,但是回复会有卡顿感"*/
}
{
/* name="StreamCacheTextLength"*/
}
{
/* onChange={handleInputChange}*/
}
{
/* value={inputs.StreamCacheQueueLength}*/
}
{
/* type="number"*/
}
{
/* min="0"*/
}
{
/* placeholder="例如:10"*/
}
{
/* />*/
}
{
/*</Form.Group>*/
}
<
Form
.
Group
widths
=
"equal"
>
<
Form
.
Group
widths
=
"equal"
>
<
Form
.
TextArea
<
Form
.
TextArea
label
=
"屏蔽词列表,一行一个屏蔽词,不需要符号分割"
label
=
"屏蔽词列表,一行一个屏蔽词,不需要符号分割"
...
...
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