-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
103 lines (47 loc) · 1.94 KB
/
main.py
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
from simulation_engine.settings import *
from simulation_engine.global_methods import *
from agent_bank.navigator import *
from generative_agent.generative_agent import *
from cs222_assignment_1.memories.jasmine_carter_memories import *
from cs222_assignment_1.memories.matthew_jacobs_memories import *
from cs222_assignment_1.questions.jasmine_carter_questions import *
from cs222_assignment_1.questions.matthew_jacobs_questions import *
def chat_session(generative_agent, stateless=False):
print (f"Start chatting with {generative_agent.scratch.get_fullname()}.")
print ("Type 'bye' to exit.")
print ("")
context = input("First, describe the context of this conversation: ")
user_name = input("And what is your name: ")
print ("")
curr_convo = []
while True:
if stateless: curr_convo = []
user_input = input("You: ").strip()
curr_convo += [[user_name, user_input]]
if user_input.lower() == "bye":
print(generative_agent.utterance(curr_convo))
break
response = generative_agent.utterance(curr_convo)
curr_convo += [[generative_agent.scratch.get_fullname(), response]]
print(f"{generative_agent.scratch.get_fullname()}: {response}")
def build_agent():
curr_agent = GenerativeAgent("SyntheticCS222_Base", "matthew_jacobs")
for m in matthew_memories:
curr_agent.remember(m)
curr_agent.save("SyntheticCS222", "matthew_jacobs")
def interview_agent():
curr_agent = GenerativeAgent("SyntheticCS222", "matthew_jacobs")
chat_session(curr_agent, True)
def chat_with_agent():
curr_agent = GenerativeAgent("SyntheticCS222", "matthew_jacobs")
chat_session(curr_agent, False)
def ask_agent_to_reflect():
curr_agent = GenerativeAgent("SyntheticCS222", "matthew_jacobs")
curr_agent.reflect("Reflect on your goal in life")
def main():
build_agent()
interview_agent()
chat_with_agent()
ask_agent_to_reflect()
if __name__ == '__main__':
main()