mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00
feat: custom-censor-check (#2437)
* feat: custom-censor-check * chore: adjust
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { POST } from './plusRequest';
|
import { POST } from './plusRequest';
|
||||||
|
|
||||||
export const postTextCensor = (data: { text: string }) =>
|
export const postTextCensor = (data: { text: string }) =>
|
||||||
POST<{ code?: number; message: string }>('/common/censor/text_baidu', data)
|
POST<{ code?: number; message: string }>('/common/censor/check', data)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res?.code === 5000) {
|
if (res?.code === 5000) {
|
||||||
return Promise.reject(res);
|
return Promise.reject(res);
|
||||||
|
@@ -112,17 +112,17 @@ export const dispatchChatCompletion = async (props: ChatProps): Promise<ChatResp
|
|||||||
systemPrompt,
|
systemPrompt,
|
||||||
stringQuoteText
|
stringQuoteText
|
||||||
}),
|
}),
|
||||||
async () => {
|
(async () => {
|
||||||
// censor model and system key
|
// censor model and system key
|
||||||
if (modelConstantsData.censor && !user.openaiAccount?.key) {
|
if (modelConstantsData.censor && !user.openaiAccount?.key) {
|
||||||
await postTextCensor({
|
return postTextCensor({
|
||||||
text: `${systemPrompt}
|
text: `${systemPrompt}
|
||||||
${datasetQuoteText}
|
${datasetQuoteText}
|
||||||
${userChatInput}
|
${userChatInput}
|
||||||
`
|
`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
})()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Get the request messages
|
// Get the request messages
|
||||||
|
Reference in New Issue
Block a user