Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason committed Mar 5, 2024
1 parent 135c4f0 commit b245d4d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
4 changes: 4 additions & 0 deletions prompts/general/talk.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ Before answering, consider "{{agent.meta_questions|random}}"

Provide {{agent}}'s response from the first person point of view.

{% if topic %}
Maybe you could discuss the topic of "{{topic}}"
{% endif %}


keep responses to under 3 sentences.
Craft an informal spoken response.
Expand Down
4 changes: 3 additions & 1 deletion src/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ def summarize_conversation(self, timestamp):
print_and_log(interaction, f"{self.matrix.id}:events:{self.name}")

self.addMemory("conversation", interaction, timestamp, random.randint(4, 6))
self.matrix.add_to_logs({"step_type":"agent_set", "attribute_name": "convo", "attribute_data": {"status": "complete", "from":self.mid, "to":self.last_conversation.other_agent.mid, "convo_id":self.last_conversation.mid}})
if self.matrix:
self.matrix.add_to_logs({"step_type":"agent_set", "attribute_name": "convo", "attribute_data": {"status": "complete", "from":self.mid, "to":self.last_conversation.other_agent.mid, "convo_id":self.last_conversation.mid}})
self.last_conversation = None

def talk(self, opts={}):
Expand Down Expand Up @@ -363,6 +364,7 @@ def talk(self, opts={}):
'selfContext': self.getSelfContext(),
'relevant_memories': relevant_memories_string,
'agent': self,
'topic': opts.get('topic',None),
'convo_types': all_convo_types[:10],
'connections': self.connections,
'meta_questions': self.meta_questions or "",
Expand Down
38 changes: 38 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,44 @@ def test_embeddings(self):
print(f"Current Memory: {mem}")
print(f"Relevance Score: {Memory.calculateRelevanceScore(mem.embedding, context_embedding)}")
self.assertTrue(len(sorted_memory) > 0)

def test_information_spreading(self):
a1_data = { "name": "Viktor", "goal": "wants to throw a party next week" }
a2_data = { "name": "John", "description": "loves art" }
a3_data = { "name": "Paul", "description": "loves eating" }
agent1 = Agent(a1_data)
agent2 = Agent(a2_data)
agent3 = Agent(a3_data)
unix_time = 1704067200
timestamp = datetime.fromtimestamp(unix_time).strftime("%Y-%m-%d %H:%M:%S")
for i in range(2):
timestamp = datetime.fromtimestamp(unix_time).strftime("%Y-%m-%d %H:%M:%S")
response = agent1.talk({ "target": agent2.name, "other_agents": [agent2], "timestamp": timestamp })
msg = f"{agent1} said to {agent2}: {response}"
print(msg)
response = agent2.talk({ "target": agent1.name, "other_agents": [agent1], "timestamp": timestamp })
msg = f"{agent2} said to {agent1}: {response}"
print(msg)
unix_time = unix_time + 10
agent2.summarize_conversation(timestamp)
print("*"*20)
for i in range(2):
timestamp = datetime.fromtimestamp(unix_time).strftime("%Y-%m-%d %H:%M:%S")
response = agent2.talk({ "target": agent3.name, "other_agents": [agent3], "timestamp": timestamp })
msg = f"{agent2} said to {agent3}: {response}"
print(msg)
response = agent3.talk({ "target": agent2.name, "other_agents": [agent2], "timestamp": timestamp })
msg = f"{agent3} said to {agent2}: {response}"
print(msg)
unix_time = unix_time + 10
agent3.summarize_conversation(timestamp)
print(f"{agent2} memories")
for mem in agent2.memory:
print(mem)
print(f"{agent3} memories")
for mem in agent3.memory:
print(mem)

def test_talk_stranger(self):
agent1_data = {
"name": "Viktor",
Expand Down

0 comments on commit b245d4d

Please sign in to comment.