create_agent¶
create_agent is the recommended entry point for the Python SDK. It constructs a fully-wired Agent from a local file or directory path, wiring up the workspace, sandbox factory, skill store, and persistence stores automatically.
Usage¶
from opendatasci import create_agent
async with create_agent("data.csv") as agent:
async for event in agent.astream("What is the average revenue by region?"):
if event.type == "token":
print(event.content, end="", flush=True)
The function returns an Agent that must be used as an async context manager. The sandbox is created on __aenter__ and released on __aexit__.
With a custom config¶
from opendatasci import create_agent, OpenDataSciConfig
config = OpenDataSciConfig(
provider="openai",
model="gpt-5.6-sol",
openai_api_key="sk-...",
)
async with create_agent("/data/sales.parquet", config=config) as agent:
async for event in agent.astream("Train a gradient-boosting classifier."):
...
Reference¶
create_agent
¶
create_agent(path: str, session_id: str | None = None, config: OpenDataSciConfig | None = None) -> Agent
Return a fully wired :class:Agent for a local file or directory.
The agent must be used as an async context manager so its sandbox is created and closed correctly::
async with create_agent("/data/sales.csv") as agent:
async for event in agent.astream("summarise the data"):
...
Resolves the workspace, sandbox factory, skill store, and persistence stores from path, then constructs and returns an agent ready to enter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to the data file or workspace directory to load. |
required |
config
|
OpenDataSciConfig | None
|
LLM provider and model settings. Falls back to the library default when omitted. |
None
|
session_id
|
str | None
|
Identifier for this session's context store. Generated automatically when omitted. |
None
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If path does not exist. |