Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
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
Unverified
Commit
236e7d3c
authored
Aug 05, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
content censor
parent
8d3ad943
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
9 deletions
+23
-9
client/src/pages/api/openapi/v1/chat/completions.ts
+3
-3
client/src/service/api/plugins.ts
+5
-0
client/src/service/api/request.ts
+4
-4
client/src/service/moduleDispatch/chat/oneapi.ts
+9
-0
client/src/types/index.d.ts
+2
-2
No files found.
client/src/pages/api/openapi/v1/chat/completions.ts
View file @
236e7d3c
...
@@ -414,13 +414,13 @@ function loadModules(
...
@@ -414,13 +414,13 @@ function loadModules(
});
});
}
}
function
responseStatus
({
export
function
responseStatus
({
res
,
res
,
status
,
status
,
name
name
}:
{
}:
{
res
:
NextApiResponse
;
res
:
NextApiResponse
;
status
:
'running'
|
'finish'
;
status
?
:
'running'
|
'finish'
;
name
?:
string
;
name
?:
string
;
})
{
})
{
if
(
!
name
)
return
;
if
(
!
name
)
return
;
...
@@ -428,7 +428,7 @@ function responseStatus({
...
@@ -428,7 +428,7 @@ function responseStatus({
res
,
res
,
event
:
sseResponseEventEnum
.
moduleStatus
,
event
:
sseResponseEventEnum
.
moduleStatus
,
data
:
JSON
.
stringify
({
data
:
JSON
.
stringify
({
status
,
status
:
'running'
,
name
name
})
})
});
});
...
...
client/src/service/api/plugins.ts
View file @
236e7d3c
...
@@ -3,3 +3,8 @@ import type { SendCodeBody, AuthCodeBody } from './plugins.d';
...
@@ -3,3 +3,8 @@ import type { SendCodeBody, AuthCodeBody } from './plugins.d';
export
const
sendCode
=
(
data
:
SendCodeBody
)
=>
POST
(
global
.
systemPlugins
.
authCode
?.
sendUrl
,
data
);
export
const
sendCode
=
(
data
:
SendCodeBody
)
=>
POST
(
global
.
systemPlugins
.
authCode
?.
sendUrl
,
data
);
export
const
authCode
=
(
data
:
AuthCodeBody
)
=>
POST
(
global
.
systemPlugins
.
authCode
?.
authUrl
,
data
);
export
const
authCode
=
(
data
:
AuthCodeBody
)
=>
POST
(
global
.
systemPlugins
.
authCode
?.
authUrl
,
data
);
export
const
textCensor
=
(
data
:
{
text
:
string
})
=>
{
if
(
!
global
.
systemPlugins
.
censor
?.
textUrl
)
return
;
return
POST
(
global
.
systemPlugins
.
censor
?.
textUrl
,
data
);
};
client/src/service/api/request.ts
View file @
236e7d3c
...
@@ -109,21 +109,21 @@ function request(url: string, data: any, config: ConfigType, method: Method): an
...
@@ -109,21 +109,21 @@ function request(url: string, data: any, config: ConfigType, method: Method): an
* @returns
* @returns
*/
*/
export
function
GET
<
T
>
(
url
?:
string
,
params
=
{},
config
:
ConfigType
=
{}):
Promise
<
T
>
{
export
function
GET
<
T
>
(
url
?:
string
,
params
=
{},
config
:
ConfigType
=
{}):
Promise
<
T
>
{
if
(
!
url
)
return
Promise
.
reject
(
'
no url
'
);
if
(
!
url
)
return
Promise
.
reject
(
'
The Plugin is not installed
'
);
return
request
(
url
,
params
,
config
,
'GET'
);
return
request
(
url
,
params
,
config
,
'GET'
);
}
}
export
function
POST
<
T
>
(
url
?:
string
,
data
=
{},
config
:
ConfigType
=
{}):
Promise
<
T
>
{
export
function
POST
<
T
>
(
url
?:
string
,
data
=
{},
config
:
ConfigType
=
{}):
Promise
<
T
>
{
if
(
!
url
)
return
Promise
.
reject
(
'
no url
'
);
if
(
!
url
)
return
Promise
.
reject
(
'
The Plugin is not installed
'
);
return
request
(
url
,
data
,
config
,
'POST'
);
return
request
(
url
,
data
,
config
,
'POST'
);
}
}
export
function
PUT
<
T
>
(
url
?:
string
,
data
=
{},
config
:
ConfigType
=
{}):
Promise
<
T
>
{
export
function
PUT
<
T
>
(
url
?:
string
,
data
=
{},
config
:
ConfigType
=
{}):
Promise
<
T
>
{
if
(
!
url
)
return
Promise
.
reject
(
'
no url
'
);
if
(
!
url
)
return
Promise
.
reject
(
'
The Plugin is not installed
'
);
return
request
(
url
,
data
,
config
,
'PUT'
);
return
request
(
url
,
data
,
config
,
'PUT'
);
}
}
export
function
DELETE
<
T
>
(
url
?:
string
,
data
=
{},
config
:
ConfigType
=
{}):
Promise
<
T
>
{
export
function
DELETE
<
T
>
(
url
?:
string
,
data
=
{},
config
:
ConfigType
=
{}):
Promise
<
T
>
{
if
(
!
url
)
return
Promise
.
reject
(
'
no url
'
);
if
(
!
url
)
return
Promise
.
reject
(
'
The Plugin is not installed
'
);
return
request
(
url
,
data
,
config
,
'DELETE'
);
return
request
(
url
,
data
,
config
,
'DELETE'
);
}
}
client/src/service/moduleDispatch/chat/oneapi.ts
View file @
236e7d3c
...
@@ -15,6 +15,7 @@ import { getChatModel } from '@/service/utils/data';
...
@@ -15,6 +15,7 @@ import { getChatModel } from '@/service/utils/data';
import
{
countModelPrice
}
from
'@/service/events/pushBill'
;
import
{
countModelPrice
}
from
'@/service/events/pushBill'
;
import
{
ChatModelItemType
}
from
'@/types/model'
;
import
{
ChatModelItemType
}
from
'@/types/model'
;
import
{
UserModelSchema
}
from
'@/types/mongoSchema'
;
import
{
UserModelSchema
}
from
'@/types/mongoSchema'
;
import
{
textCensor
}
from
'@/service/api/plugins'
;
export
type
ChatProps
=
{
export
type
ChatProps
=
{
res
:
NextApiResponse
;
res
:
NextApiResponse
;
...
@@ -63,6 +64,14 @@ export const dispatchChatCompletion = async (props: Record<string, any>): Promis
...
@@ -63,6 +64,14 @@ export const dispatchChatCompletion = async (props: Record<string, any>): Promis
model
:
modelConstantsData
model
:
modelConstantsData
});
});
await
textCensor
({
text
:
`
${
systemPrompt
}
${
quotePrompt
}
${
limitPrompt
}
${
userChatInput
}
`
});
const
{
messages
,
filterMessages
}
=
getChatMessages
({
const
{
messages
,
filterMessages
}
=
getChatMessages
({
model
:
modelConstantsData
,
model
:
modelConstantsData
,
history
,
history
,
...
...
client/src/types/index.d.ts
View file @
236e7d3c
...
@@ -37,8 +37,8 @@ export type PluginType = {
...
@@ -37,8 +37,8 @@ export type PluginType = {
sendUrl
:
string
;
sendUrl
:
string
;
authUrl
:
string
;
authUrl
:
string
;
};
};
moderationsCheck
?:
{
censor
?:
{
url
:
string
;
textUrl
?
:
string
;
};
};
};
};
...
...
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