Skip to main content

safe_format

Function
This function is defined in the agents_generator module.
Safe string formatting that preserves JSON/dict literals while substituting variables. This function only substitutes placeholders that look like identifiers (e.g., {topic}) while preserving JSON structures like {“level”: 2}. Delegates to the single source of truth, BaseFrameworkAdapter._format_template in the core SDK, so the wrapper and core cannot drift (non-string short-circuit, regex, missing-key handling). _format_template is stateless; a fresh instance is free.

Signature

Parameters

Any
required
Template string with placeholders **kwargs: Values to substitute

Returns

Any
Formatted string with safe substitutions

Uses

  • BaseFrameworkAdapter

Source

View on GitHub

praisonai/agents_generator.py at line 1639