haive.core.utils.file_utils

📄 File Reader Utilities

This module provides utility functions for reading .md, .yaml, or .yml files into memory. It supports content integration for system messages and configuration loading.

Features: - Read Markdown files as plain strings - Read YAML files into Python dictionaries - Auto-detect file type based on extension - Read multiple files at once and return a dictionary - Designed for use in LLM prompt templates and configuration systems

Author: Your Name

Functions

read_file_content(file_path)

Reads a Markdown or YAML file and returns its content.

read_multiple_files(file_paths)

Reads multiple Markdown or YAML files and returns a dictionary of filename to content.

read_yaml_file(file_path)

Reads a YAML (.yml or .yaml) file and returns the parsed Python object.

Module Contents

haive.core.utils.file_utils.read_file_content(file_path)[source]

Reads a Markdown or YAML file and returns its content.

Automatically detects the file type based on extension.

Parameters:

file_path (Union[str, Path]) – Path to the file to read (.md, .yml, or .yaml).

Returns:

String content for .md files, parsed Python object for .yaml files,

or None if the file cannot be read.

Return type:

Any

haive.core.utils.file_utils.read_multiple_files(file_paths)[source]

Reads multiple Markdown or YAML files and returns a dictionary of filename to content.

Parameters:

file_paths (list[Union[str, Path]]) – List of paths to files to read.

Returns:

Dictionary mapping file stem (name without extension) to content.

Return type:

dict[str, Any]

haive.core.utils.file_utils.read_yaml_file(file_path)[source]

Reads a YAML (.yml or .yaml) file and returns the parsed Python object.

Parameters:

file_path (Union[str, Path]) – Path to the YAML file.

Returns:

Parsed content of the YAML file as a dict, list, or scalar.

Return type:

Any