refactor(沙箱工具): 将沙箱镜像配置改为从settings读取

默认镜像配置改为从settings.SANDBOX_IMAGE读取,提高配置灵活性
This commit is contained in:
lintsinghua 2025-12-17 18:07:11 +08:00
parent 99c0613cfa
commit dbf03c5ac3
1 changed files with 6 additions and 1 deletions

View File

@ -14,6 +14,7 @@ from pydantic import BaseModel, Field
from dataclasses import dataclass
from .base import AgentTool, ToolResult
from app.core.config import settings
logger = logging.getLogger(__name__)
@ -21,7 +22,7 @@ logger = logging.getLogger(__name__)
@dataclass
class SandboxConfig:
"""沙箱配置"""
image: str = "deepaudit/sandbox:latest"
image: str = None # 默认从 settings.SANDBOX_IMAGE 读取
memory_limit: str = "512m"
cpu_limit: float = 1.0
timeout: int = 60
@ -29,6 +30,10 @@ class SandboxConfig:
read_only: bool = True
user: str = "1000:1000"
def __post_init__(self):
if self.image is None:
self.image = settings.SANDBOX_IMAGE
class SandboxManager:
"""