feat(openai): add moderation action

This commit is contained in:
Ali BARIN
2023-01-17 13:20:36 +01:00
parent 577d5215cd
commit c2579b1850
3 changed files with 34 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
import defineAction from '../../../../helpers/define-action';
export default defineAction({
name: 'Check moderation',
key: 'checkModeration',
description: 'Checks for hate, hate/threatening, self-harm, sexual, sexual/minors, violence, or violence/graphic content in the given text.',
arguments: [
{
label: 'Input',
key: 'input',
type: 'string' as const,
required: true,
variables: true,
description: 'The text to analyze.'
},
],
async run($) {
const { data } = await $.http.post('/v1/moderations', {
input: $.step.parameters.input as string,
});
const result = data?.results[0];
$.setActionItem({
raw: result,
});
},
});