Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@ import { handler as defaultalllowercase } from './default/alllowercase';
import { handler as defaultendsWith } from './default/endsWith';
import { handler as defaultmodelWhitelist } from './default/modelWhitelist';
import { handler as defaultnotNull } from './default/notNull';
import { handler as qualifireDangerousContent } from './qualifire/dangerousContent';
import { handler as qualifireContentModeration } from './qualifire/contentModeration';
import { handler as qualifireGrounding } from './qualifire/grounding';
import { handler as qualifireHarassment } from './qualifire/harassment';
import { handler as qualifireInstructionFollowing } from './qualifire/instructionFollowing';
import { handler as qualifirePolicy } from './qualifire/policy';
import { handler as qualifireSexualContent } from './qualifire/sexualContent';
import { handler as qualifireToolUseQuality } from './qualifire/toolUseQuality';
import { handler as qualifireHallucinations } from './qualifire/hallucinations';
import { handler as qualifireHateSpeech } from './qualifire/hateSpeech';
import { handler as qualifirePii } from './qualifire/pii';
import { handler as qualifirePromptInjections } from './qualifire/promptInjections';
import { handler as defaultaddPrefix } from './default/addPrefix';
Expand Down Expand Up @@ -94,15 +90,11 @@ export const plugins = {
notNull: defaultnotNull,
},
qualifire: {
dangerousContent: qualifireDangerousContent,
contentModeration: qualifireContentModeration,
grounding: qualifireGrounding,
harassment: qualifireHarassment,
instructionFollowing: qualifireInstructionFollowing,
policy: qualifirePolicy,
sexualContent: qualifireSexualContent,
toolUseQuality: qualifireToolUseQuality,
hallucinations: qualifireHallucinations,
hateSpeech: qualifireHateSpeech,
pii: qualifirePii,
promptInjections: qualifirePromptInjections,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const handler: PluginHandler = async (
) => {
const evaluationBody: any = {
input: context.request.text,
dangerous_content_check: true,
content_moderation_check: true,
};

if (eventType === 'afterRequestHook') {
Expand Down
2 changes: 1 addition & 1 deletion plugins/qualifire/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const postQualifire = async (

const result = await post(BASE_URL, body, options, timeout_millis || 60000);
const error = result?.error || null;
const verdict = result?.status === 'success';
const verdict = result?.status !== 'failed';
const data = result?.evaluationResults;

return { error, verdict, data };
Expand Down
3 changes: 3 additions & 0 deletions plugins/qualifire/grounding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ export const handler: PluginHandler = async (
};
}

const mode = parameters?.mode || 'balanced';

const evaluationBody: any = {
input: context.request.text,
output: context.response.text,
grounding_check: true,
grounding_mode: mode,
};

try {
Expand Down
3 changes: 3 additions & 0 deletions plugins/qualifire/hallucinations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ export const handler: PluginHandler = async (
};
}

const mode = parameters?.mode || 'balanced';

const evaluationBody: any = {
input: context.request.text,
output: context.response.text,
hallucinations_check: true,
hallucinations_mode: mode,
};

try {
Expand Down
29 changes: 0 additions & 29 deletions plugins/qualifire/harassment.ts

This file was deleted.

29 changes: 0 additions & 29 deletions plugins/qualifire/hateSpeech.ts

This file was deleted.

37 changes: 0 additions & 37 deletions plugins/qualifire/instructionFollowing.ts

This file was deleted.

111 changes: 53 additions & 58 deletions plugins/qualifire/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,66 +15,14 @@
},
"functions": [
{
"name": "Hate Speech Check",
"id": "hateSpeech",
"name": "Content Moderation Check",
"id": "contentModeration",
"supportedHooks": ["beforeRequestHook", "afterRequestHook"],
"type": "guardrail",
"description": [
{
"type": "subHeading",
"text": "Checks for hate speech in the user input or model output."
}
],
"parameters": {}
},
{
"name": "Dangerous Content Check",
"id": "dangerousContent",
"supportedHooks": ["beforeRequestHook", "afterRequestHook"],
"type": "guardrail",
"description": [
{
"type": "subHeading",
"text": "Checks for dangerous content in the user input or model output."
}
],
"parameters": {}
},
{
"name": "Sexual Content Check",
"id": "sexualContent",
"supportedHooks": ["beforeRequestHook", "afterRequestHook"],
"type": "guardrail",
"description": [
{
"type": "subHeading",
"text": "Checks for sexual content in the user input or model output."
}
],
"parameters": {}
},
{
"name": "Harassment Check",
"id": "harassment",
"supportedHooks": ["beforeRequestHook", "afterRequestHook"],
"type": "guardrail",
"description": [
{
"type": "subHeading",
"text": "Checks for harassment in the user input or model output."
}
],
"parameters": {}
},
{
"name": "Instruction Following Check",
"id": "instructionFollowing",
"supportedHooks": ["afterRequestHook"],
"type": "guardrail",
"description": [
{
"type": "subHeading",
"text": "Checks that the model followed the instructions provided in the prompt."
"text": "Checks for dangerous content, sexual content, harassment, and dangerous content in the user input or model output."
}
],
"parameters": {}
Expand All @@ -90,7 +38,18 @@
"text": "Checks that the model did not hallucinate."
}
],
"parameters": {}
"parameters": {
"type": "object",
"properties": {
"mode": {
"type": "string",
"label": "Mode",
"description": "The mode to use for the check",
"enum": ["speed", "balanced", "quality"],
"default": "balanced"
}
}
}
},
{
"name": "PII Check",
Expand Down Expand Up @@ -129,7 +88,18 @@
"text": "Checks that the model is grounded in the context provided."
}
],
"parameters": {}
"parameters": {
"type": "object",
"properties": {
"mode": {
"type": "string",
"label": "Mode",
"description": "The mode to use for the check",
"enum": ["speed", "balanced", "quality"],
"default": "balanced"
}
}
}
},
{
"name": "Tool Use Quality Check",
Expand All @@ -142,7 +112,18 @@
"text": "Checks the model's tool use quality. Including correct tool selection, correct tool parameters and values."
}
],
"parameters": {}
"parameters": {
"type": "object",
"properties": {
"mode": {
"type": "string",
"label": "Mode",
"description": "The mode to use for the check",
"enum": ["speed", "balanced", "quality"],
"default": "balanced"
}
}
}
},
{
"name": "Policy Violations Check",
Expand Down Expand Up @@ -170,6 +151,20 @@
}
]
}
},
"mode": {
"type": "string",
"label": "Mode",
"description": "The mode to use for the check",
"enum": ["speed", "balanced", "quality"],
"default": "balanced"
},
"policy_target": {
"type": "string",
"label": "Policy Target",
"description": "Where to apply the policy check",
"enum": ["input", "output", "both"],
"default": "both"
}
},
"required": ["policies"]
Expand Down
16 changes: 14 additions & 2 deletions plugins/qualifire/policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,24 @@ export const handler: PluginHandler = async (
};
}

const mode = parameters?.mode || 'balanced';
const policyTarget = parameters?.policy_target || 'both';

const evaluationBody: any = {
input: context.request.text,
assertions: parameters?.policies,
assertions_mode: mode,
};

if (eventType === 'afterRequestHook') {
// Add input based on policy_target
if (policyTarget === 'input' || policyTarget === 'both') {
evaluationBody.input = context.request.text;
}

// Add output based on policy_target and hook type
if (
eventType === 'afterRequestHook' &&
(policyTarget === 'output' || policyTarget === 'both')
) {
evaluationBody.output = context.response.text;
}

Expand Down
Loading