selvedge
Version:
A type-safe, declarative DSL for building robust, composable LLM prompts and programs in TypeScript. Selvedge simplifies prompt engineering, structured output, and multi-model orchestration.
47 lines • 1.63 kB
TypeScript
/**
* Object formatting utilities for Selvedge
*
* This module provides utilities for formatting objects into readable strings
* for use in prompt templates and other text-based contexts.
*/
/**
* Options for formatting objects
*/
export interface FormatterOptions {
/** Maximum depth for nested objects */
maxDepth?: number;
/** Maximum number of items to show in arrays */
maxArrayItems?: number;
/** Maximum length of strings */
maxStringLength?: number;
/** Indentation for nested objects */
indent?: string;
/** Current depth level (used internally) */
currentDepth?: number;
}
/**
* Format any value into a readable string representation
*
* This function intelligently formats different data types:
* - Objects are formatted as key-value pairs
* - Arrays are formatted as lists
* - Primitives are formatted directly
* - Null/undefined values are handled gracefully
*
* @param value - The value to format
* @param options - Formatting options
* @returns A readable string representation of the value
*/
export declare function formatValue(value: any, options?: FormatterOptions): string;
/**
* Format an object for display in a prompt
*
* This is the main entry point for formatting objects in prompt templates.
* It formats the object in a way that's readable in a prompt context.
*
* @param value - The value to format
* @param options - Formatting options
* @returns A formatted string suitable for inclusion in a prompt
*/
export declare function formatForPrompt(value: any, options?: FormatterOptions): string;
//# sourceMappingURL=formatter.d.ts.map