Skip to content

Commit 393bb4e

Browse files
committed
Revert "calling"
This reverts commit c66a463.
1 parent 3ee6198 commit 393bb4e

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

vision_agent/agent/vision_agent.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@
2121
use_extra_vision_agent_args,
2222
)
2323
from vision_agent.utils import CodeInterpreterFactory
24-
from vision_agent.utils.execute import CodeInterpreter, LocalCodeInterpreter, Execution
24+
from vision_agent.utils.execute import CodeInterpreter, Execution
2525

2626
logging.basicConfig(level=logging.INFO)
2727
_LOGGER = logging.getLogger(__name__)
2828
WORKSPACE = Path(os.getenv("WORKSPACE", ""))
2929
WORKSPACE.mkdir(parents=True, exist_ok=True)
3030
if str(WORKSPACE) != "":
3131
os.environ["PYTHONPATH"] = f"{WORKSPACE}:{os.getenv('PYTHONPATH', '')}"
32-
_SESSION_TIMEOUT = 600 # 10 minutes
3332

3433

3534
class BoilerplateCode:
@@ -196,7 +195,7 @@ def __init__(
196195
agent: Optional[LMM] = None,
197196
verbosity: int = 0,
198197
local_artifacts_path: Optional[Union[str, Path]] = None,
199-
code_interpreter: Optional[CodeInterpreter] = None,
198+
code_sandbox_runtime: Optional[str] = None,
200199
callback_message: Optional[Callable[[Dict[str, Any]], None]] = None,
201200
) -> None:
202201
"""Initialize the VisionAgent.
@@ -207,17 +206,13 @@ def __init__(
207206
verbosity (int): The verbosity level of the agent.
208207
local_artifacts_path (Optional[Union[str, Path]]): The path to the local
209208
artifacts file.
210-
code_interpreter (Optional[CodeInterpreter]): The code interpreter to use, default to local python
209+
code_sandbox_runtime (Optional[str]): The code sandbox runtime to use.
211210
"""
212211

213212
self.agent = AnthropicLMM(temperature=0.0) if agent is None else agent
214213
self.max_iterations = 12
215214
self.verbosity = verbosity
216-
self.code_interpreter = (
217-
code_interpreter
218-
if code_interpreter is not None
219-
else LocalCodeInterpreter(timeout=_SESSION_TIMEOUT)
220-
)
215+
self.code_sandbox_runtime = code_sandbox_runtime
221216
self.callback_message = callback_message
222217
if self.verbosity >= 1:
223218
_LOGGER.setLevel(logging.INFO)
@@ -289,7 +284,9 @@ def chat_with_code(
289284
# this is setting remote artifacts path
290285
artifacts = Artifacts(WORKSPACE / "artifacts.pkl")
291286

292-
with self.code_interpreter as code_interpreter:
287+
with CodeInterpreterFactory.new_instance(
288+
code_sandbox_runtime=self.code_sandbox_runtime,
289+
) as code_interpreter:
293290
orig_chat = copy.deepcopy(chat)
294291
int_chat = copy.deepcopy(chat)
295292
last_user_message = chat[-1]
@@ -475,7 +472,7 @@ def __init__(
475472
agent: Optional[LMM] = None,
476473
verbosity: int = 0,
477474
local_artifacts_path: Optional[Union[str, Path]] = None,
478-
code_interpreter: Optional[CodeInterpreter] = None,
475+
code_sandbox_runtime: Optional[str] = None,
479476
callback_message: Optional[Callable[[Dict[str, Any]], None]] = None,
480477
) -> None:
481478
"""Initialize the VisionAgent using OpenAI LMMs.
@@ -486,15 +483,15 @@ def __init__(
486483
verbosity (int): The verbosity level of the agent.
487484
local_artifacts_path (Optional[Union[str, Path]]): The path to the local
488485
artifacts file.
489-
code_interpreter (Optional[CodeInterpreter]): The code interpreter to use, default to local python
486+
code_sandbox_runtime (Optional[str]): The code sandbox runtime to use.
490487
"""
491488

492489
agent = OpenAILMM(temperature=0.0, json_mode=True) if agent is None else agent
493490
super().__init__(
494491
agent,
495492
verbosity,
496493
local_artifacts_path,
497-
code_interpreter,
494+
code_sandbox_runtime,
498495
callback_message,
499496
)
500497

@@ -505,7 +502,7 @@ def __init__(
505502
agent: Optional[LMM] = None,
506503
verbosity: int = 0,
507504
local_artifacts_path: Optional[Union[str, Path]] = None,
508-
code_interpreter: Optional[CodeInterpreter] = None,
505+
code_sandbox_runtime: Optional[str] = None,
509506
callback_message: Optional[Callable[[Dict[str, Any]], None]] = None,
510507
) -> None:
511508
"""Initialize the VisionAgent using Anthropic LMMs.
@@ -516,14 +513,14 @@ def __init__(
516513
verbosity (int): The verbosity level of the agent.
517514
local_artifacts_path (Optional[Union[str, Path]]): The path to the local
518515
artifacts file.
519-
code_interpreter (Optional[CodeInterpreter]): The code interpreter to use, default to local python
516+
code_sandbox_runtime (Optional[str]): The code sandbox runtime to use.
520517
"""
521518

522519
agent = AnthropicLMM(temperature=0.0) if agent is None else agent
523520
super().__init__(
524521
agent,
525522
verbosity,
526523
local_artifacts_path,
527-
code_interpreter,
524+
code_sandbox_runtime,
528525
callback_message,
529526
)

0 commit comments

Comments
 (0)