Skip to main content
SimpleComponent: a lightweight named-span component. SimpleComponent accepts arbitrary keyword arguments (strings, CBlocks, or Components) and renders them as a JSON object keyed by the argument names. It is the go-to component type for ad-hoc prompts that do not require a dedicated Component subclass or a Jinja2 template.

Classes

CLASS SimpleComponent

A Component that is make up of named spans.
Methods:

FUNC parts

Returns the values of the kwargs. Returns:
  • List of component values passed as keyword arguments.

FUNC make_simple_string

Render keyword arguments as <|key|>value</|key|> tagged strings. Args: Returns:
  • Newline-joined tagged representation of all keyword arguments.

FUNC make_json_string

Serialize keyword arguments to a JSON string. Each value is converted to its string representation: CBlock and ModelOutputThunk values use their .value attribute, while Component values use format_for_llm(). Args: Returns:
  • JSON-encoded representation of the keyword arguments.

FUNC format_for_llm

Format this component as a JSON string representation for the language model. Delegates to make_json_string using the stored keyword arguments. Returns:
  • JSON-encoded string of all named spans in this component.