haive.core.engine.document.agentsΒΆ

Document Engine Agent Implementation.

This module provides agent implementations that integrate with the DocumentEngine and the Haive agent framework for loading documents from various sources.

The agents handle document loading from various sources, including: - Local files and directories - Web pages and URLs - Cloud storage - Text input

The agents can be integrated into complex workflows and support both synchronous and asynchronous operation modes.

ClassesΒΆ

DirectoryDocumentAgent

Specialized document agent for loading documents from directories.

DocumentAgent

Document Agent that integrates the document engine with the agent framework.

FileDocumentAgent

Specialized document agent for loading documents from files.

WebDocumentAgent

Specialized document agent for loading documents from web URLs.

Module ContentsΒΆ

class haive.core.engine.document.agents.DirectoryDocumentAgent(/, **data)ΒΆ

Bases: DocumentAgent

Specialized document agent for loading documents from directories.

This agent is pre-configured for loading from local directories and provides additional directory-specific options.

Parameters:

data (Any)

nameΒΆ

Name of the agent

directory_pathΒΆ

Path to the directory to load

recursiveΒΆ

Whether to recursively load files

include_patternsΒΆ

List of file patterns to include

exclude_patternsΒΆ

List of file patterns to exclude

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

setup_agent()ΒΆ

Set up the agent with a directory document engine.

Return type:

None

class haive.core.engine.document.agents.DocumentAgent(/, **data)ΒΆ

Bases: haive.agents.base.agent.Agent

Document Agent that integrates the document engine with the agent framework.

This agent provides a simple interface for loading and processing documents from various sources through the agent framework. It can be used as a standalone agent or as part of a more complex agent workflow.

The agent supports loading from: - Local files and directories - Web pages and URLs - Text input - Cloud storage (with proper credentials)

Parameters:

data (Any)

nameΒΆ

Name of the agent

engineΒΆ

The document engine to use

include_contentΒΆ

Whether to include document content in the output

include_metadataΒΆ

Whether to include document metadata in the output

max_documentsΒΆ

Maximum number of documents to load (None for unlimited)

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

build_graph()ΒΆ

Build the document agent graph.

Creates a simple linear graph that loads and processes documents from the input source.

Returns:

A BaseGraph instance for document processing

Return type:

haive.core.graph.state_graph.base_graph2.BaseGraph

process_output(output)ΒΆ

Process the output from the document engine.

This method filters and formats the output based on the agent’s configuration.

Parameters:

output (haive.core.engine.document.config.DocumentOutput) – The raw output from the document engine

Returns:

A dictionary with processed document data

Return type:

dict[str, Any]

setup_agent()ΒΆ

Set up the agent by configuring the document engine.

This method is called during agent initialization to set up the engine with the agent’s configuration parameters.

Return type:

None

class haive.core.engine.document.agents.FileDocumentAgent(/, **data)ΒΆ

Bases: DocumentAgent

Specialized document agent for loading documents from files.

This agent is pre-configured for loading from local files and provides additional file-specific options.

Parameters:

data (Any)

nameΒΆ

Name of the agent

file_pathΒΆ

Path to the file to load

chunking_strategyΒΆ

Strategy for chunking documents

chunk_sizeΒΆ

Size of chunks in characters

chunk_overlapΒΆ

Overlap between chunks

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

setup_agent()ΒΆ

Set up the agent with a file document engine.

Return type:

None

class haive.core.engine.document.agents.WebDocumentAgent(/, **data)ΒΆ

Bases: DocumentAgent

Specialized document agent for loading documents from web URLs.

This agent is pre-configured for loading from web sources and provides additional web-specific options.

Parameters:

data (Any)

nameΒΆ

Name of the agent

urlΒΆ

URL to load

chunking_strategyΒΆ

Strategy for chunking documents

chunk_sizeΒΆ

Size of chunks in characters

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

setup_agent()ΒΆ

Set up the agent with a web document engine.

Return type:

None