Ensure Dir • AI Agent SDK

ensure_dir: Ensure a directory exists, creating it if necessary.

ensure_dir

Function

</div>

This function is defined in the paths module.

Ensure a directory exists, creating it if necessary.

Signature

python
def ensure_dir(path: Union[str, Path]) -> Path

Parameters

ParamField Union[str, Path]

Directory path to ensure exists

Returns

ResponseField Path

Path object for the directory

Usage

python
>>> from praisonaiagents.paths import ensure_dir, get_sessions_dir
    >>> sessions = ensure_dir(get_sessions_dir())

Uses

  • Path
  • path.mkdir

Source

View on GitHub

praisonaiagents/paths.py at line 535