mirror of
https://github.com/Katakate/k7.git
synced 2026-09-21 17:43:20 +00:00
d65ea43536
See CHANGELOG.md for what shipped.
1.4 KiB
1.4 KiB
LangChain ReAct Agent with K7 Sandbox Tool
This tutorial shows a minimal LangChain ReAct-style agent equipped with a tool that executes shell commands inside a K7 sandbox.
Prerequisites
- K7 API deployed and reachable (use
k7 start-apiand checkk7 api-statusfor the public URL) - API key generated:
k7 generate-api-key <name> - Python 3.10+
- uv (recommended): https://docs.astral.sh/uv/
Setup
- Install uv (if not installed):
curl -LsSf https://astral.sh/uv/install.sh | sh
- Create a
.envfile in this directory with:
K7_ENDPOINT=https://your-k7-endpoint
K7_API_KEY=your-api-key
K7_SANDBOX_NAME=lc-agent
K7_SANDBOX_IMAGE=alpine:latest
K7_NAMESPACE=default
OPENAI_API_KEY=sk-your-openai-key
OPENAI_MODEL=gpt-4o-mini
- Create an isolated environment and install dependencies (using uv):
# from this tutorial directory
uv venv .venv-lc
. .venv-lc/bin/activate
# core deps for the tutorial
uv pip install -r requirements.txt
# install the local K7 SDK from the repo source
# (two levels up from this tutorial dir)
uv pip install -e ../..
# or from the PyPI registry:
uv pip install k7-sdk
Run
python agent.py
Ask the agent to perform simple shell actions, e.g., "List files in /". The agent will decide to use the sandbox tool and return the output.
In parallel if you want you can shell into its sandbox:
k7 shell lc-agent
or replace lc-agent with the sandbox name you chose.