llm-json-fix
Version:
Fix malformed JSON outputs from Large Language Models (LLMs)
45 lines • 1.37 kB
TypeScript
/**
* Options for repairing LLM JSON
*/
export interface FixLLMJsonOptions {
/**
* Whether to apply model-specific fixes (default: true)
*/
applyModelSpecificFixes?: boolean;
/**
* The specific LLM model being used, for optimized repairs
* Supported values: 'openai', 'anthropic', 'general'
*/
model?: 'openai' | 'anthropic' | 'general';
/**
* Whether to preserve comments in the JSON (default: false)
*/
preserveComments?: boolean;
/**
* Whether to be verbose about changes being made
*/
verbose?: boolean;
}
/**
* Fix malformed JSON from LLM outputs
*
* @param text Potentially broken JSON text
* @param options Configuration options
* @returns Repaired JSON string
* @throws {UnrepairableJSONError} If the JSON cannot be repaired
*/
export declare function fixLLMJson(text: string, options?: FixLLMJsonOptions): string;
/**
* Repair invalid JSON documents
* Core implementation based on jsonrepair library with enhancements
*
* @param text The JSON document containing errors
* @param options Repair options
* @returns Repaired JSON as string
* @throws {UnrepairableJSONError} If the JSON cannot be repaired
*/
export declare function jsonrepair(text: string, options?: {
preserveComments?: boolean;
verbose?: boolean;
}): string;
//# sourceMappingURL=jsonFix.d.ts.map