ResponsibleAI - Input Moderation - Renaming of files for better clarity and alignment to functionality
This commit is contained in:
parent
c274085d42
commit
b3f44e0495
|
|
@ -7,7 +7,7 @@ import { BaseOutputParser } from 'langchain/schema/output_parser'
|
|||
import { formatResponse, injectOutputParser } from '../../outputparsers/OutputParserHelpers'
|
||||
import { BaseLLMOutputParser } from 'langchain/schema/output_parser'
|
||||
import { OutputFixingParser } from 'langchain/output_parsers'
|
||||
import { checkInputs, Moderation, streamResponse } from '../../responsibleAI/ResponsibleAI'
|
||||
import { checkInputs, Moderation, streamResponse } from '../../moderation/Moderation'
|
||||
|
||||
class LLMChain_Chains implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { Server } from 'socket.io'
|
||||
|
||||
export abstract class ResponsibleAI {}
|
||||
|
||||
export abstract class Moderation extends ResponsibleAI {
|
||||
export abstract class Moderation {
|
||||
abstract checkForViolations(llm: BaseLanguageModel, input: string): Promise<string>
|
||||
}
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src'
|
||||
import { Moderation } from '../ResponsibleAI'
|
||||
import { Moderation } from '../Moderation'
|
||||
import { OpenAIModerationRunner } from './OpenAIModerationRunner'
|
||||
|
||||
class OpenAIModeration implements INode {
|
||||
|
|
@ -20,7 +20,7 @@ class OpenAIModeration implements INode {
|
|||
this.version = 1.0
|
||||
this.type = 'Moderation'
|
||||
this.icon = 'openai-moderation.png'
|
||||
this.category = 'Responsible AI'
|
||||
this.category = 'Moderation'
|
||||
this.description = 'Check whether content complies with OpenAI usage policies.'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(Moderation)]
|
||||
this.inputs = [
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { Moderation } from '../ResponsibleAI'
|
||||
import { Moderation } from '../Moderation'
|
||||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { OpenAIModerationChain } from 'langchain/chains'
|
||||
|
||||
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
|
|
@ -1,6 +1,6 @@
|
|||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src'
|
||||
import { Moderation } from '../ResponsibleAI'
|
||||
import { Moderation } from '../Moderation'
|
||||
import { SimplePromptModerationRunner } from './SimplePromptModerationRunner'
|
||||
|
||||
class SimplePromptModeration implements INode {
|
||||
|
|
@ -20,7 +20,7 @@ class SimplePromptModeration implements INode {
|
|||
this.version = 1.0
|
||||
this.type = 'Moderation'
|
||||
this.icon = 'simple_moderation.png'
|
||||
this.category = 'Responsible AI'
|
||||
this.category = 'Moderation'
|
||||
this.description = 'Check whether input consists of any text from Deny list, and prevent being sent to LLM'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(Moderation)]
|
||||
this.inputs = [
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { Moderation } from '../ResponsibleAI'
|
||||
import { Moderation } from '../Moderation'
|
||||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
|
||||
export class SimplePromptModerationRunner implements Moderation {
|
||||
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
|
|
@ -17,8 +17,8 @@
|
|||
"version": 1,
|
||||
"name": "inputModerationOpenAI",
|
||||
"type": "Moderation",
|
||||
"baseClasses": ["Moderation", "ResponsibleAI"],
|
||||
"category": "Responsible AI",
|
||||
"baseClasses": ["Moderation"],
|
||||
"category": "Moderation",
|
||||
"description": "Check whether content complies with OpenAI usage policies.",
|
||||
"inputParams": [
|
||||
{
|
||||
|
|
@ -37,10 +37,10 @@
|
|||
},
|
||||
"outputAnchors": [
|
||||
{
|
||||
"id": "inputModerationOpenAI_0-output-inputModerationOpenAI-Moderation|ResponsibleAI",
|
||||
"id": "inputModerationOpenAI_0-output-inputModerationOpenAI-Moderation|Moderation",
|
||||
"name": "inputModerationOpenAI",
|
||||
"label": "Moderation",
|
||||
"type": "Moderation | ResponsibleAI"
|
||||
"type": "Moderation"
|
||||
}
|
||||
],
|
||||
"outputs": {},
|
||||
|
|
@ -406,11 +406,11 @@
|
|||
"edges": [
|
||||
{
|
||||
"source": "inputModerationOpenAI_0",
|
||||
"sourceHandle": "inputModerationOpenAI_0-output-inputModerationOpenAI-Moderation|ResponsibleAI",
|
||||
"sourceHandle": "inputModerationOpenAI_0-output-inputModerationOpenAI-Moderation|Moderation",
|
||||
"target": "llmChain_0",
|
||||
"targetHandle": "llmChain_0-input-inputModeration-Moderation",
|
||||
"type": "buttonedge",
|
||||
"id": "inputModerationOpenAI_0-inputModerationOpenAI_0-output-inputModerationOpenAI-Moderation|ResponsibleAI-llmChain_0-llmChain_0-input-inputModeration-Moderation",
|
||||
"id": "inputModerationOpenAI_0-inputModerationOpenAI_0-output-inputModerationOpenAI-Moderation|Moderation-llmChain_0-llmChain_0-input-inputModeration-Moderation",
|
||||
"data": {
|
||||
"label": ""
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue