Skip to content

Latest commit

 

History

History

sdk-python

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

berthos-sdk

Build a Berth resident app in Python. It uses the same berth.yml manifest, RPC protocol and context bus as the TypeScript SDK, @berthos/sdk.

Berth runs an AI agent's tools in a sandbox. Each tool declares what it may touch in a berth.yml manifest, and the Linux kernel enforces it.

pip install berthos-sdk

Needs Python 3.11+. The import name is berth_sdk.

Usage

from berth_sdk import define_app
from pydantic import BaseModel


class GreetInput(BaseModel):
    name: str


class GreetOutput(BaseModel):
    message: str


def setup(app):
    app.export(
        "greet",
        lambda inp: GreetOutput(message=f"hello {inp.name}"),
        input_model=GreetInput,
        output_model=GreetOutput,
    )


app = define_app(setup)

Declare greet under exports in berth.yml too. Without input_model, a handler receives the raw input dict. Run the app with berth dev from @berthos/cli; the hello-world-py app is a complete example.

Docs

Python SDK reference · Python and the context bus · Repo