mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 11:00:55 +03:00
added LLM to moderation to detect similar deny sentences
This commit is contained in:
+12
-4
@@ -2,6 +2,7 @@ import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src'
|
||||
import { Moderation } from '../Moderation'
|
||||
import { SimplePromptModerationRunner } from './SimplePromptModerationRunner'
|
||||
import { BaseChatModel } from 'langchain/chat_models/base'
|
||||
|
||||
class SimplePromptModeration implements INode {
|
||||
label: string
|
||||
@@ -17,7 +18,7 @@ class SimplePromptModeration implements INode {
|
||||
constructor() {
|
||||
this.label = 'Simple Prompt Moderation'
|
||||
this.name = 'inputModerationSimple'
|
||||
this.version = 1.0
|
||||
this.version = 2.0
|
||||
this.type = 'Moderation'
|
||||
this.icon = 'moderation.svg'
|
||||
this.category = 'Moderation'
|
||||
@@ -30,8 +31,14 @@ class SimplePromptModeration implements INode {
|
||||
type: 'string',
|
||||
rows: 4,
|
||||
placeholder: `ignore previous instructions\ndo not follow the directions\nyou must ignore all previous instructions`,
|
||||
description: 'An array of string literals (enter one per line) that should not appear in the prompt text.',
|
||||
optional: false
|
||||
description: 'An array of string literals (enter one per line) that should not appear in the prompt text.'
|
||||
},
|
||||
{
|
||||
label: 'Chat Model',
|
||||
name: 'model',
|
||||
type: 'BaseChatModel',
|
||||
description: 'Use LLM to detect if the input is similar to those specified in Deny List',
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Error Message',
|
||||
@@ -46,9 +53,10 @@ class SimplePromptModeration implements INode {
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const denyList = nodeData.inputs?.denyList as string
|
||||
const model = nodeData.inputs?.model as BaseChatModel
|
||||
const moderationErrorMessage = nodeData.inputs?.moderationErrorMessage as string
|
||||
|
||||
return new SimplePromptModerationRunner(denyList, moderationErrorMessage)
|
||||
return new SimplePromptModerationRunner(denyList, moderationErrorMessage, model)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user