Skip to content

Commit

Permalink
fix: send config purpose when running in web ui (promptfoo#2504)
Browse files Browse the repository at this point in the history
  • Loading branch information
typpo authored Dec 24, 2024
1 parent 72d4019 commit 38feee1
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 40 deletions.
81 changes: 41 additions & 40 deletions src/app/src/pages/redteam/setup/hooks/useRedTeamConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,46 +75,6 @@ const defaultConfig: Config = {
},
};

export const EXAMPLE_CONFIG: Config = {
description: 'Red Panda Bamboo Company RAG Example',
prompts: ['{{prompt}}'],
target: {
id: 'http',
label: 'promptfoo-redpanda-rag-example',
config: {
url: 'https://redpanda-internal-rag-example.promptfoo.app/chat',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-session-id': '{{sessionId}}',
},
body: {
input: '{{prompt}}',
role: 'engineering',
},
transformResponse: 'json.response',
sessionParser: 'x-session-id',
},
},
plugins: ['harmful:hate', 'harmful:self-harm', 'rbac'],
strategies: ['jailbreak', 'jailbreak:composite'],
purpose:
'Help employees at Red Panda Bamboo company find information faster from their internal documentation.',
entities: [],
numTests: 5,
applicationDefinition: {
purpose:
'Help employees at Red Panda Bamboo company find information faster from their internal documentation.',
redteamUser: 'An employee in the engineering department',
accessToData: 'General company information like policies and engineering documents',
forbiddenData:
'Anything owned by other departments. Things like future strategy, financial documents, sales documentation and planning, confidential HR information.',
accessToActions: 'Search the documents',
forbiddenActions: '',
connectedSystems: 'Internal company knowledge base',
},
};

const applicationDefinitionToPurpose = (applicationDefinition: Config['applicationDefinition']) => {
const sections = [];

Expand Down Expand Up @@ -153,6 +113,47 @@ const applicationDefinitionToPurpose = (applicationDefinition: Config['applicati
return sections.join('\n\n');
};

const EXAMPLE_APPLICATION_DEFINITION = {
purpose:
'Help employees at Red Panda Bamboo company find information faster from their internal documentation.',
redteamUser: 'An employee in the engineering department',
accessToData: 'General company information like policies and engineering documents',
forbiddenData:
'Anything owned by other departments. Things like future strategy, financial documents, sales documentation and planning, confidential HR information.',
accessToActions: 'Search the documents',
forbiddenActions: '',
connectedSystems: 'Internal company knowledge base',
};

export const EXAMPLE_CONFIG: Config = {
description: 'Red Panda Bamboo Company RAG Example',
prompts: ['{{prompt}}'],
target: {
id: 'http',
label: 'promptfoo-redpanda-rag-example',
config: {
url: 'https://redpanda-internal-rag-example.promptfoo.app/chat',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-session-id': '{{sessionId}}',
},
body: {
input: '{{prompt}}',
role: 'engineering',
},
transformResponse: 'json.response',
sessionParser: 'x-session-id',
},
},
plugins: ['harmful:hate', 'harmful:self-harm', 'rbac'],
strategies: ['jailbreak', 'jailbreak:composite'],
purpose: applicationDefinitionToPurpose(EXAMPLE_APPLICATION_DEFINITION),
entities: [],
numTests: 5,
applicationDefinition: EXAMPLE_APPLICATION_DEFINITION,
};

export const useRedTeamConfig = create<RedTeamConfigState>()(
persist(
(set) => ({
Expand Down
1 change: 1 addition & 0 deletions src/app/src/pages/redteam/setup/utils/yamlHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function getUnifiedConfig(
targets: [config.target],
prompts: config.prompts,
redteam: {
purpose: config.purpose,
numTests: config.numTests,
plugins: config.plugins.map((plugin): RedteamPluginObject => {
if (typeof plugin === 'string') {
Expand Down

0 comments on commit 38feee1

Please sign in to comment.