mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-28 09:03:53 +00:00
content censor
This commit is contained in:
@@ -414,13 +414,13 @@ function loadModules(
|
||||
});
|
||||
}
|
||||
|
||||
function responseStatus({
|
||||
export function responseStatus({
|
||||
res,
|
||||
status,
|
||||
name
|
||||
}: {
|
||||
res: NextApiResponse;
|
||||
status: 'running' | 'finish';
|
||||
status?: 'running' | 'finish';
|
||||
name?: string;
|
||||
}) {
|
||||
if (!name) return;
|
||||
@@ -428,7 +428,7 @@ function responseStatus({
|
||||
res,
|
||||
event: sseResponseEventEnum.moduleStatus,
|
||||
data: JSON.stringify({
|
||||
status,
|
||||
status: 'running',
|
||||
name
|
||||
})
|
||||
});
|
||||
|
@@ -3,3 +3,8 @@ import type { SendCodeBody, AuthCodeBody } from './plugins.d';
|
||||
|
||||
export const sendCode = (data: SendCodeBody) => POST(global.systemPlugins.authCode?.sendUrl, 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);
|
||||
};
|
||||
|
@@ -109,21 +109,21 @@ function request(url: string, data: any, config: ConfigType, method: Method): an
|
||||
* @returns
|
||||
*/
|
||||
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');
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ import { getChatModel } from '@/service/utils/data';
|
||||
import { countModelPrice } from '@/service/events/pushBill';
|
||||
import { ChatModelItemType } from '@/types/model';
|
||||
import { UserModelSchema } from '@/types/mongoSchema';
|
||||
import { textCensor } from '@/service/api/plugins';
|
||||
|
||||
export type ChatProps = {
|
||||
res: NextApiResponse;
|
||||
@@ -63,6 +64,14 @@ export const dispatchChatCompletion = async (props: Record<string, any>): Promis
|
||||
model: modelConstantsData
|
||||
});
|
||||
|
||||
await textCensor({
|
||||
text: `${systemPrompt}
|
||||
${quotePrompt}
|
||||
${limitPrompt}
|
||||
${userChatInput}
|
||||
`
|
||||
});
|
||||
|
||||
const { messages, filterMessages } = getChatMessages({
|
||||
model: modelConstantsData,
|
||||
history,
|
||||
|
4
client/src/types/index.d.ts
vendored
4
client/src/types/index.d.ts
vendored
@@ -37,8 +37,8 @@ export type PluginType = {
|
||||
sendUrl: string;
|
||||
authUrl: string;
|
||||
};
|
||||
moderationsCheck?: {
|
||||
url: string;
|
||||
censor?: {
|
||||
textUrl?: string;
|
||||
};
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user