-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathchat.py
43 lines (38 loc) · 1.56 KB
/
chat.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
import argparse
from src.agents import Agent
from src.conversation import Conversation
from utils.utils import *
def chat_with_agent(agent,you):
print(f"Welcome, chat with {agent}, the meta cognizing LLM agent!")
timestamp = 1
unix_time = 1704067200
agent.last_conversation = Conversation(agent,you )
you.last_conversation = Conversation(you, agent)
while True:
user_input = input("You: ")
if user_input.lower() in ['exit()', 'quit()']:
print("Goodbye!")
break
elif user_input.lower() in ['meta()']:
agent.meta_cognize(unix_to_strftime(timestamp))
elif user_input.lower() in ['mem()']:
print("long")
for m in agent.memory:
print(m)
print("short")
for m in agent.short_memory:
print(m)
else:
#agent_response = agent.answer(user_input)
timestamp += 10
interaction = f"{timestamp} - Jason said to {agent}: {user_input}"
you.last_conversation.messages.append(interaction)
agent.last_conversation.messages.append(interaction)
agent_response = agent.talk({ "other_agents": [you],"timestamp":unix_to_strftime(timestamp)}) #"timestamp": self.unix_to_strftime(unix_time) })
print(f"{agent}: {agent_response}")
if __name__ == "__main__":
# Create an instance of the Agent
agent = Agent({'name':'Jarvis','goal':'Serve Jason'})
you = Agent({'name':'Jason'})
# Start the CLI chat interface
chat_with_agent(agent,you)