Skip to content

API Reference parrot.outputs.formats.base

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.outputs.formats.base

View source

Class BaseRenderer

Base class for output renderers.

Method BaseRenderer.get_expected_content_type

Define what type of content this renderer expects. Override in subclasses to specify expected type.

get_expected_content_type() -> Type

Returns: Type — The expected type (str, pd.DataFrame, dict, etc.)

Method BaseRenderer.execute_code

Execute code within the PythonPandasTool or fallback namespace.

FEAT-380 (TASK-1944) note on the pandas_tool branch: this deliberately keeps reading the tool's locals attribute rather than switching to the async namespace API (snapshot()/get_var()). Those always read the tool's WORKER process's namespace (TASK-1943); the attribute read below reflects execute_sync() (a separate, pre-existing synchronous escape hatch that still runs _execute_code() in-process, untouched by TASK-1943) — the worker was never even started for this code path, so snapshot() would silently return an unrelated (fresh, empty) namespace instead of this method's own just-executed result. Porting this branch correctly would require also routing execute_sync() through the worker, which TASK-1943 explicitly keeps out of scope. See TASK-1944's Completion Note for the full reasoning; the AC13 grep guard test explicitly excludes this one documented case.

execute_code(code: str, pandas_tool: PythonPandasTool | None = None, execution_state: Optional[Dict[str, Any]] = None, extra_namespace: Optional[Dict[str, Any]] = None, **kwargs) -> Tuple[Optional[Dict[str, Any]], Optional[str]]

Parameter Type Default Description
code str
pandas_tool PythonPandasTool | None None
execution_state Optional[Dict[str, Any]] None
extra_namespace Optional[Dict[str, Any]] None
**kwargs {}

Returns: Tuple[Optional[Dict[str, Any]], Optional[str]]

Method BaseRenderer.render

Render response in the appropriate format.

render(response: Any, environment: str = 'terminal', export_format: str = 'html', include_code: bool = False, **kwargs) -> Tuple[Any, Optional[Any]]

Parameter Type Default Description
response Any
environment str 'terminal'
export_format str 'html'
include_code bool False
**kwargs {}

Returns: Tuple[Any, Optional[Any]] — Tuple[Any, Optional[Any]]: (content, wrapped) - content: Primary formatted output - wrapped: Optional wrapped version (e.g., HTML, standalone file)

Alias PythonPandasTool

Re-exported from parrot.tools.pythonpandas.PythonPandasTool.

Class RenderError

Structured error information from rendering.

Parameter Type Default Description
message str
error_type str
raw_output Optional[str] None
details Optional[Dict[str, Any]] dict()

Fields:

Field Type Default Description
message str Human-readable error message
error_type str Type of error (e.g., 'json_parse', 'validation', 'execution')
raw_output Optional[str] None The original output that failed to render
details Optional[Dict[str, Any]] field(default_factory=dict) Additional error details (stack trace, position, etc.)

Class RenderResult

Structured result from rendering operation.

This provides more detailed information about the rendering outcome, including whether it succeeded and any error information.

Parameter Type Default Description
success bool
content Any
wrapped_content Optional[Any] None
error Optional[RenderError] None

Fields:

Field Type Default Description
success bool Whether rendering succeeded
content Any The rendered content (may be partial on error)
wrapped_content Optional[Any] None Optional wrapped version (e.g., HTML)
error Optional[RenderError] None Error information if rendering failed

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally