Skip to content

Commit

Permalink
retry on redis
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason committed Feb 25, 2024
1 parent 688222e commit 6e0e0d3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
6 changes: 3 additions & 3 deletions prompts/general/evaluate_progress.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% if primer %}
prime your thoughts but dont mention: "{{primer}}".
{% endif %}
About {{agent}}:
{{agent.getSelfContext()}}

Expand All @@ -9,9 +12,6 @@ Rate your progress towards your goal with an integer from 1-5, 1 being bad, 5 be

Write in the first person from the point of view of {{agent}}.
Write in natural short response style.
{% if random_prime %}
Think about the word "{{random_prime}}".
{% endif %}
Base your evaluation on your past memories only.
Format your response like:
Explanation: I didnt get my groceries today
Expand Down
3 changes: 3 additions & 0 deletions prompts/general/talk.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% if primer %}
prime your thoughts but dont mention: "{{primer}}".
{% endif %}
{{selfContext}}

{{relevant_memories}}
Expand Down
5 changes: 3 additions & 2 deletions src/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ def ask_meta_questions(self, timestamp):
def evaluate_progress(self,opts={}):
relevant_memories = self.getMemories(self.goal, unix_to_strftime(self.matrix.unix_time))
relevant_memories_string = "\n".join(f"Memory {i + 1}:\n{memory}" for i, memory in enumerate(relevant_memories)) if relevant_memories else ""
random_prime = opts.get("random_prime",False)
primer = opts.get("random_prime",False)
variables = {
'agent': self,
'random_prime': random_common_word(),
'primer': random.randint(1, 1000000),
'selfContext': self.getSelfContext()
}
#msg = llm.generate(prompt, f"How am I doing?")
Expand Down Expand Up @@ -355,6 +355,7 @@ def talk(self, opts={}):
'agent': self,
'connections': self.connections,
'meta_questions': self.meta_questions or "",
'primer': random.randint(1, 1000000),
'other_agent': other_agent,
"previous_conversations": f"Current Conversation:\n{self.name}\n{previous_conversations}" if previous_conversations else f"Initiate a conversation with {other_agent.name}.",
}
Expand Down
9 changes: 9 additions & 0 deletions src/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,15 @@ def add_to_logs(self,obj):
queue = f"{obj['sim_id']}"
wtf = json.loads(json.dumps(obj, default=str))
#redis_connection.xadd(stream, wtf)
max_retries = 3
retry_delay = 1
for attempt in range(max_retries):
try:
redis_connection.lpush(queue, json.dumps(obj))
break # Break the loop if successful
except redis.RedisError as e:
print(f"Error pushing to Redis queue. Retrying... ({attempt + 1}/{max_retries})")
time.sleep(retry_delay)
redis_connection.lpush(queue,json.dumps(obj))

self.current_substep += 1
Expand Down

0 comments on commit 6e0e0d3

Please sign in to comment.