Skip to content

Commit

Permalink
fix: update types, guardrail functions
Browse files Browse the repository at this point in the history
  • Loading branch information
b4s36t4 committed Dec 26, 2024
1 parent 9aba645 commit 578fce7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 25 deletions.
23 changes: 3 additions & 20 deletions plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,6 @@ import { handler as patronusretrievalAnswerRelevance } from './patronus/retrieva
import { handler as patronustoxicity } from './patronus/toxicity';
import { handler as patronuscustom } from './patronus/custom';
import { mistralGuardrailHandler } from './mistral';
import { PluginHandler } from './types';

const mistralGuardCategories = [
'sexual',
'hate_and_discrimination',
'violence_and_threats',
'dangerous_and_criminal_content',
'selfharm',
'health',
'financial',
'law',
'pii',
];
import { handler as pangeatextGuard } from './pangea/textGuard';

export const plugins = {
Expand Down Expand Up @@ -95,13 +82,9 @@ export const plugins = {
toxicity: patronustoxicity,
custom: patronuscustom,
},
mistral: mistralGuardCategories.reduce(
(config, category) => {
config[category] = mistralGuardrailHandler;
return config;
},
{} as Record<string, PluginHandler>
),
mistral: {
moderateContent: mistralGuardrailHandler,
},
pangea: {
textGuard: pangeatextGuard,
},
Expand Down
4 changes: 1 addition & 3 deletions plugins/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,5 @@ export type PluginHandler = (
eventType: HookEventType,
options?: {
env: Record<string, any>;
},
// Handler function, useful in cases for a provider with multiple guardrails ex: mistral
fn?: string
}
) => Promise<PluginHandlerResponse>;
3 changes: 1 addition & 2 deletions src/middlewares/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,7 @@ export class HooksManager {
context,
check.parameters,
eventType,
options,
fn
options
);
return {
...result,
Expand Down

0 comments on commit 578fce7

Please sign in to comment.