vision-agent 0.2.76__py3-none-any.whl → 0.2.77__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vision_agent/utils/execute.py +23 -25
 - {vision_agent-0.2.76.dist-info → vision_agent-0.2.77.dist-info}/METADATA +2 -2
 - {vision_agent-0.2.76.dist-info → vision_agent-0.2.77.dist-info}/RECORD +5 -5
 - {vision_agent-0.2.76.dist-info → vision_agent-0.2.77.dist-info}/LICENSE +0 -0
 - {vision_agent-0.2.76.dist-info → vision_agent-0.2.77.dist-info}/WHEEL +0 -0
 
    
        vision_agent/utils/execute.py
    CHANGED
    
    | 
         @@ -11,10 +11,9 @@ import tempfile 
     | 
|
| 
       11 
11 
     | 
    
         
             
            import traceback
         
     | 
| 
       12 
12 
     | 
    
         
             
            import warnings
         
     | 
| 
       13 
13 
     | 
    
         
             
            from enum import Enum
         
     | 
| 
       14 
     | 
    
         
            -
            from io import IOBase
         
     | 
| 
       15 
14 
     | 
    
         
             
            from pathlib import Path
         
     | 
| 
       16 
15 
     | 
    
         
             
            from time import sleep
         
     | 
| 
       17 
     | 
    
         
            -
            from typing import  
     | 
| 
      
 16 
     | 
    
         
            +
            from typing import Any, Dict, Iterable, List, Optional, Union
         
     | 
| 
       18 
17 
     | 
    
         | 
| 
       19 
18 
     | 
    
         
             
            import nbformat
         
     | 
| 
       20 
19 
     | 
    
         
             
            import tenacity
         
     | 
| 
         @@ -33,6 +32,7 @@ from typing_extensions import Self 
     | 
|
| 
       33 
32 
     | 
    
         | 
| 
       34 
33 
     | 
    
         
             
            load_dotenv()
         
     | 
| 
       35 
34 
     | 
    
         
             
            _LOGGER = logging.getLogger(__name__)
         
     | 
| 
      
 35 
     | 
    
         
            +
            _SESSION_TIMEOUT = 300  # 5 minutes
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
38 
     | 
    
         
             
            class MimeType(str, Enum):
         
     | 
| 
         @@ -403,11 +403,8 @@ class CodeInterpreter(abc.ABC): 
     | 
|
| 
       403 
403 
     | 
    
         
             
                    self.restart_kernel()
         
     | 
| 
       404 
404 
     | 
    
         
             
                    return self.exec_cell(code)
         
     | 
| 
       405 
405 
     | 
    
         | 
