Extensions and helper methods for ChatAIze projects.
$ dotnet add package ChatAIze.UtilitiesShared helpers and extensions used across the ChatAIze stack. This package is intentionally small and focused: it provides string normalization, placeholder substitution, delegate invocation helpers for tool calls, and lightweight date parsing.
It is referenced by:
ChatAIze.Chatbot (host runtime and dashboard)ChatAIze.GenerativeCS (tool schema and provider integration)ChatAIze.PluginApi (plugin authoring helpers)law-firm-plugindotnet add package ChatAIze.Utilities
Target framework: net10.0. The package depends on ChatAIze.Abstractions for tool and workflow context types.
Namespaces:
ChatAIze.Utilities for standalone helpers (for example DateTimeOffsetParser).ChatAIze.Utilities.Extensions for extension methods used across the host and plugins.Key modules:
StringExtension: normalization, identifier casing, placeholder substitution.CharExtension: simple Latin transliteration for diacritics.DictionaryExtensions: tolerant JSON reads and placeholder expansion for dictionaries.DelegateExtensions: tool/action/condition invocation helpers with validation.DateTimeOffsetExtension: "natural" UI-friendly date formatting.DateTimeOffsetParser: small natural-language date/time parser.Concrete examples from the current codebase:
ToSnakeLower is used to normalize database titles and properties in ChatAIze.Chatbot and to generate tool schemas in
ChatAIze.GenerativeCS.NormalizedEquals is used to match tool calls coming back from providers (OpenAI/Gemini) to registered functions.WithPlaceholderValues is used to expand action settings and confirmation text in the workflow engine.TryGetSettingValue is used in the action/condition UI builders to read settings with safe defaults.ToNaturalString is used in dashboard UI timestamps (chat cards, account metadata, backups).DateTimeOffsetParser is used in law-firm-plugin and in condition evaluation to parse date/time expressions.DelegateExtensions is the standard path for invoking tool functions, workflow actions, and conditions.using ChatAIze.Utilities.Extensions;
var normalized = "My Project Name".ToSnakeLower(); // "my_project_name"
var equal = "Sao Paulo".NormalizedEquals("Sao-Paulo"); // true
var template = "Hello {user.name}, your order is {order_id}.";
var placeholders = new Dictionary<string, string>
{
["UserName"] = "Marcel",
["order_id"] = "A-123"
};
var message = template.WithPlaceholderValues(placeholders);StringExtension and CharExtension provide the normalization rules used throughout ChatAIze.
Highlights:
NormalizedEquals compares strings by transliterating diacritics, ignoring punctuation/whitespace, and matching
ASCII letters/digits case-insensitively.ToSeparated, ToSnakeLower, ToKebabLower normalize identifiers for use in tool schemas and settings keys.ToAlphanumeric strips non-ASCII characters and optionally preserves - or _ (whitespace normalizes to the chosen separator).ToLatin maps a curated set of diacritics to ASCII-friendly characters.Warnings:
NormalizedEquals for security-sensitive comparisons (passwords, tokens).ToSeparated drops non-ASCII characters and splits on lower-to-upper transitions (for example "ChatBot" -> "chat_bot").WithPlaceholderValues exists for string templates and for dictionaries that contain JSON values.
String templates:
{key}, {key.sub_property}, and {key:sub_property}.Dictionary placeholders:
IReadOnlyDictionary<string, JsonElement>, string values are replaced directly.Warnings:
DictionaryExtensions is designed for settings dictionaries used by actions and conditions.
Key helpers:
TryGetSettingValue<T>: tolerant JSON read that returns a default value on deserialization errors.WithPlaceholderValues overloads: apply placeholder substitution to strings and JSON data.Tip: TryGetSettingValue is used heavily in ChatAIze.Chatbot action/condition builders to keep UI logic resilient to
missing or invalid settings values.
DelegateExtensions provides the standard binding and validation rules for ChatAIze tools and workflows.
Main features:
GetNormalizedMethodName extracts stable names for delegates. Prefer named methods; lambdas can throw if the compiler
name is not recognized.InvokeForStringResultAsync binds JSON arguments to function delegates, injects IFunctionContext/CancellationToken,
and serializes non-string results to snake_case JSON.IActionContext.SetActionResult.Validation rules:
Required, MinLength, MaxLength, StringLength attributes are enforced on string parameters.Warnings:
"Error: ..." strings for validation failures (not exceptions).DateTimeOffsetExtension.ToNaturalStringFormats timestamps for UI display:
Today, 13:37, Yesterday, Mon, 15:00, or 2025-01-31.DateTimeOffsetParser.ParseA lightweight parser for human-friendly date/time expressions.
Supported examples:
now, today, tomorrow, next monday at 14:302025-01-31, 31.01.2025, 12/31/2025utc+2, gmt-5, cestLimitations and gotchas:
DateTimeOffset.UtcNow and uses fixed offsets for time zones (no DST).01/02/2025 are interpreted as month/day/year.at keyword is detected by substring and can match inside other words.ToLatin() normalization.ChatAIze.Utilities.Preview is a tiny console app used to demo placeholder replacement with JsonElement values.
It is not published as a package.
ChatAIze.Abstractions: base interfaces referenced by DelegateExtensions.ChatAIze.PluginApi: concrete helper implementations for plugin authors.ChatAIze.GenerativeCS: tool schema generation, uses ToSnakeLower and NormalizedEquals.GPL-3.0-or-later. See LICENSE for details.