-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathquickstart_private_chat.ts
More file actions
82 lines (75 loc) · 2.29 KB
/
quickstart_private_chat.ts
File metadata and controls
82 lines (75 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import {
createAgentChatSettings,
createAgentMediatorPersonaConfig,
createAgentParticipantPersonaConfig,
createChatPromptConfig,
createChatStage,
createExperimentConfig,
createExperimentTemplate,
createMetadataConfig,
createParticipantProfileBase,
createPrivateChatStage,
createProfileStage,
createDefaultPromptFromText,
AgentMediatorTemplate,
AgentParticipantTemplate,
AgentPersonaType,
ExperimentTemplate,
MediatorPromptConfig,
ParticipantPromptConfig,
ProfileType,
StageConfig,
StageKind,
} from '@deliberation-lab/utils';
// ****************************************************************************
// Experiment config
// ****************************************************************************
export function getQuickstartPrivateChatTemplate(): ExperimentTemplate {
const stageConfigs = getStageConfigs();
const metadata = createMetadataConfig({
name: 'Private Chat Experiment',
publicName: 'Private Chat',
description: 'Template experiment with private chat between user and agent',
});
return createExperimentTemplate({
experiment: createExperimentConfig(stageConfigs, {metadata}),
stageConfigs,
agentMediators: [createMediatorAgent()],
agentParticipants: [],
});
}
const CHAT_STAGE_ID = 'chat';
function getStageConfigs(): StageConfig[] {
const stages: StageConfig[] = [];
stages.push(
createProfileStage({profileType: ProfileType.ANONYMOUS_ANIMAL}),
createPrivateChatStage({
id: CHAT_STAGE_ID,
name: 'Private chat with agent',
}),
);
return stages;
}
function createMediatorAgent(): AgentMediatorTemplate {
const persona = createAgentMediatorPersonaConfig({
name: 'Agent',
description: 'Has 1-on-1 conversation with user and tries to help them',
isDefaultAddToCohort: true,
defaultProfile: createParticipantProfileBase({
name: 'Agent',
avatar: '🤖',
}),
});
const promptMap: Record<string, MediatorPromptConfig> = {};
promptMap[CHAT_STAGE_ID] = createChatPromptConfig(
CHAT_STAGE_ID, // stage ID
StageKind.PRIVATE_CHAT,
{
prompt: createDefaultPromptFromText(
'You are having a private chat with a human user. Make sure you help them with whatever they need',
CHAT_STAGE_ID,
),
},
);
return {persona, promptMap};
}