Skip to main content

Novita sandbox backend integration for LangChain Deep Agents

Project description

langchain-novita

Novita sandbox backend integration for LangChain Deep Agents.

Novita provides code interpreter sandboxes for running commands in isolated environments. See the Novita docs for signup, authentication, and platform details.

Installation

pip install -U langchain-novita
uv add langchain-novita

Set your Novita credentials:

export NOVITA_API_KEY="your-api-key"

Create a sandbox backend

In Python, create the sandbox using the Novita SDK, then wrap it with the Deep Agents backend:

from novita_sandbox.code_interpreter import Sandbox

from langchain_novita import NovitaSandbox

sandbox = Sandbox.create()
backend = NovitaSandbox(sandbox=sandbox)

result = backend.execute("echo hello")
print(result.output)

Use with Deep Agents

Novita's LLM API is compatible with OpenAI's Chat Completions API. To use Novita models with Deep Agents, install langchain-openai and configure ChatOpenAI with Novita's base URL.

pip install -U langchain-openai
import os

from langchain_openai import ChatOpenAI
from novita_sandbox.code_interpreter import Sandbox

from deepagents import create_deep_agent
from langchain_novita import NovitaSandbox

sandbox = Sandbox.create()
backend = NovitaSandbox(sandbox=sandbox)

model = ChatOpenAI(
    model=os.environ["NOVITA_MODEL_ID"],
    api_key=os.environ["NOVITA_API_KEY"],
    base_url=os.environ["NOVITA_BASE_URL"],
)

agent = create_deep_agent(
    model=model,
    system_prompt="You are a coding assistant with sandbox access.",
    backend=backend,
)

result = agent.invoke(
    {
        "messages": [
            {"role": "user", "content": "Create a hello world Python script and run it"}
        ]
    }
)

Cleanup

You are responsible for managing the sandbox lifecycle via the Novita SDK. When you are done, kill the sandbox:

sandbox.kill()

Testing

Install test dependencies:

poetry install --with test

Run unit tests:

poetry run pytest tests/unit_tests

Run the standard sandbox integration tests:

export NOVITA_API_KEY="your-api-key"
poetry run pytest tests/integration_tests/test_sandbox.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_novita-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_novita-0.1.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file langchain_novita-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_novita-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.2 Darwin/25.3.0

File hashes

Hashes for langchain_novita-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6f561b2eba2d30dc9f143d9f566dea4576837fd2c526ec91f8f7fc907b62cce8
MD5 5aaf7be7b9b1c5dc4cbe893697357f54
BLAKE2b-256 2690772ac38fe6692fae6fe395a0256df615e4c6e1a6f73ea2665f8342d66f13

See more details on using hashes here.

File details

Details for the file langchain_novita-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: langchain_novita-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.2 Darwin/25.3.0

File hashes

Hashes for langchain_novita-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1256ef75c6d80cb6522c96e9ef080a9e8cfd6f2879c245747efc9aa3a2c0f793
MD5 3fd6d5cec194573247ded9d5e8a5d43b
BLAKE2b-256 906e9c6a4928cfed3f643041218e7fe3f09599206928446698a08ce99519fdac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page