Skip to main content

parse_utils

AI Agent Parse Utilities for Consolidated Parameter Resolution. Provides O(1) utility functions for parameter parsing:
  • URL detection and parsing
  • Path detection
  • Typo suggestion (only on error path)
  • Error message generation
Performance: All happy-path operations are O(1). Typo suggestion uses Levenshtein distance only when raising errors.

Import

from praisonaiagents.config import parse_utils

Functions

detect_url_scheme()

Detect URL scheme from a string. O(1) operation.

parse_url_to_config()

Parse a URL string into a config object.

is_path_like()

Check if a string looks like a file path. O(1) operation.

is_numeric_string()

Check if a string is numeric. O(1) operation.

suggest_similar()

Find the most similar string from candidates using Levenshtein distance.

make_preset_error()

Create a helpful error message for invalid preset.

make_array_error()

Create a helpful error message for invalid array format.

is_policy_string()

Check if a string is a policy specification. O(1) operation.

parse_policy_string()

Parse a policy string into type and action. O(1) operation.

merge_config_with_overrides()

Merge a base config with override dict.