🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
chore: add try except if not exist in terminal toolkit (#3430)
JINO ROHIT7c2edc8cbec5
diff --git a/camel/toolkits/terminal_toolkit/terminal_toolkit.py b/camel/toolkits/terminal_toolkit/terminal_toolkit.pyindex 32d7c4190..8888001f2 100644--- a/camel/toolkits/terminal_toolkit/terminal_toolkit.py+++ b/camel/toolkits/terminal_toolkit/terminal_toolkit.py@@ -180,13 +180,20 @@ class TerminalToolkit(BaseToolkit):base_url='unix://var/run/docker.sock', timeout=self.timeout)self.docker_client = docker.from_env()- self.container = self.docker_client.containers.get(- docker_container_name- )- logger.info(- f"Successfully attached to Docker container "- f"'{docker_container_name}'."- )+ try:+ # Try to get existing container+ self.container = self.docker_client.containers.get(+ docker_container_name+ )+ logger.info(+ f"Successfully attached to existing Docker container "+ f"'{docker_container_name}'."+ )+ except NotFound:+ raise RuntimeError(+ f"Container '{docker_container_name}' not found. "+ )+# Ensure the working directory exists inside the containerif self.docker_workdir:try: