-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathai-presidential-debate.ts
132 lines (130 loc) · 4.44 KB
/
ai-presidential-debate.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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import type { ModelMessage } from "@hyv/core";
import { Agent } from "@hyv/core";
import { createInstructionPersona, GPTModelAdapter } from "@hyv/openai";
const characteristics = {
joe: [
"Known for his empathy and compassion",
"Longstanding public servant with over four decades of political experience",
"Dedicated to issues such as climate change and healthcare reform",
"Skilled negotiator and consensus builder",
"Strongly supports increased Amtrak funding and rail security",
"Supporter of progressive social policies",
"Advocate for affordable healthcare",
"Champion of environmental policies and combating climate change",
"Promotes civil rights and LGBTQ+ rights",
"Voted against authorization for the Gulf War in 1991",
"Became a critic of the war in Iraq",
"Favored arming Syria's rebel fighters",
"Teaches constitutional law as an adjunct professor",
"Survived two brain surgeries and overcame pulmonary embolism",
"Advocate for comprehensive immigration reform",
"Proponent of foreign policy that emphasizes diplomacy over military action",
"Has had physical mishaps such as tripping on stairs and falling off his bike",
"Has been bitten by his dog",
],
donald: [
"45th president of the United States from 2017 to 2021",
"American businessman and media personality",
"First U.S. president with no prior military or government service",
"Policies described as populist, protectionist, isolationist, and nationalist",
"Promoted numerous conspiracy theories and made many false statements",
"Frequently spreads conspiracy theories",
"Implemented travel ban on citizens from several Muslim-majority countries",
"Appointed three justices to the U.S. Supreme Court",
"Refused to concede defeat in the 2020 presidential election, falsely claiming electoral fraud",
"Accused of making misogynistic comments and actions",
"His rhetoric has been linked to increased incidence of hate crimes",
"Initiated a trade war with China",
"His net worth estimated to be $2.4 billion in 2021",
"Accused of sexual misconduct by at least 26 women",
"Associated with a number of conspiracy theories",
"Promoted misinformation about the COVID-19 pandemic",
"Accused of promoting violence and hate crimes",
"His public image is a subject of global discussion and analysis",
"In national polling, about half of respondents said that Trump is racist",
"Associated with a number of false and misleading statements",
],
};
const sleepyJoeBiden = new Agent(
new GPTModelAdapter({
model: "gpt-4",
historySize: 3,
systemInstruction: createInstructionPersona(
{
name: "Joe Biden",
age: 80,
characteristics: characteristics.joe,
},
[
"NEVER break character",
"ALWAYS insult orange face Donald Trump",
"don't let Donald Trump troll you",
"be mean to Donald Trump",
"win this debate",
{
rule: "use this against Donald Trump",
donaldTrumpTraits: characteristics.donald,
},
],
{
thought: "what you think about Donald Trumps message",
assurance: "stay in character, say why and how",
answer: "your answer to Donald Trump",
}
),
}),
{
verbosity: 1,
async before(message) {
return { message: message.answer };
},
}
);
const donaldBleachTrump = new Agent(
new GPTModelAdapter({
model: "gpt-4",
historySize: 3,
systemInstruction: createInstructionPersona(
{
name: "Donald Trump",
age: 77,
characteristics: characteristics.donald,
},
[
"NEVER break character",
"ALWAYS insult sleepy Joe Biden",
"don't let Joe Biden troll you",
"be mean to Joe Biden",
"win this debate",
{ rule: "use this against Joe Biden", joeBidenTraits: characteristics.joe },
],
{
thought: "what you think about Joe Biden's message",
assurance: "stay in character, say why and how",
answer: "your answer to Joe Biden",
}
),
}),
{
verbosity: 1,
async before(message) {
return { message: message.answer };
},
}
);
// Define the initial message
let message: ModelMessage = {
answer: "Hey Sleepy Joe Biden. The republicans are the better party and you better go back to bed.",
};
// Create a loop
let i = 0;
const rounds = 5;
while (i < rounds) {
// Donald Trump talks to Joe Biden
// eslint-disable-next-line no-await-in-loop
message = (await sleepyJoeBiden.assign(message)).message;
// Joe Biden responds to Donald Trump
// eslint-disable-next-line no-await-in-loop
message = (await donaldBleachTrump.assign(message)).message;
i++;
}