aw.loading

Loading agent for converting data sources to pandas DataFrames.

Implements the ReAct pattern to iteratively try different loading strategies until successful or max retries reached.

Functions

create_loading_agent([llm, validator, ...])

Factory function to create a loading agent.

Classes

LoadingAgent([config])

Agent that loads data from various sources into pandas DataFrames.

class aw.loading.LoadingAgent(config=None)[source]

Bases: object

Agent that loads data from various sources into pandas DataFrames.

Uses ReAct loop:

  1. Thought: Analyze source (extension, sample) to choose loader

  2. Action: Generate code to load data

  3. Observe: Execute code and capture result/error

  4. Validate: Check if result is valid DataFrame

  5. Repeat or finish

Example

>>> agent = LoadingAgent()
>>> context = Context()
>>> df, metadata = agent.execute('/path/to/data.csv', context)
execute(source_uri, context)[source]

Execute loading agent to load data from source.

Parameters:
  • source_uri (str) – URI of data source (file path or URL)

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

Return type:

tuple[Any, dict[str, Any]]

Returns:

Tuple of (dataframe, metadata)

aw.loading.create_loading_agent(llm=None, validator=None, max_retries=3)[source]

Factory function to create a loading agent.

Parameters:
  • llm (str) – LLM model name or callable

  • validator (Any) – Custom validator (uses default if None)

  • max_retries (int) – Maximum retry attempts

Return type:

LoadingAgent

Returns:

Configured LoadingAgent

Example

>>> agent = create_loading_agent(llm="gpt-4", max_retries=5)