Files
portkey-ai--gateway/plugins/qualifire/contentModeration.ts
T
wehub-resource-sync 3cd11ababe
Check Markdown links / linkChecker (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:38:56 +08:00

30 lines
676 B
TypeScript

import {
HookEventType,
PluginContext,
PluginHandler,
PluginParameters,
} from '../types';
import { postQualifire } from './globals';
export const handler: PluginHandler = async (
context: PluginContext,
parameters: PluginParameters,
eventType: HookEventType
) => {
const evaluationBody: any = {
input: context.request.text,
content_moderation_check: true,
};
if (eventType === 'afterRequestHook') {
evaluationBody.output = context.response.text;
}
try {
return await postQualifire(evaluationBody, parameters?.credentials?.apiKey);
} catch (e: any) {
delete e.stack;
return { error: e, verdict: false, data: null };
}
};