| 
       406 
     | 
    
         
            -
                def upload_file(self, file: Union[str, Path 
     | 
| 
      
 406 
     | 
    
         
            +
                def upload_file(self, file: Union[str, Path]) -> str:
         
     | 
| 
       407 
407 
     | 
    
         
             
                    # Default behavior is a no-op (for local code interpreter)
         
     | 
| 
       408 
     | 
    
         
            -
                    assert not isinstance(
         
     | 
| 
       409 
     | 
    
         
            -
                        file, IO
         
     | 
| 
       410 
     | 
    
         
            -
                    ), "Don't pass IO objects to upload_file() of local interpreter"
         
     | 
| 
       411 
408 
     | 
    
         
             
                    return str(file)
         
     | 
| 
       412 
409 
     | 
    
         | 
| 
       413 
410 
     | 
    
         
             
                def download_file(self, file_path: str) -> Path:
         
     | 
| 
         @@ -416,7 +413,6 @@ class CodeInterpreter(abc.ABC): 
     | 
|
| 
       416 
413 
     | 
    
         | 
| 
       417 
414 
     | 
    
         | 
| 
       418 
415 
     | 
    
         
             
            class E2BCodeInterpreter(CodeInterpreter):
         
     | 
| 
       419 
     | 
    
         
            -
                KEEP_ALIVE_SEC: int = 300
         
     | 
| 
       420 
416 
     | 
    
         | 
| 
       421 
417 
     | 
    
         
             
                def __init__(self, *args: Any, **kwargs: Any) -> None:
         
     | 
| 
       422 
418 
     | 
    
         
             
                    super().__init__(*args, **kwargs)
         
     | 
| 
         @@ -437,8 +433,8 @@ print(f"Vision Agent version: {va_version}")""" 
     | 
|
| 
       437 
433 
     | 
    
         
             
                    _LOGGER.info(f"E2BCodeInterpreter initialized:\n{sys_versions}")
         
     | 
| 
       438 
434 
     | 
    
         | 
| 
       439 
435 
     | 
    
         
             
                def close(self, *args: Any, **kwargs: Any) -> None:
         
     | 
| 
       440 
     | 
    
         
            -
                    self.interpreter.notebook.close()
         
     | 
| 
       441 
436 
     | 
    
         
             
                    self.interpreter.close()
         
     | 
| 
      
 437 
     | 
    
         
            +
                    self.interpreter.kill()
         
     | 
| 
       442 
438 
     | 
    
         | 
| 
       443 
439 
     | 
    
         
             
                def restart_kernel(self) -> None:
         
     | 
| 
       444 
440 
     | 
    
         
             
                    self.interpreter.notebook.restart_kernel()
         
     | 
| 
         @@ -449,25 +445,27 @@ print(f"Vision Agent version: {va_version}")""" 
     | 
|
| 
       449 
445 
     | 
    
         
             
                    retry=tenacity.retry_if_exception_type(TimeoutError),
         
     | 
| 
       450 
446 
     | 
    
         
             
                )
         
     | 
| 
       451 
447 
     | 
    
         
             
                def exec_cell(self, code: str) -> Execution:
         
     | 
| 
       452 
     | 
    
         
            -
                    self.interpreter. 
     | 
| 
      
 448 
     | 
    
         
            +
                    if not self.interpreter.is_running():
         
     | 
| 
      
 449 
     | 
    
         
            +
                        raise ConnectionResetError(
         
     | 
| 
      
 450 
     | 
    
         
            +
                            "Remote sandbox is closed unexpectedly. Please retry the operation."
         
     | 
| 
      
 451 
     | 
    
         
            +
                        )
         
     | 
| 
      
 452 
     | 
    
         
            +
                    self.interpreter.set_timeout(_SESSION_TIMEOUT)  # Extend the life of the sandbox
         
     | 
| 
       453 
453 
     | 
    
         
             
                    execution = self.interpreter.notebook.exec_cell(code, timeout=self.timeout)
         
     | 
| 
       454 
454 
     | 
    
         
             
                    return Execution.from_e2b_execution(execution)
         
     | 
| 
       455 
455 
     | 
    
         | 
| 
       456 
     | 
    
         
            -
                def upload_file(self, file: Union[str, Path 
     | 
| 
       457 
     | 
    
         
            -
                     
     | 
| 
       458 
     | 
    
         
            -
             
     | 
| 
       459 
     | 
    
         
            -
             
     | 
| 
       460 
     | 
    
         
            -
                         
     | 
| 
       461 
     | 
    
         
            -
             
     | 
| 
       462 
     | 
    
         
            -
                         
     | 
| 
       463 
     | 
    
         
            -
                        file.close()
         
     | 
| 
       464 
     | 
    
         
            -
                        _LOGGER.info(f"File ({file}) is uploaded to: {file.name}")
         
     | 
| 
      
 456 
     | 
    
         
            +
                def upload_file(self, file: Union[str, Path]) -> str:
         
     | 
| 
      
 457 
     | 
    
         
            +
                    file_name = Path(file).name
         
     | 
| 
      
 458 
     | 
    
         
            +
                    remote_path = f"/home/user/{file_name}"
         
     | 
| 
      
 459 
     | 
    
         
            +
                    with open(file, "rb") as f:
         
     | 
| 
      
 460 
     | 
    
         
            +
                        self.interpreter.files.write(path=remote_path, data=f)
         
     | 
| 
      
 461 
     | 
    
         
            +
                        _LOGGER.info(f"File ({file}) is uploaded to: {remote_path}")
         
     | 
| 
      
 462 
     | 
    
         
            +
                        return remote_path
         
     | 
| 
       465 
463 
     | 
    
         | 
| 
       466 
464 
     | 
    
         
             
                def download_file(self, file_path: str) -> Path:
         
     | 
| 
       467 
     | 
    
         
            -
                     
     | 
| 
       468 
     | 
    
         
            -
             
     | 
| 
       469 
     | 
    
         
            -
             
     | 
| 
       470 
     | 
    
         
            -
             
     | 
| 
      
 465 
     | 
    
         
            +
                    with tempfile.NamedTemporaryFile(mode="w+b", delete=False) as file:
         
     | 
| 
      
 466 
     | 
    
         
            +
                        file.write(self.interpreter.files.read(path=file_path, format="bytes"))
         
     | 
| 
      
 467 
     | 
    
         
            +
                        _LOGGER.info(f"File ({file_path}) is downloaded to: {file.name}")
         
     | 
| 
      
 468 
     | 
    
         
            +
                        return Path(file.name)
         
     | 
| 
       471 
469 
     | 
    
         | 
| 
       472 
470 
     | 
    
         
             
                @staticmethod
         
     | 
| 
       473 
471 
     | 
    
         
             
                @tenacity.retry(
         
     | 
| 
         @@ -480,7 +478,7 @@ print(f"Vision Agent version: {va_version}")""" 
     | 
|
| 
       480 
478 
     | 
    
         | 
| 
       481 
479 
     | 
    
         | 
| 
       482 
480 
     | 
    
         
             
            class LocalCodeInterpreter(CodeInterpreter):
         
     | 
| 
       483 
     | 
    
         
            -
                def __init__(self, timeout: int =  
     | 
| 
      
 481 
     | 
    
         
            +
                def __init__(self, timeout: int = _SESSION_TIMEOUT) -> None:
         
     | 
| 
       484 
482 
     | 
    
         
             
                    super().__init__(timeout=timeout)
         
     | 
| 
       485 
483 
     | 
    
         
             
                    self.nb = nbformat.v4.new_notebook()
         
     | 
| 
       486 
484 
     | 
    
         
             
                    self.nb_client = NotebookClient(self.nb, timeout=self.timeout)
         
     | 
| 
         @@ -568,9 +566,9 @@ class CodeInterpreterFactory: 
     | 
|
| 
       568 
566 
     | 
    
         
             
                @staticmethod
         
     | 
| 
       569 
567 
     | 
    
         
             
                def new_instance() -> CodeInterpreter:
         
     | 
| 
       570 
568 
     | 
    
         
             
                    if os.getenv("CODE_SANDBOX_RUNTIME") == "e2b":
         
     | 
| 
       571 
     | 
    
         
            -
                        instance: CodeInterpreter = E2BCodeInterpreter(timeout= 
     | 
| 
      
 569 
     | 
    
         
            +
                        instance: CodeInterpreter = E2BCodeInterpreter(timeout=_SESSION_TIMEOUT)
         
     | 
| 
       572 
570 
     | 
    
         
             
                    else:
         
     | 
| 
       573 
     | 
    
         
            -
                        instance = LocalCodeInterpreter(timeout= 
     | 
| 
      
 571 
     | 
    
         
            +
                        instance = LocalCodeInterpreter(timeout=_SESSION_TIMEOUT)
         
     | 
| 
       574 
572 
     | 
    
         
             
                    atexit.register(instance.close)
         
     | 
| 
       575 
573 
     | 
    
         
             
                    return instance
         
     | 
| 
       576 
574 
     | 
    
         | 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            Metadata-Version: 2.1
         
     | 
| 
       2 
2 
     | 
    
         
             
            Name: vision-agent
         
     | 
| 
       3 
     | 
    
         
            -
            Version: 0.2. 
     | 
| 
      
 3 
     | 
    
         
            +
            Version: 0.2.77
         
     | 
| 
       4 
4 
     | 
    
         
             
            Summary: Toolset for Vision Agent
         
     | 
| 
       5 
5 
     | 
    
         
             
            Author: Landing AI
         
     | 
| 
       6 
6 
     | 
    
         
             
            Author-email: dev@landing.ai
         
     | 
| 
         @@ -10,7 +10,7 @@ Classifier: Programming Language :: Python :: 3.9 
     | 
|
| 
       10 
10 
     | 
    
         
             
            Classifier: Programming Language :: Python :: 3.10
         
     | 
| 
       11 
11 
     | 
    
         
             
            Classifier: Programming Language :: Python :: 3.11
         
     | 
| 
       12 
12 
     | 
    
         
             
            Requires-Dist: e2b (>=0.17.1,<0.18.0)
         
     | 
| 
       13 
     | 
    
         
            -
            Requires-Dist: e2b-code-interpreter ( 
     | 
| 
      
 13 
     | 
    
         
            +
            Requires-Dist: e2b-code-interpreter (==0.0.11a1)
         
     | 
| 
       14 
14 
     | 
    
         
             
            Requires-Dist: ipykernel (>=6.29.4,<7.0.0)
         
     | 
| 
       15 
15 
     | 
    
         
             
            Requires-Dist: langsmith (>=0.1.58,<0.2.0)
         
     | 
| 
       16 
16 
     | 
    
         
             
            Requires-Dist: moviepy (>=1.0.0,<2.0.0)
         
     | 
| 
         @@ -12,12 +12,12 @@ vision_agent/tools/prompts.py,sha256=V1z4YJLXZuUl_iZ5rY0M5hHc_2tmMEUKr0WocXKGt4E 
     | 
|
| 
       12 
12 
     | 
    
         
             
            vision_agent/tools/tool_utils.py,sha256=ZOY45bCX3nlo6iGwaZ8RVpRJB-vWxkXDed9oegT7-p0,1838
         
     | 
| 
       13 
13 
     | 
    
         
             
            vision_agent/tools/tools.py,sha256=TkZqNYX-ocwdaCdXd6c6tysSa_HX2y6Nrgl4JKni4IQ,43661
         
     | 
| 
       14 
14 
     | 
    
         
             
            vision_agent/utils/__init__.py,sha256=CW84HnhqI6XQVuxf2KifkLnSuO7EOhmuL09-gAymAak,219
         
     | 
| 
       15 
     | 
    
         
            -
            vision_agent/utils/execute.py,sha256= 
     | 
| 
      
 15 
     | 
    
         
            +
            vision_agent/utils/execute.py,sha256=DMaQz5-yULxDx-TlSMTRKOPHE7VmyR7PArhXXilm7h0,21368
         
     | 
| 
       16 
16 
     | 
    
         
             
            vision_agent/utils/image_utils.py,sha256=_cdiS5YrLzqkq_ZgFUO897m5M4_SCIThwUy4lOklfB8,7700
         
     | 
| 
       17 
17 
     | 
    
         
             
            vision_agent/utils/sim.py,sha256=ci6Eta73dDgLP1Ajtknbgmf1g8aAvBHqlVQvBuLMKXQ,4427
         
     | 
| 
       18 
18 
     | 
    
         
             
            vision_agent/utils/type_defs.py,sha256=BlI8ywWHAplC7kYWLvt4AOdnKpEW3qWEFm-GEOSkrFQ,1792
         
     | 
| 
       19 
19 
     | 
    
         
             
            vision_agent/utils/video.py,sha256=rNmU9KEIkZB5-EztZNlUiKYN0mm_55A_2VGUM0QpqLA,8779
         
     | 
| 
       20 
     | 
    
         
            -
            vision_agent-0.2. 
     | 
| 
       21 
     | 
    
         
            -
            vision_agent-0.2. 
     | 
| 
       22 
     | 
    
         
            -
            vision_agent-0.2. 
     | 
| 
       23 
     | 
    
         
            -
            vision_agent-0.2. 
     | 
| 
      
 20 
     | 
    
         
            +
            vision_agent-0.2.77.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
         
     | 
| 
      
 21 
     | 
    
         
            +
            vision_agent-0.2.77.dist-info/METADATA,sha256=2GjXWlij7wzd19pzbjNRt__AVhpVtLcAe_WfGnydxTI,9433
         
     | 
| 
      
 22 
     | 
    
         
            +
            vision_agent-0.2.77.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
         
     | 
| 
      
 23 
     | 
    
         
            +
            vision_agent-0.2.77.dist-info/RECORD,,
         
     | 
| 
         
            File without changes
         
     | 
| 
         
            File without changes
         
     |