yaml

YAML loading helpers shared across Pipecat’s YAML-based configuration.

The main helper is include_loader(), which builds a loader class that understands an !include <relative-path> tag so a document can pull in sibling files:

judge: !include judge_audio.yaml
task_messages: !include prompts/greeting.yaml
pipecat.utils.yaml.add_include_constructor(loader_class: type[SafeLoader], base_dir: Path) → None[source]

Register an !include <relative-path> constructor on loader_class.

Included files load with the same loader class, so nested includes work and scalars get the same resolver treatment as the top-level document. Paths resolve against base_dir.

This mutates loader_class. Register on a private subclass rather than on yaml.SafeLoader itself so the constructor has no global side effects; include_loader() does that for you.

Parameters:
  • loader_class – The loader class to register the constructor on.

  • base_dir – Directory that !include paths resolve against.

pipecat.utils.yaml.include_loader(base_dir: Path, base: type[SafeLoader] = <class 'yaml.loader.SafeLoader'>) → type[SafeLoader][source]

Build a loader class that resolves !include relative to base_dir.

Returns a fresh subclass of base with the include constructor registered, so base itself is left untouched.

Parameters:
  • base_dir – Directory that !include paths resolve against, typically the directory of the document being loaded.

  • base – Loader class to subclass. Defaults to yaml.SafeLoader; pass a custom SafeLoader subclass to keep its resolvers and constructors.

Returns:

A loader class to pass as the Loader argument of yaml.load.

Example:

with path.open() as f:
    data = yaml.load(f, include_loader(path.parent))