Files
dify/api/core/sandbox/initializer/skill_initializer.py
Harry a43efef9f0 refactor(skill): transition from artifact set to bundle structure
- Replaced SkillArtifactSet with SkillBundle across various components, enhancing the organization of skill dependencies and references.
- Updated SkillManager methods to load and save bundles instead of artifacts, improving clarity in asset management.
- Refactored SkillCompiler to compile skills into bundles, streamlining the dependency resolution process.
- Adjusted DifyCli and SandboxBashSession to utilize ToolDependencies, ensuring consistent handling of tool references.
- Introduced AssetReferences for better management of file dependencies within skill bundles.
2026-01-22 22:46:57 +08:00

44 lines
1.1 KiB
Python

from __future__ import annotations
import logging
from core.sandbox.sandbox import Sandbox
from core.skill import SkillAttrs
from core.skill.skill_manager import SkillManager
from .base import SyncSandboxInitializer
logger = logging.getLogger(__name__)
class SkillInitializer(SyncSandboxInitializer):
def __init__(
self,
tenant_id: str,
user_id: str,
app_id: str,
assets_id: str,
) -> None:
self._tenant_id = tenant_id
self._app_id = app_id
self._user_id = user_id
self._assets_id = assets_id
def initialize(self, sandbox: Sandbox) -> None:
bundle = SkillManager.load_bundle(
self._tenant_id,
self._app_id,
self._assets_id,
)
if bundle is None:
raise ValueError(
f"No skill bundle found for tenant_id={self._tenant_id}, "
f"app_id={self._app_id}, "
f"assets_id={self._assets_id}"
)
sandbox.attrs.set(
SkillAttrs.BUNDLE,
bundle,
)