UNPKG

langextract

Version:

A TypeScript library for extracting structured and grounded information from text using LLMs

61 lines 2.48 kB
/** * Copyright 2025 kmbro. * * This is a TypeScript translation of the original Python LangExtract library * by Google LLC (https://github.com/google/langextract). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { Extraction, FormatType } from "./types"; import { Constraint } from "./schema"; export declare class ResolverParsingError extends Error { constructor(message: string); } export interface AbstractResolver { fenceOutput: boolean; formatType: FormatType; resolve(inputText: string, options?: ResolveOptions): Extraction[]; align(extractions: Extraction[], sourceText: string, tokenOffset: number, charOffset?: number, enableFuzzyAlignment?: boolean, fuzzyAlignmentThreshold?: number, acceptMatchLesser?: boolean): Extraction[]; } export interface ResolveOptions { suppressParseErrors?: boolean; [key: string]: any; } export declare class Resolver implements AbstractResolver { private _fenceOutput; private _constraint; private _formatType; private extractionIndexSuffix?; private extractionAttributesSuffix; constructor(options?: { fenceOutput?: boolean; extractionIndexSuffix?: string; extractionAttributesSuffix?: string; constraint?: Constraint; formatType?: FormatType; }); get fenceOutput(): boolean; set fenceOutput(value: boolean); get formatType(): FormatType; set formatType(value: FormatType); resolve(inputText: string, options?: ResolveOptions): Extraction[]; align(extractions: Extraction[], sourceText: string, tokenOffset: number, charOffset?: number, enableFuzzyAlignment?: boolean, fuzzyAlignmentThreshold?: number): Extraction[]; private extractAndParseContent; private stringToExtractionData; private extractOrderedExtractions; private alignSingleExtraction; private findExactMatch; private findFuzzyMatch; private tokenToCharInterval; } //# sourceMappingURL=resolver.d.ts.map