diff --git a/llm_sandbox/docker.py b/llm_sandbox/docker.py index aa100e7..80d73ef 100644 --- a/llm_sandbox/docker.py +++ b/llm_sandbox/docker.py @@ -32,7 +32,7 @@ def __init__( lang: str = SupportedLanguage.PYTHON, keep_template: bool = False, verbose: bool = False, - mounts: Optional[list[Mount]] = None + mounts: Optional[list[Mount]] = None, ): """ Create a new sandbox session @@ -74,7 +74,7 @@ def __init__( self.is_create_template: bool = False self.verbose = verbose self.mounts = mounts - + def open(self): warning_str = ( "Since the `keep_template` flag is set to True the docker image will not be removed after the session ends " @@ -108,7 +108,9 @@ def open(self): if self.verbose: print(f"Using image {self.image.tags[-1]}") - self.container = self.client.containers.run(self.image, detach=True, tty=True, mounts=self.mounts) + self.container = self.client.containers.run( + self.image, detach=True, tty=True, mounts=self.mounts + ) def close(self): if self.container: diff --git a/llm_sandbox/micromamba.py b/llm_sandbox/micromamba.py index fda2306..9228952 100644 --- a/llm_sandbox/micromamba.py +++ b/llm_sandbox/micromamba.py @@ -4,30 +4,36 @@ from llm_sandbox.docker import ConsoleOutput from llm_sandbox.const import SupportedLanguage from docker.types import Mount + + class MicromambaSession(SandboxDockerSession): """ SandboxDockerSession does not allow activation of micromamba environment, this class extends it and allows that which makes it possible for LLM agents to installed conda dependencies. """ - def __init__(self, client: Optional[docker.DockerClient] = None, + def __init__( + self, + client: Optional[docker.DockerClient] = None, image: Optional[str] = "mambaorg/micromamba:latest", dockerfile: Optional[str] = None, lang: str = SupportedLanguage.PYTHON, keep_template: bool = False, - verbose: bool = False, + verbose: bool = False, mounts: Optional[list[Mount]] = None, - environment: str = "base"): - super().__init__(client=client, - image=image, - dockerfile=dockerfile, - lang=lang, - keep_template=keep_template, - verbose=verbose, - mounts=mounts) + environment: str = "base", + ): + super().__init__( + client=client, + image=image, + dockerfile=dockerfile, + lang=lang, + keep_template=keep_template, + verbose=verbose, + mounts=mounts, + ) self.environment = environment - def execute_command( self, command: Optional[str], workdir: Optional[str] = None ) -> ConsoleOutput: