Sign inSign up

docker/sbx-kit-smolagents:latest

Multi-platform
Manifest digest

sha256:32b95035de6bdbe500bca6ee68f7ecb5d13b85bb4e8e1fc2f0856ad3efaaa960

Last pushed

9 days by cdupuis

Type

Sandbox Kit

Manifest digest

sha256:32b95035de6bdbe500bca6ee68f7ecb5d13b85bb4e8e1fc2f0856ad3efaaa960

yaml
schemaVersion: "3"
displayName: smolagents
description: Installs Hugging Face smolagents in an isolated Python virtual environment and exposes the smolagent and webagent CLIs inside the sandbox.
kind: mixin
provides:
    - [email protected]
requires:
    - deb/apt
capabilities:
    - type: com.docker.sandbox/network-policy@1
      config:
        install:
            allow:
                - pypi.org
                - files.pythonhosted.org
                - archive.ubuntu.com
                - security.ubuntu.com
                - ports.ubuntu.com
                - download.docker.com
        runtime:
            allow:
                - huggingface.co
                - hf.co
                - router.huggingface.co
                - duckduckgo.com
                - html.duckduckgo.com
                - www.duckduckgo.com
    - type: com.docker.sandbox/lifecycle@1
      config:
        install:
            - command: apt-get update && apt-get install -y --no-install-recommends ca-certificates python3 python3-venv python3-pip && rm -rf /var/lib/apt/lists/*
              description: Install Python and venv prerequisites for smolagents
              user: "0"
            - command: |
                set -euo pipefail
                SMOLAGENTS_VERSION=1.26.0
                python3 -m venv /opt/smolagents
                /opt/smolagents/bin/python -m pip install --upgrade pip setuptools wheel
                /opt/smolagents/bin/python -m pip install "smolagents[toolkit,vision]==${SMOLAGENTS_VERSION}"
                ln -sf /opt/smolagents/bin/smolagent /usr/local/bin/smolagent
                ln -sf /opt/smolagents/bin/webagent /usr/local/bin/webagent
                cat > /usr/local/bin/smolagents-python <<'SCRIPT'
                #!/bin/sh
                exec /opt/smolagents/bin/python "$@"
                SCRIPT
                chmod 0755 /usr/local/bin/smolagents-python
                smolagent --help >/dev/null
                webagent --help >/dev/null
                # The pin is a claim about content, so something has to enforce it.
                # For the already-baked kits in this repo that is a build step; here
                # the install is still create-time, so this is the only place the
                # check can live — it fails sandbox creation rather than a publish,
                # which is weaker, and is one more cost of the venv not travelling.
                installed=$(/opt/smolagents/bin/python -c 'import smolagents; print(smolagents.__version__)')
                echo "smolagents ${installed}"
                [ "${installed}" = "${SMOLAGENTS_VERSION}" ] || {
                  echo "pin mismatch: kit declares ${SMOLAGENTS_VERSION}, venv has ${installed}" >&2
                  exit 1
                }
              description: Install smolagents v1.26.0 with toolkit and vision extras in /opt/smolagents
              env:
                - HTTP_PROXY
                - HTTPS_PROXY
              user: "0"
            - command: |
                set -euo pipefail
                grep -qF 'smolagents-python' ~/.bashrc 2>/dev/null || \
                  printf '\n# smolagents (added by sbx-kits-contrib/smolagents)\nexport SMOLAGENTS_VENV=/opt/smolagents\nexport SMOLAGENTS_PYTHON=/opt/smolagents/bin/python\nalias smolagents-python=/opt/smolagents/bin/python\n' >> ~/.bashrc
              description: Add smolagents helper environment variables to interactive shells
              user: "1000"