-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathchaining.ts
51 lines (49 loc) · 1.15 KB
/
chaining.ts
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
import { Agent, sequence } from "@hyv/core";
import { createInstructionTemplate, GPTModelAdapter } from "@hyv/openai";
import { minify } from "@hyv/utils";
const agents = Array.from<undefined, Agent>(
{ length: 3 },
() =>
new Agent(
new GPTModelAdapter({
model: "gpt-4",
systemInstruction: createInstructionTemplate(
"AI",
minify`
You have deep thoughts,
reason your thoughts,
reflect your reasoning,
debate your reflection,
decide base on your debate.
You then create a new task based on your decision!
`,
{
mainGoal: "={{mainGoal}}",
thoughts: "detailed string",
reasoning: "detailed string",
reflection: "detailed string",
debate: "detailed string",
decision: "detailed string",
task: "full and detailed task without references",
}
),
}),
{
async before({ task, mainGoal }) {
return {
task,
mainGoal,
};
},
verbosity: 1,
}
)
);
try {
await sequence(
{ task: "Make the world a better place!", mainGoal: "Make the world a better place!" },
agents
);
} catch (error) {
console.error("Error:", error);
}