Skip to content

Pool

infra.llm.providers.llama_parser.pool

Summary

LlamaCloud statement parser adaptor.


Upload a statement PDF to LlamaCloud for extraction, or replay a cached CSV, returning normalized transaction dictionaries.

Classes

AsyncLlamaParserPool

AsyncLlamaParserPool(**kwargs)

Bases: LlamaParserAdaptor

LLM parser pool configured from the environment.

Initialize the pool with configuration defaults.

Parameters:

Name Type Description Default
**kwargs

Overrides passed to the parser adaptor.

{}
Attributes
client property
client: AsyncLlamaCloud

Return the lazily initialized LlamaCloud client.

Returns:

Name Type Description
AsyncLlamaCloud AsyncLlamaCloud

Authenticated LlamaCloud client.

Raises:

Type Description
ValueError

When no API key is configured.

Functions
aclose async
aclose()

Close the LlamaCloud client if it was created.

generate_statement async
1
2
3
4
generate_statement(
    filepath: Union[str, os.PathLike],
    cached: Optional[Union[str, os.PathLike]] = None,
) -> List[dict]

Extract transactions from a statement PDF.

When cached points to a CSV previously exported by scripts/llama_txns_extractor.py, read it and validate each row into RawExpense models instead of calling LlamaCloud.

Parameters:

Name Type Description Default
filepath Union[str, PathLike]

Path to the statement PDF.

required
cached Optional[Union[str, PathLike]]

Path to a cached CSV export.

None

Returns:

Type Description
List[dict]

List[dict]: Extracted transaction dictionaries.

LlamaParserAdaptor

LlamaParserAdaptor(**kwargs)

Extract transactions through the LlamaCloud API.

Attributes:

Name Type Description
api_key str

LlamaCloud API key.

extract_config dict

Extraction configuration payload.

_client Optional[AsyncLlamaCloud]

Lazily created API client.

Initialize the parser adaptor.

Parameters:

Name Type Description Default
**kwargs

Configuration; api_key and extract_config are consumed, remaining keys become instance attributes.

{}
Attributes
client property
client: AsyncLlamaCloud

Return the lazily initialized LlamaCloud client.

Returns:

Name Type Description
AsyncLlamaCloud AsyncLlamaCloud

Authenticated LlamaCloud client.

Raises:

Type Description
ValueError

When no API key is configured.

Functions
aclose async
aclose()

Close the LlamaCloud client if it was created.

generate_statement async
1
2
3
4
generate_statement(
    filepath: Union[str, os.PathLike],
    cached: Optional[Union[str, os.PathLike]] = None,
) -> List[dict]

Extract transactions from a statement PDF.

When cached points to a CSV previously exported by scripts/llama_txns_extractor.py, read it and validate each row into RawExpense models instead of calling LlamaCloud.

Parameters:

Name Type Description Default
filepath Union[str, PathLike]

Path to the statement PDF.

required
cached Optional[Union[str, PathLike]]

Path to a cached CSV export.

None

Returns:

Type Description
List[dict]

List[dict]: Extracted transaction dictionaries.