agentscope-runtime 0.1.5b2__py3-none-any.whl → 0.2.0__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.
- agentscope_runtime/common/__init__.py +0 -0
- agentscope_runtime/common/collections/in_memory_mapping.py +27 -0
- agentscope_runtime/common/collections/redis_mapping.py +42 -0
- agentscope_runtime/common/container_clients/__init__.py +0 -0
- agentscope_runtime/common/container_clients/agentrun_client.py +1098 -0
- agentscope_runtime/common/container_clients/docker_client.py +250 -0
- agentscope_runtime/{sandbox/manager → common}/container_clients/kubernetes_client.py +6 -13
- agentscope_runtime/engine/__init__.py +12 -0
- agentscope_runtime/engine/agents/agentscope_agent.py +567 -0
- agentscope_runtime/engine/agents/agno_agent.py +26 -27
- agentscope_runtime/engine/agents/autogen_agent.py +13 -8
- agentscope_runtime/engine/agents/langgraph_agent.py +52 -9
- agentscope_runtime/engine/agents/utils.py +53 -0
- agentscope_runtime/engine/app/__init__.py +6 -0
- agentscope_runtime/engine/app/agent_app.py +239 -0
- agentscope_runtime/engine/app/base_app.py +181 -0
- agentscope_runtime/engine/app/celery_mixin.py +92 -0
- agentscope_runtime/engine/deployers/adapter/responses/response_api_adapter_utils.py +5 -1
- agentscope_runtime/engine/deployers/base.py +1 -0
- agentscope_runtime/engine/deployers/cli_fc_deploy.py +39 -20
- agentscope_runtime/engine/deployers/kubernetes_deployer.py +12 -5
- agentscope_runtime/engine/deployers/local_deployer.py +61 -3
- agentscope_runtime/engine/deployers/modelstudio_deployer.py +201 -40
- agentscope_runtime/engine/deployers/utils/docker_image_utils/runner_image_factory.py +9 -0
- agentscope_runtime/engine/deployers/utils/package_project_utils.py +234 -3
- agentscope_runtime/engine/deployers/utils/service_utils/fastapi_factory.py +567 -7
- agentscope_runtime/engine/deployers/utils/service_utils/standalone_main.py.j2 +211 -0
- agentscope_runtime/engine/deployers/utils/wheel_packager.py +1 -1
- agentscope_runtime/engine/helpers/helper.py +60 -41
- agentscope_runtime/engine/runner.py +40 -24
- agentscope_runtime/engine/schemas/agent_schemas.py +42 -0
- agentscope_runtime/engine/schemas/modelstudio_llm.py +14 -14
- agentscope_runtime/engine/services/sandbox_service.py +62 -70
- agentscope_runtime/engine/services/tablestore_memory_service.py +307 -0
- agentscope_runtime/engine/services/tablestore_rag_service.py +143 -0
- agentscope_runtime/engine/services/tablestore_session_history_service.py +293 -0
- agentscope_runtime/engine/services/utils/__init__.py +0 -0
- agentscope_runtime/engine/services/utils/tablestore_service_utils.py +352 -0
- agentscope_runtime/engine/tracing/__init__.py +9 -3
- agentscope_runtime/engine/tracing/asyncio_util.py +24 -0
- agentscope_runtime/engine/tracing/base.py +66 -34
- agentscope_runtime/engine/tracing/local_logging_handler.py +45 -31
- agentscope_runtime/engine/tracing/message_util.py +528 -0
- agentscope_runtime/engine/tracing/tracing_metric.py +20 -8
- agentscope_runtime/engine/tracing/tracing_util.py +130 -0
- agentscope_runtime/engine/tracing/wrapper.py +794 -169
- agentscope_runtime/sandbox/__init__.py +2 -0
- agentscope_runtime/sandbox/box/base/__init__.py +4 -0
- agentscope_runtime/sandbox/box/base/base_sandbox.py +6 -4
- agentscope_runtime/sandbox/box/browser/__init__.py +4 -0
- agentscope_runtime/sandbox/box/browser/browser_sandbox.py +10 -14
- agentscope_runtime/sandbox/box/dummy/__init__.py +4 -0
- agentscope_runtime/sandbox/box/dummy/dummy_sandbox.py +2 -1
- agentscope_runtime/sandbox/box/filesystem/__init__.py +4 -0
- agentscope_runtime/sandbox/box/filesystem/filesystem_sandbox.py +10 -7
- agentscope_runtime/sandbox/box/gui/__init__.py +4 -0
- agentscope_runtime/sandbox/box/gui/box/__init__.py +0 -0
- agentscope_runtime/sandbox/box/gui/gui_sandbox.py +81 -0
- agentscope_runtime/sandbox/box/sandbox.py +5 -2
- agentscope_runtime/sandbox/box/shared/routers/generic.py +20 -1
- agentscope_runtime/sandbox/box/training_box/__init__.py +4 -0
- agentscope_runtime/sandbox/box/training_box/training_box.py +7 -54
- agentscope_runtime/sandbox/build.py +143 -58
- agentscope_runtime/sandbox/client/http_client.py +87 -59
- agentscope_runtime/sandbox/client/training_client.py +0 -1
- agentscope_runtime/sandbox/constant.py +27 -1
- agentscope_runtime/sandbox/custom/custom_sandbox.py +7 -6
- agentscope_runtime/sandbox/custom/example.py +4 -3
- agentscope_runtime/sandbox/enums.py +1 -1
- agentscope_runtime/sandbox/manager/sandbox_manager.py +212 -106
- agentscope_runtime/sandbox/manager/server/app.py +82 -14
- agentscope_runtime/sandbox/manager/server/config.py +50 -3
- agentscope_runtime/sandbox/model/container.py +12 -23
- agentscope_runtime/sandbox/model/manager_config.py +93 -5
- agentscope_runtime/sandbox/registry.py +1 -1
- agentscope_runtime/sandbox/tools/gui/__init__.py +7 -0
- agentscope_runtime/sandbox/tools/gui/tool.py +77 -0
- agentscope_runtime/sandbox/tools/mcp_tool.py +6 -2
- agentscope_runtime/sandbox/tools/tool.py +4 -0
- agentscope_runtime/sandbox/utils.py +124 -0
- agentscope_runtime/version.py +1 -1
- {agentscope_runtime-0.1.5b2.dist-info → agentscope_runtime-0.2.0.dist-info}/METADATA +246 -111
- {agentscope_runtime-0.1.5b2.dist-info → agentscope_runtime-0.2.0.dist-info}/RECORD +96 -80
- agentscope_runtime/engine/agents/agentscope_agent/__init__.py +0 -6
- agentscope_runtime/engine/agents/agentscope_agent/agent.py +0 -401
- agentscope_runtime/engine/agents/agentscope_agent/hooks.py +0 -169
- agentscope_runtime/engine/agents/llm_agent.py +0 -51
- agentscope_runtime/engine/llms/__init__.py +0 -3
- agentscope_runtime/engine/llms/base_llm.py +0 -60
- agentscope_runtime/engine/llms/qwen_llm.py +0 -47
- agentscope_runtime/sandbox/manager/collections/in_memory_mapping.py +0 -22
- agentscope_runtime/sandbox/manager/collections/redis_mapping.py +0 -26
- agentscope_runtime/sandbox/manager/container_clients/__init__.py +0 -10
- agentscope_runtime/sandbox/manager/container_clients/docker_client.py +0 -422
- /agentscope_runtime/{sandbox/manager → common}/collections/__init__.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/base_mapping.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/base_queue.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/base_set.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/in_memory_queue.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/in_memory_set.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/redis_queue.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/collections/redis_set.py +0 -0
- /agentscope_runtime/{sandbox/manager → common}/container_clients/base_client.py +0 -0
- {agentscope_runtime-0.1.5b2.dist-info → agentscope_runtime-0.2.0.dist-info}/WHEEL +0 -0
- {agentscope_runtime-0.1.5b2.dist-info → agentscope_runtime-0.2.0.dist-info}/entry_points.txt +0 -0
- {agentscope_runtime-0.1.5b2.dist-info → agentscope_runtime-0.2.0.dist-info}/licenses/LICENSE +0 -0
- {agentscope_runtime-0.1.5b2.dist-info → agentscope_runtime-0.2.0.dist-info}/top_level.txt +0 -0
|
@@ -3,6 +3,7 @@ from .custom import *
|
|
|
3
3
|
from .box.base.base_sandbox import BaseSandbox
|
|
4
4
|
from .box.browser.browser_sandbox import BrowserSandbox
|
|
5
5
|
from .box.filesystem.filesystem_sandbox import FilesystemSandbox
|
|
6
|
+
from .box.gui.gui_sandbox import GuiSandbox
|
|
6
7
|
from .box.training_box.training_box import TrainingSandbox
|
|
7
8
|
|
|
8
9
|
|
|
@@ -10,5 +11,6 @@ __all__ = [
|
|
|
10
11
|
"BaseSandbox",
|
|
11
12
|
"BrowserSandbox",
|
|
12
13
|
"FilesystemSandbox",
|
|
14
|
+
"GuiSandbox",
|
|
13
15
|
"TrainingSandbox",
|
|
14
16
|
]
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
from typing import Optional
|
|
3
3
|
|
|
4
|
-
from ...
|
|
4
|
+
from ...utils import build_image_uri
|
|
5
5
|
from ...registry import SandboxRegistry
|
|
6
6
|
from ...enums import SandboxType
|
|
7
7
|
from ...box.sandbox import Sandbox
|
|
8
|
+
from ...constant import TIMEOUT
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
@SandboxRegistry.register(
|
|
11
|
-
|
|
12
|
+
build_image_uri("runtime-sandbox-base"),
|
|
12
13
|
sandbox_type=SandboxType.BASE,
|
|
13
14
|
security_level="medium",
|
|
14
|
-
timeout=
|
|
15
|
+
timeout=TIMEOUT,
|
|
15
16
|
description="Base Sandbox",
|
|
16
17
|
)
|
|
17
18
|
class BaseSandbox(Sandbox):
|
|
@@ -21,13 +22,14 @@ class BaseSandbox(Sandbox):
|
|
|
21
22
|
timeout: int = 3000,
|
|
22
23
|
base_url: Optional[str] = None,
|
|
23
24
|
bearer_token: Optional[str] = None,
|
|
25
|
+
sandbox_type: SandboxType = SandboxType.BASE,
|
|
24
26
|
):
|
|
25
27
|
super().__init__(
|
|
26
28
|
sandbox_id,
|
|
27
29
|
timeout,
|
|
28
30
|
base_url,
|
|
29
31
|
bearer_token,
|
|
30
|
-
|
|
32
|
+
sandbox_type,
|
|
31
33
|
)
|
|
32
34
|
|
|
33
35
|
def run_ipython_cell(self, code: str):
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
from typing import Optional
|
|
4
4
|
from urllib.parse import urlparse, urlunparse
|
|
5
5
|
|
|
6
|
-
from ...
|
|
6
|
+
from ...utils import build_image_uri
|
|
7
7
|
from ...registry import SandboxRegistry
|
|
8
8
|
from ...enums import SandboxType
|
|
9
|
-
from ...box.
|
|
9
|
+
from ...box.base import BaseSandbox
|
|
10
|
+
from ...box.gui import GUIMixin
|
|
11
|
+
from ...constant import TIMEOUT
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
def http_to_ws(url, use_localhost=True):
|
|
@@ -27,35 +29,29 @@ def http_to_ws(url, use_localhost=True):
|
|
|
27
29
|
|
|
28
30
|
|
|
29
31
|
@SandboxRegistry.register(
|
|
30
|
-
|
|
32
|
+
build_image_uri("runtime-sandbox-browser"),
|
|
31
33
|
sandbox_type=SandboxType.BROWSER,
|
|
32
34
|
security_level="medium",
|
|
33
|
-
timeout=
|
|
35
|
+
timeout=TIMEOUT,
|
|
34
36
|
description="Browser sandbox",
|
|
35
37
|
)
|
|
36
|
-
class BrowserSandbox(
|
|
37
|
-
def __init__(
|
|
38
|
+
class BrowserSandbox(GUIMixin, BaseSandbox):
|
|
39
|
+
def __init__( # pylint: disable=useless-parent-delegation
|
|
38
40
|
self,
|
|
39
41
|
sandbox_id: Optional[str] = None,
|
|
40
42
|
timeout: int = 3000,
|
|
41
43
|
base_url: Optional[str] = None,
|
|
42
44
|
bearer_token: Optional[str] = None,
|
|
45
|
+
sandbox_type: SandboxType = SandboxType.BROWSER,
|
|
43
46
|
):
|
|
44
47
|
super().__init__(
|
|
45
48
|
sandbox_id,
|
|
46
49
|
timeout,
|
|
47
50
|
base_url,
|
|
48
51
|
bearer_token,
|
|
49
|
-
|
|
52
|
+
sandbox_type,
|
|
50
53
|
)
|
|
51
54
|
|
|
52
|
-
@property
|
|
53
|
-
def browser_ws(self):
|
|
54
|
-
if self.base_url is None:
|
|
55
|
-
# Local mode
|
|
56
|
-
return self.get_info()["front_browser_ws"]
|
|
57
|
-
return http_to_ws(f"{self.base_url}/browser/{self.sandbox_id}/cast")
|
|
58
|
-
|
|
59
55
|
def browser_close(self):
|
|
60
56
|
return self.call_tool("browser_close", {})
|
|
61
57
|
|
|
@@ -4,13 +4,14 @@ from typing import Optional
|
|
|
4
4
|
from ...registry import SandboxRegistry
|
|
5
5
|
from ...enums import SandboxType
|
|
6
6
|
from ...box.sandbox import Sandbox
|
|
7
|
+
from ...constant import TIMEOUT
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
@SandboxRegistry.register(
|
|
10
11
|
"",
|
|
11
12
|
sandbox_type=SandboxType.DUMMY,
|
|
12
13
|
security_level="low",
|
|
13
|
-
timeout=
|
|
14
|
+
timeout=TIMEOUT,
|
|
14
15
|
description="Dummy Sandbox",
|
|
15
16
|
)
|
|
16
17
|
class DummySandbox(Sandbox):
|
|
@@ -2,33 +2,36 @@
|
|
|
2
2
|
# pylint: disable=dangerous-default-value
|
|
3
3
|
from typing import Optional
|
|
4
4
|
|
|
5
|
-
from ...
|
|
5
|
+
from ...utils import build_image_uri
|
|
6
6
|
from ...registry import SandboxRegistry
|
|
7
7
|
from ...enums import SandboxType
|
|
8
|
-
from ...box.
|
|
8
|
+
from ...box.base import BaseSandbox
|
|
9
|
+
from ...box.gui import GUIMixin
|
|
10
|
+
from ...constant import TIMEOUT
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
@SandboxRegistry.register(
|
|
12
|
-
|
|
14
|
+
build_image_uri("runtime-sandbox-filesystem"),
|
|
13
15
|
sandbox_type=SandboxType.FILESYSTEM,
|
|
14
16
|
security_level="medium",
|
|
15
|
-
timeout=
|
|
17
|
+
timeout=TIMEOUT,
|
|
16
18
|
description="Filesystem sandbox",
|
|
17
19
|
)
|
|
18
|
-
class FilesystemSandbox(
|
|
19
|
-
def __init__(
|
|
20
|
+
class FilesystemSandbox(GUIMixin, BaseSandbox):
|
|
21
|
+
def __init__( # pylint: disable=useless-parent-delegation
|
|
20
22
|
self,
|
|
21
23
|
sandbox_id: Optional[str] = None,
|
|
22
24
|
timeout: int = 3000,
|
|
23
25
|
base_url: Optional[str] = None,
|
|
24
26
|
bearer_token: Optional[str] = None,
|
|
27
|
+
sandbox_type: SandboxType = SandboxType.FILESYSTEM,
|
|
25
28
|
):
|
|
26
29
|
super().__init__(
|
|
27
30
|
sandbox_id,
|
|
28
31
|
timeout,
|
|
29
32
|
base_url,
|
|
30
33
|
bearer_token,
|
|
31
|
-
|
|
34
|
+
sandbox_type,
|
|
32
35
|
)
|
|
33
36
|
|
|
34
37
|
def read_file(self, path: str):
|
|
File without changes
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import logging
|
|
3
|
+
from typing import Optional, Union, Tuple, List
|
|
4
|
+
|
|
5
|
+
from urllib.parse import urljoin, urlencode
|
|
6
|
+
|
|
7
|
+
from ...utils import build_image_uri, get_platform
|
|
8
|
+
from ...registry import SandboxRegistry
|
|
9
|
+
from ...enums import SandboxType
|
|
10
|
+
from ...box.base import BaseSandbox
|
|
11
|
+
from ...constant import TIMEOUT
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class GUIMixin:
|
|
17
|
+
@property
|
|
18
|
+
def desktop_url(self):
|
|
19
|
+
if not self.manager_api.check_health(identity=self.sandbox_id):
|
|
20
|
+
raise RuntimeError(f"Sandbox {self.sandbox_id} is not healthy")
|
|
21
|
+
|
|
22
|
+
info = self.get_info()
|
|
23
|
+
path = "/vnc/vnc_lite.html"
|
|
24
|
+
remote_path = "/vnc/vnc_relay.html"
|
|
25
|
+
params = {"password": info["runtime_token"]}
|
|
26
|
+
|
|
27
|
+
if self.base_url is None:
|
|
28
|
+
return urljoin(info["url"], path) + "?" + urlencode(params)
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
f"{self.base_url}/desktop/{self.sandbox_id}{remote_path}"
|
|
32
|
+
f"?{urlencode(params)}"
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@SandboxRegistry.register(
|
|
37
|
+
build_image_uri("runtime-sandbox-gui"),
|
|
38
|
+
sandbox_type=SandboxType.GUI,
|
|
39
|
+
security_level="high",
|
|
40
|
+
timeout=TIMEOUT,
|
|
41
|
+
description="GUI Sandbox",
|
|
42
|
+
)
|
|
43
|
+
class GuiSandbox(GUIMixin, BaseSandbox):
|
|
44
|
+
def __init__( # pylint: disable=useless-parent-delegation
|
|
45
|
+
self,
|
|
46
|
+
sandbox_id: Optional[str] = None,
|
|
47
|
+
timeout: int = 3000,
|
|
48
|
+
base_url: Optional[str] = None,
|
|
49
|
+
bearer_token: Optional[str] = None,
|
|
50
|
+
sandbox_type: SandboxType = SandboxType.GUI,
|
|
51
|
+
):
|
|
52
|
+
super().__init__(
|
|
53
|
+
sandbox_id,
|
|
54
|
+
timeout,
|
|
55
|
+
base_url,
|
|
56
|
+
bearer_token,
|
|
57
|
+
sandbox_type,
|
|
58
|
+
)
|
|
59
|
+
if get_platform() == "linux/arm64":
|
|
60
|
+
logger.warning(
|
|
61
|
+
"\nCompatibility Notice: This GUI Sandbox may have issues on "
|
|
62
|
+
"arm64 CPU architectures, due to the computer-use-mcp does "
|
|
63
|
+
"not provide linux/arm64 compatibility. It has been tested "
|
|
64
|
+
"to work on Apple M4 chips with Rosetta enabled. However, "
|
|
65
|
+
"on M1, M2, and M3 chips, chromium browser might crash due "
|
|
66
|
+
"to the missing SSE3 instruction set.",
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
def computer_use(
|
|
70
|
+
self,
|
|
71
|
+
action: str,
|
|
72
|
+
coordinate: Optional[Union[List[float], Tuple[float, float]]] = None,
|
|
73
|
+
text: Optional[str] = None,
|
|
74
|
+
):
|
|
75
|
+
payload = {"action": action}
|
|
76
|
+
if coordinate is not None:
|
|
77
|
+
payload["coordinate"] = coordinate
|
|
78
|
+
if text is not None:
|
|
79
|
+
payload["text"] = text
|
|
80
|
+
|
|
81
|
+
return self.call_tool("computer", payload)
|
|
@@ -49,7 +49,7 @@ class Sandbox:
|
|
|
49
49
|
)
|
|
50
50
|
|
|
51
51
|
sandbox_id = self.manager_api.create_from_pool(
|
|
52
|
-
sandbox_type=sandbox_type.value,
|
|
52
|
+
sandbox_type=SandboxType(sandbox_type).value,
|
|
53
53
|
)
|
|
54
54
|
if sandbox_id is None:
|
|
55
55
|
raise RuntimeError(
|
|
@@ -115,8 +115,11 @@ class Sandbox:
|
|
|
115
115
|
# Clean the specific sandbox
|
|
116
116
|
self.manager_api.release(self.sandbox_id)
|
|
117
117
|
except Exception as e:
|
|
118
|
+
import traceback
|
|
119
|
+
|
|
118
120
|
logger.error(
|
|
119
|
-
f"Cleanup {self.sandbox_id} error: {e}"
|
|
121
|
+
f"Cleanup {self.sandbox_id} error: {e}\n"
|
|
122
|
+
f"{traceback.format_exc()}",
|
|
120
123
|
)
|
|
121
124
|
|
|
122
125
|
def __enter__(self):
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
import io
|
|
3
|
+
import sys
|
|
3
4
|
import logging
|
|
4
5
|
import subprocess
|
|
5
6
|
import traceback
|
|
@@ -44,7 +45,25 @@ async def run_ipython_cell(
|
|
|
44
45
|
stderr_buf = io.StringIO()
|
|
45
46
|
|
|
46
47
|
with redirect_stdout(stdout_buf), redirect_stderr(stderr_buf):
|
|
47
|
-
|
|
48
|
+
preprocessing_exc_tuple = None
|
|
49
|
+
try:
|
|
50
|
+
transformed_cell = ipy.transform_cell(code)
|
|
51
|
+
except Exception:
|
|
52
|
+
transformed_cell = code
|
|
53
|
+
preprocessing_exc_tuple = sys.exc_info()
|
|
54
|
+
|
|
55
|
+
if transformed_cell is None:
|
|
56
|
+
raise HTTPException(
|
|
57
|
+
status_code=500,
|
|
58
|
+
detail="IPython cell transformation failed: "
|
|
59
|
+
"transformed_cell is None.",
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
await ipy.run_cell_async(
|
|
63
|
+
code,
|
|
64
|
+
transformed_cell=transformed_cell,
|
|
65
|
+
preprocessing_exc_tuple=preprocessing_exc_tuple,
|
|
66
|
+
)
|
|
48
67
|
|
|
49
68
|
stdout_content = stdout_buf.getvalue()
|
|
50
69
|
stderr_content = stderr_buf.getvalue()
|
|
@@ -5,21 +5,13 @@ Module for the Training Sandbox implementation.
|
|
|
5
5
|
This module provides a sandbox environment for training tasks
|
|
6
6
|
with specific configuration and tool calling methods.
|
|
7
7
|
"""
|
|
8
|
-
import platform
|
|
9
8
|
from typing import Dict, Optional
|
|
10
9
|
import os
|
|
11
10
|
|
|
11
|
+
from ...utils import build_image_uri
|
|
12
12
|
from ...registry import SandboxRegistry
|
|
13
13
|
from ...enums import SandboxType
|
|
14
14
|
from ...box.sandbox import Sandbox
|
|
15
|
-
from ...constant import IMAGE_TAG
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def get_image_tag() -> str:
|
|
19
|
-
machine = platform.machine().lower()
|
|
20
|
-
if machine in ("arm64", "aarch64", "armv7l", "armv8"):
|
|
21
|
-
return f"{IMAGE_TAG}-arm64"
|
|
22
|
-
return IMAGE_TAG
|
|
23
15
|
|
|
24
16
|
|
|
25
17
|
class TrainingSandbox(Sandbox):
|
|
@@ -214,7 +206,7 @@ class TrainingSandbox(Sandbox):
|
|
|
214
206
|
|
|
215
207
|
|
|
216
208
|
@SandboxRegistry.register(
|
|
217
|
-
|
|
209
|
+
build_image_uri("runtime-sandbox-appworld", arm64_compatible=False),
|
|
218
210
|
sandbox_type=SandboxType.APPWORLD,
|
|
219
211
|
runtime_config={"shm_size": "5.06gb"},
|
|
220
212
|
security_level="medium",
|
|
@@ -235,6 +227,7 @@ class APPWorldSandbox(TrainingSandbox):
|
|
|
235
227
|
timeout: int = 3000,
|
|
236
228
|
base_url: Optional[str] = None,
|
|
237
229
|
bearer_token: Optional[str] = None,
|
|
230
|
+
sandbox_type: SandboxType = SandboxType.APPWORLD,
|
|
238
231
|
):
|
|
239
232
|
"""
|
|
240
233
|
Initialize the Training Sandbox.
|
|
@@ -250,7 +243,7 @@ class APPWorldSandbox(TrainingSandbox):
|
|
|
250
243
|
timeout,
|
|
251
244
|
base_url,
|
|
252
245
|
bearer_token,
|
|
253
|
-
|
|
246
|
+
sandbox_type,
|
|
254
247
|
)
|
|
255
248
|
|
|
256
249
|
|
|
@@ -258,7 +251,7 @@ DATASET_SUB_TYPE = os.environ.get("DATASET_SUB_TYPE", "multi_turn")
|
|
|
258
251
|
|
|
259
252
|
|
|
260
253
|
@SandboxRegistry.register(
|
|
261
|
-
|
|
254
|
+
build_image_uri("runtime-sandbox-bfcl", arm64_compatible=False),
|
|
262
255
|
sandbox_type=SandboxType.BFCL,
|
|
263
256
|
runtime_config={"shm_size": "8.06gb"},
|
|
264
257
|
security_level="medium",
|
|
@@ -289,6 +282,7 @@ class BFCLSandbox(TrainingSandbox):
|
|
|
289
282
|
timeout: int = 3000,
|
|
290
283
|
base_url: Optional[str] = None,
|
|
291
284
|
bearer_token: Optional[str] = None,
|
|
285
|
+
sandbox_type: SandboxType = SandboxType.BFCL,
|
|
292
286
|
):
|
|
293
287
|
"""
|
|
294
288
|
Initialize the Training Sandbox.
|
|
@@ -304,46 +298,5 @@ class BFCLSandbox(TrainingSandbox):
|
|
|
304
298
|
timeout,
|
|
305
299
|
base_url,
|
|
306
300
|
bearer_token,
|
|
307
|
-
|
|
308
|
-
)
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
@SandboxRegistry.register(
|
|
312
|
-
f"agentscope/runtime-sandbox-webshop:{get_image_tag()}",
|
|
313
|
-
sandbox_type=SandboxType.WEBSHOP,
|
|
314
|
-
runtime_config={"shm_size": "5.06gb"},
|
|
315
|
-
security_level="medium",
|
|
316
|
-
timeout=30,
|
|
317
|
-
description="webshop Sandbox",
|
|
318
|
-
)
|
|
319
|
-
class WebShopSandbox(TrainingSandbox):
|
|
320
|
-
"""
|
|
321
|
-
Training Sandbox class for managing and executing training-related tasks.
|
|
322
|
-
|
|
323
|
-
This class provides methods to create, manage, and interact with
|
|
324
|
-
training environment instances using specialized tool calls.
|
|
325
|
-
"""
|
|
326
|
-
|
|
327
|
-
def __init__(
|
|
328
|
-
self,
|
|
329
|
-
sandbox_id: Optional[str] = None,
|
|
330
|
-
timeout: int = 3000,
|
|
331
|
-
base_url: Optional[str] = None,
|
|
332
|
-
bearer_token: Optional[str] = None,
|
|
333
|
-
):
|
|
334
|
-
"""
|
|
335
|
-
Initialize the Training Sandbox.
|
|
336
|
-
|
|
337
|
-
Args:
|
|
338
|
-
sandbox_id (Optional[str]): Unique identifier for the sandbox.
|
|
339
|
-
timeout (int): Maximum time allowed for sandbox operations.
|
|
340
|
-
base_url (Optional[str]): Base URL for sandbox API.
|
|
341
|
-
bearer_token (Optional[str]): Authentication token for API access.
|
|
342
|
-
"""
|
|
343
|
-
super().__init__(
|
|
344
|
-
sandbox_id,
|
|
345
|
-
timeout,
|
|
346
|
-
base_url,
|
|
347
|
-
bearer_token,
|
|
348
|
-
SandboxType.BFCL,
|
|
301
|
+
sandbox_type,
|
|
349
302
|
)
|