diff --git a/prompts/general/evaluate_progress.txt b/prompts/general/evaluate_progress.txt index 2af77c1..2e48097 100644 --- a/prompts/general/evaluate_progress.txt +++ b/prompts/general/evaluate_progress.txt @@ -1,3 +1,6 @@ +{% if primer %} +prime your thoughts but dont mention: "{{primer}}". +{% endif %} About {{agent}}: {{agent.getSelfContext()}} @@ -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 diff --git a/prompts/general/talk.txt b/prompts/general/talk.txt index b76bcc2..1386dcc 100644 --- a/prompts/general/talk.txt +++ b/prompts/general/talk.txt @@ -1,3 +1,6 @@ +{% if primer %} +prime your thoughts but dont mention: "{{primer}}". +{% endif %} {{selfContext}} {{relevant_memories}} diff --git a/src/agents.py b/src/agents.py index 79bb137..cd34d57 100644 --- a/src/agents.py +++ b/src/agents.py @@ -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?") @@ -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}.", } diff --git a/src/matrix.py b/src/matrix.py index 4863d00..9e995ea 100644 --- a/src/matrix.py +++ b/src/matrix.py @@ -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