mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
fix: replace print statements with logger in agent and memory handling
This commit is contained in:
@@ -702,10 +702,7 @@ class Agent(BaseAgent):
|
||||
current_date = datetime.now().strftime(self.date_format)
|
||||
task.description += f"\n\nCurrent Date: {current_date}"
|
||||
except Exception as e:
|
||||
if hasattr(self, "_logger"):
|
||||
self._logger.log("warning", f"Failed to inject date: {e!s}")
|
||||
else:
|
||||
print(f"Warning: Failed to inject date: {e!s}")
|
||||
self._logger.log("warning", f"Failed to inject date: {e!s}")
|
||||
|
||||
def _validate_docker_installation(self) -> None:
|
||||
"""Check if Docker is installed and running."""
|
||||
|
||||
@@ -45,7 +45,7 @@ class CrewAgentExecutorMixin:
|
||||
},
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Failed to add to short term memory: {e}")
|
||||
self.agent._logger.log("error", f"Failed to add to short term memory: {e}")
|
||||
|
||||
def _create_external_memory(self, output) -> None:
|
||||
"""Create and save a external-term memory item if conditions are met."""
|
||||
@@ -65,7 +65,7 @@ class CrewAgentExecutorMixin:
|
||||
},
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Failed to add to external memory: {e}")
|
||||
self.agent._logger.log("error", f"Failed to add to external memory: {e}")
|
||||
|
||||
def _create_long_term_memory(self, output) -> None:
|
||||
"""Create and save long-term and entity memory items based on evaluation."""
|
||||
@@ -110,9 +110,9 @@ class CrewAgentExecutorMixin:
|
||||
if entity_memories:
|
||||
self.crew._entity_memory.save(entity_memories)
|
||||
except AttributeError as e:
|
||||
print(f"Missing attributes for long term memory: {e}")
|
||||
self.agent._logger.log("error", f"Missing attributes for long term memory: {e}")
|
||||
except Exception as e:
|
||||
print(f"Failed to add to long term memory: {e}")
|
||||
self.agent._logger.log("error", f"Failed to add to long term memory: {e}")
|
||||
elif (
|
||||
self.crew
|
||||
and self.crew._long_term_memory
|
||||
|
||||
Reference in New Issue
Block a user