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

Set the model ID:

export NOVITA_MODEL_ID="deepseek/deepseek-v4-pro"
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="https://api.novita.ai/openai",
)

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.1.tar.gz (4.2 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.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_novita-0.1.1.tar.gz
  • Upload date:
  • Size: 4.2 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.1.tar.gz
Algorithm Hash digest
SHA256 1505ae302f33f9249479fb06ffeb501e961e0ba3a645508af752aa7da6ea31eb
MD5 2d57a06facd37f57c80ef5150f5cc672
BLAKE2b-256 cca3b072440b682536602d1fc3d98a73cf75e3f6c85c8cbe1caf091904e762cd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: langchain_novita-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a77dc7d49c19f827e9e90bca4be1b80aa43c60785f38fbe43e1f3f690472f64c
MD5 a019995fc7b988f53d7f269dea494c04
BLAKE2b-256 84b16bb5d23d89c78661ee43d42910a06cf021c5a8ba7c3ab7797604f960884a

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