-
Notifications
You must be signed in to change notification settings - Fork 854
/
Copy pathconfiguration.js
67 lines (61 loc) · 1.78 KB
/
configuration.js
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
import { validate } from 'pydantic';
import { GuardrailFunctionOutput, InputGuardrail, OutputGuardrail } from 'openai-agents';
export function configureAgentGuardrails(agent, inputGuardrails, outputGuardrails) {
agent.input_guardrails = inputGuardrails.map(guardrail => new InputGuardrail(guardrail));
agent.output_guardrails = outputGuardrails.map(guardrail => new OutputGuardrail(guardrail));
}
export function configureAgentHandoffs(agent, handoffs) {
agent.handoffs = handoffs.map(handoffData => handoff(handoffData));
}
export function configureAgentTools(agent, tools) {
agent.tools = tools.map(tool => function_tool(tool));
}
export function provideAgentTemplates() {
return [
{
name: 'Basic Agent',
instructions: 'You are a basic agent.',
model: 'text-davinci-003',
tools: [],
context: {},
outputTypes: 'text',
handoffs: [],
guardrails: {
input: [],
output: [],
},
cloning: false,
},
{
name: 'Advanced Agent',
instructions: 'You are an advanced agent with multiple tools and guardrails.',
model: 'text-davinci-003',
tools: ['tool1', 'tool2'],
context: {},
outputTypes: 'json',
handoffs: ['handoff1', 'handoff2'],
guardrails: {
input: ['inputGuardrail1', 'inputGuardrail2'],
output: ['outputGuardrail1', 'outputGuardrail2'],
},
cloning: true,
},
];
}
export function validateAgentConfiguration(agentData) {
const schema = {
name: 'string',
instructions: 'string',
model: 'string',
tools: 'array',
context: 'object',
outputTypes: 'string',
handoffs: 'array',
guardrails: {
input: 'array',
output: 'array',
},
cloning: 'boolean',
};
return validate(agentData, schema);
}