API Reference / agent / adapters /

pydantic_ai.py

Pydantic-AI adapter, TuiML tools + a one-liner tuiml.agent.agent() agent.

Pydantic-AI is model-agnostic (works with Anthropic, OpenAI, Google, Groq, etc.), uses Pydantic models for schemas natively, and is our chosen substrate for the one-liner agent. This module exposes both the plain tools list and a pre-wired Agent instance.
python
>>> from tuiml.agent.adapters.pydantic_ai import get_tools, system_prompt
>>> from pydantic_ai import Agent
>>> agent = Agent("anthropic:claude-sonnet-4-6",
...               tools=get_tools(), system_prompt=system_prompt())
>>> agent.run_sync("Train a random forest on iris and report accuracy using TuiML")
python
>>> import tuiml
>>> tuiml.agent.agent().run_sync("Predict churn on customers.csv")

Functions

Func

get_tools

Line 29
get_tools() -> List[Any]

Return every TuiML workflow tool as a pydantic_ai.Tool.

Returns

list of pydantic_ai.Tool
One Tool per workflow tool, each routing to the TuiML executor. Pass directly as Agent(tools=get_tools(), ...).

Raises

ImportError
If pydantic_ai is not installed.
python
>>> from tuiml.agent.adapters.pydantic_ai import get_tools, system_prompt
>>> from pydantic_ai import Agent
>>> agent = Agent("anthropic:claude-sonnet-4-6",
...               tools=get_tools(), system_prompt=system_prompt())
Func

system_prompt

Line 94
system_prompt() -> str

Return the canonical TuiML system prompt (SKILL.md).

Returns

str
The contents of the canonical SKILL.md system prompt.
Func

agent

Line 105
agent(model: Optional[str]=None, **kwargs) -> Any

Return a ready-to-run pydantic_ai.Agent pre-loaded with every TuiML tool and the canonical system prompt.

Parameters

model
str
A Pydantic-AI model string, e.g. "anthropic:claude-sonnet-4-6" or "openai:gpt-4o". Defaults to "anthropic:claude-sonnet-4-6"; the Pydantic-AI environment must be configured with the matching provider API key (ANTHROPIC_API_KEY, OPENAI_API_KEY, …).
**kwargs
Passed through to pydantic_ai.Agent.

Returns

pydantic_ai.Agent
Agent configured with all TuiML workflow tools and the canonical system prompt.
python
>>> import tuiml
>>> result = tuiml.agent.agent().run_sync("Compare RandomForestClassifier and XGBoost on iris.")
>>> print(result.output)