mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 01:48:04 +08:00
fix(e2b): stupid e2b env variable not work
This commit is contained in:
@ -5,6 +5,7 @@ from dataclasses import dataclass
|
||||
from core.app.entities.app_asset_entities import AppAssetFileTree, AppAssetNode
|
||||
from core.app_assets.entities import AssetItem, FileAsset
|
||||
from core.app_assets.paths import AssetPaths
|
||||
from core.skill.entities.skill_bundle import SkillBundle
|
||||
from core.skill.entities.skill_document import SkillDocument
|
||||
from core.skill.skill_compiler import SkillCompiler
|
||||
from core.skill.skill_manager import SkillManager
|
||||
@ -47,6 +48,8 @@ class SkillBuilder:
|
||||
|
||||
def build(self, tree: AppAssetFileTree, ctx: BuildContext) -> list[AssetItem]:
|
||||
if not self._nodes:
|
||||
bundle = SkillBundle(assets_id=ctx.build_id)
|
||||
SkillManager.save_bundle(ctx.tenant_id, ctx.app_id, ctx.build_id, bundle)
|
||||
return []
|
||||
|
||||
# 1. Load all skills (parallel IO)
|
||||
|
||||
@ -43,7 +43,7 @@ def _truncate_output(output: str, name: str = "output") -> str:
|
||||
|
||||
|
||||
class SandboxBashTool(Tool):
|
||||
def __init__(self, sandbox: VirtualEnvironment, tenant_id: str, tools_path: str | None = None) -> None:
|
||||
def __init__(self, sandbox: VirtualEnvironment, tenant_id: str, tools_path: str) -> None:
|
||||
self._sandbox = sandbox
|
||||
self._tools_path = tools_path
|
||||
|
||||
@ -93,20 +93,20 @@ class SandboxBashTool(Tool):
|
||||
|
||||
try:
|
||||
with with_connection(self._sandbox) as conn:
|
||||
cmd_list = ["bash", "-c", command]
|
||||
# Build command with embedded environment variables
|
||||
env_exports = (
|
||||
f"export PATH={self._tools_path}:/usr/local/bin:/usr/bin:/bin && "
|
||||
f"export DIFY_CLI_CONFIG={self._tools_path}/{DifyCli.CONFIG_FILENAME} && "
|
||||
)
|
||||
full_command = env_exports + command
|
||||
|
||||
cmd_list = ["bash", "-c", full_command]
|
||||
sandbox_debug("bash_tool", "cmd_list", cmd_list)
|
||||
environments: dict[str, str] | None = None
|
||||
if self._tools_path:
|
||||
environments = {
|
||||
"PATH": f"{self._tools_path}:/usr/local/bin:/usr/bin:/bin",
|
||||
"DIFY_CLI_CONFIG": self._tools_path + f"/{DifyCli.CONFIG_FILENAME}",
|
||||
}
|
||||
|
||||
future = submit_command(
|
||||
self._sandbox,
|
||||
conn,
|
||||
cmd_list,
|
||||
environments=environments,
|
||||
)
|
||||
timeout = COMMAND_TIMEOUT_SECONDS if COMMAND_TIMEOUT_SECONDS > 0 else None
|
||||
result = future.result(timeout=timeout)
|
||||
|
||||
@ -15,12 +15,8 @@ class SkillManager:
|
||||
assets_id: str,
|
||||
) -> SkillBundle:
|
||||
key = AssetPaths.build_skill_bundle(tenant_id, app_id, assets_id)
|
||||
try:
|
||||
data = storage.load_once(key)
|
||||
return SkillBundle.model_validate_json(data)
|
||||
except Exception:
|
||||
logger.info("Skill bundle missing or invalid for assets_id=%s", assets_id)
|
||||
return SkillBundle(assets_id=assets_id)
|
||||
data = storage.load_once(key)
|
||||
return SkillBundle.model_validate_json(data)
|
||||
|
||||
@staticmethod
|
||||
def save_bundle(
|
||||
|
||||
Reference in New Issue
Block a user