cognis-core 0.2.0

Core traits and types for the Cognis LLM framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! String formatting utilities.

use crate::error::Result;
use serde_json::Value;
use std::collections::HashMap;

/// A strict formatter that only accepts keyword arguments (no positional).
/// Mirrors Python `langchain_core.utils.formatting.StrictFormatter`.
pub fn strict_format(template: &str, kwargs: &HashMap<String, Value>) -> Result<String> {
    crate::prompts::string_formatter::format_template(
        template,
        crate::prompts::string_formatter::TemplateFormat::FString,
        kwargs,
    )
}