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