Skip to content

API Reference parrot_loaders.extractors.base

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

parrot_loaders.extractors.base

View source

Abstract base class and data models for structured data extraction.

ExtractDataSource provides a generic contract for extracting structured records (list[dict]) from various data sources (CSV, JSON, SQL, APIs, in-memory). Unlike AI-Parrot's Loaders (which produce text chunks for RAG), extractors produce structured records for ontology graph ingestion, data pipelines, and ETL.

Class ExtractDataSource

Abstract base class for structured data extraction.

Subclasses implement extract() and list_fields() for a specific data source type (CSV, JSON, SQL, API, etc.). All implementations must be async-first.

Parameter Type Default Description
name str Human-readable name for logging and reporting.
config dict[str, Any] | None None Source-specific configuration (paths, credentials, etc.).

Method ExtractDataSource.extract

Extract structured records from the data source.

extract(fields: list[str] | None = None, filters: dict[str, Any] | None = None) -> ExtractionResult

Parameter Type Default Description
fields list[str] | None None Optional list of fields to extract (None = all fields). Allows the caller to request only the fields defined in the ontology entity, reducing memory and processing.
filters dict[str, Any] | None None Optional key-value filters to pre-filter records at source. For CSV/JSON this filters in-memory after loading. For API/SQL sources this translates to query parameters.

Returns: ExtractionResult — ExtractionResult with the list of ExtractedRecord instances.

Method ExtractDataSource.list_fields

Return the available field names from this data source.

Used during ontology validation to check that entity properties and discovery rules reference fields that actually exist in the source.

list_fields() -> list[str]

Returns: list[str] — List of field/column names available in the source.

Method ExtractDataSource.validate

Validate that the source is accessible and has the expected schema.

validate(expected_fields: list[str] | None = None) -> bool

Parameter Type Default Description
expected_fields list[str] | None None If provided, checks that all these fields exist in the source. Used during ontology build to catch YAML-to-source mismatches early.

Returns: bool — True if validation passes.

Raises:

  • DataSourceValidationError — With details on what's wrong.

Class ExtractedRecord

A single extracted record with its raw data and metadata.

Fields:

Field Type Default Description
data dict[str, Any]
metadata dict[str, Any]

Class ExtractionResult

Result of an extraction operation.

Fields:

Field Type Default Description
records list[ExtractedRecord]
total int
errors list[str]
warnings list[str]
source_name str
extracted_at datetime

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