Skip to content

Commit

Permalink
add convo id for logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason committed Feb 7, 2024
1 parent bb8c345 commit d386c75
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,7 @@ This should start a basic webserver that would allow us to view the game state a

3. Pass in to `engine.py` with `--environment` flag.



TODO:
refactor add_agents bc of jumping
4 changes: 3 additions & 1 deletion src/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ 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","convo":"complete","from":self.id,"to":self.last_conversation.other_agent.id,"convo_id":self.last_conversation.mid})
self.last_conversation = None

def talk(self, opts={}):
Expand Down Expand Up @@ -345,9 +346,10 @@ def talk(self, opts={}):
self.last_conversation.messages.append(interaction)
other_agent.last_conversation.messages.append(interaction)
if self.matrix:
self.matrix.add_to_logs({"agent_id":self.id,"to_id":other_agent.id,"step_type":"talk","content": msg})
self.matrix.add_to_logs({"agent_id":self.id,"to_id":other_agent.id,"step_type":"talk","content": msg,"convo_id":self.last_conversation.mid})
return msg

# TO DELETE
def talk_many(self, perceived_agents, timestamp):
relevant_memories = self.getMemories(f"{[a.name for a in perceived_agents]}", timestamp)
relevant_memories_string = "\n".join(f"Memory {i + 1}:\n{memory}" for i, memory in enumerate(relevant_memories)) if relevant_memories else ""
Expand Down
2 changes: 2 additions & 0 deletions src/conversation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import uuid
class Conversation:
def __init__(self, agent, other_agent, messages=None):
self.agent = agent
self.other_agent = other_agent
self.mid = str(uuid.uuid4())
self.messages = messages

if self.messages is None:
Expand Down
2 changes: 1 addition & 1 deletion src/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self, config={}):
self.allow_movement = ALLOW_MOVEMENT
self.model = MODEL
self.replay = None
self.add_to_logs({"step_type":"world_init","data":config})
self.add_to_logs({"step_type":"matrix_init","data":config})
self.agent_locks = { agent: threading.Lock() for agent in self.agents }
self.environment = Environment({ "filename": self.environment_file })
if self.scenario_file is not None:
Expand Down

0 comments on commit d386c75

Please sign in to comment.