aw.preparing

Preparation agent for transforming data to meet target requirements.

Implements ReAct pattern with functional validation (try-the-purpose approach).

Functions

create_preparation_agent([target, ...])

Factory function to create a preparation agent.

Classes

PreparationAgent([config, target, ...])

Agent that prepares data to meet target requirements.

class aw.preparing.PreparationAgent(config=None, target='generic', target_validator=None)[source]

Bases: object

Agent that prepares data to meet target requirements.

Uses ReAct loop with functional validation:

  1. Thought: Analyze current data state vs. requirements

  2. Action: Generate transformation code

  3. Observe: Execute code and capture result

  4. Validate: Try to use data for its purpose (e.g., visualization)

  5. Repeat or finish

Example

>>> agent = PreparationAgent(target='cosmo-ready')
>>> context = Context({'loading': {'df': df}})
>>> prepared_df, metadata = agent.execute(df, context)
execute(input_df, context)[source]

Execute preparation agent to transform data.

Parameters:
  • input_df (Any) – Input DataFrame to prepare

  • context (MutableMapping[str, Any]) – Context for storing intermediate results

Return type:

tuple[Any, dict[str, Any]]

Returns:

Tuple of (prepared_dataframe, metadata)

aw.preparing.create_preparation_agent(target='generic', validator=None, llm=None, max_retries=3)[source]

Factory function to create a preparation agent.

Parameters:
  • target (str) – Target format/purpose

  • validator (Callable) – Custom validator function

  • llm (str) – LLM model name or callable

  • max_retries (int) – Maximum retry attempts

Return type:

PreparationAgent

Returns:

Configured PreparationAgent

Example

>>> agent = create_preparation_agent(
...     target='cosmo-ready',
...     validator=cosmo_validator,
...     max_retries=5
... )