UNPKG

llm-json-fix

Version:

Fix malformed JSON outputs from Large Language Models (LLMs)

54 lines (53 loc) 1.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BufferLimitExceededError = exports.AmbiguousRepairError = exports.UnrepairableJSONError = exports.LLMJSONFixError = void 0; /** * Custom error thrown by the LLM JSON Fix library */ class LLMJSONFixError extends Error { /** * Create a new LLMJSONFixError * @param message The error message * @param position The position in the text where the error occurred (if available) */ constructor(message, position) { super(message); this.position = position; this.name = 'LLMJSONFixError'; // Maintain proper stack trace in V8 engines if (Error.captureStackTrace) { Error.captureStackTrace(this, LLMJSONFixError); } } } exports.LLMJSONFixError = LLMJSONFixError; /** * Error thrown when a repair operation could not be completed */ class UnrepairableJSONError extends LLMJSONFixError { constructor(message, position) { super(message, position); this.name = 'UnrepairableJSONError'; } } exports.UnrepairableJSONError = UnrepairableJSONError; /** * Error thrown when the input JSON is too complex or ambiguous to be repaired */ class AmbiguousRepairError extends LLMJSONFixError { constructor(message, position) { super(message, position); this.name = 'AmbiguousRepairError'; } } exports.AmbiguousRepairError = AmbiguousRepairError; /** * Error thrown when repair operation exceeds buffer limits */ class BufferLimitExceededError extends LLMJSONFixError { constructor(message, position) { super(message, position); this.name = 'BufferLimitExceededError'; } } exports.BufferLimitExceededError = BufferLimitExceededError;