feat(openai): add moderation action
This commit is contained in:
@@ -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,
|
||||
});
|
||||
},
|
||||
});
|
3
packages/backend/src/apps/openai/actions/index.ts
Normal file
3
packages/backend/src/apps/openai/actions/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import checkModeration from './check-moderation';
|
||||
|
||||
export default [checkModeration];
|
@@ -1,6 +1,7 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import addAuthHeader from './common/add-auth-header';
|
||||
import auth from './auth';
|
||||
import actions from './actions';
|
||||
|
||||
export default defineApp({
|
||||
name: 'OpenAI',
|
||||
@@ -13,4 +14,5 @@ export default defineApp({
|
||||
supportsConnections: true,
|
||||
beforeRequest: [addAuthHeader],
|
||||
auth,
|
||||
actions,
|
||||
});
|
||||
|
Reference in New Issue
Block a user