@langchain/community
Version:
Third-party integrations for LangChain.js
1 lines • 7.09 kB
Source Map (JSON)
{"version":3,"file":"unstructured.d.ts","names":["basename","BasenameT","readFile","ReadFileT","Document","StringWithAutocomplete","DirectoryLoader","UnknownHandling","BaseDocumentLoader","UNSTRUCTURED_API_FILETYPES","Element","UnstructuredLoaderStrategy","HiResModelName","SkipInferTableTypes","ChunkingStrategy","UnstructuredLoaderOptions","Array","UnstructuredDirectoryLoaderOptions","UnstructuredMemoryLoaderOptions","Buffer","UnstructuredLoader","Promise","UnstructuredDirectoryLoader"],"sources":["../../../src/document_loaders/fs/unstructured.d.ts"],"sourcesContent":["import type { basename as BasenameT } from \"node:path\";\nimport type { readFile as ReadFileT } from \"node:fs/promises\";\nimport { Document } from \"@langchain/core/documents\";\nimport { StringWithAutocomplete } from \"@langchain/core/utils/types\";\nimport { DirectoryLoader, UnknownHandling } from \"@langchain/classic/document_loaders/fs/directory\";\nimport { BaseDocumentLoader } from \"@langchain/core/document_loaders/base\";\nexport declare const UNSTRUCTURED_API_FILETYPES: string[];\n/**\n * Represents an element returned by the Unstructured API. It has\n * properties for the element type, text content, and metadata.\n */\ntype Element = {\n type: string;\n text: string;\n metadata: {\n [key: string]: unknown;\n };\n};\n/**\n * Represents the available strategies for the UnstructuredLoader. It can\n * be one of \"hi_res\", \"fast\", \"ocr_only\", or \"auto\".\n */\nexport type UnstructuredLoaderStrategy = \"hi_res\" | \"fast\" | \"ocr_only\" | \"auto\";\n/**\n * Represents the available hi-res models for the UnstructuredLoader. It can\n * be one of \"chipper\".\n */\nexport type HiResModelName = \"chipper\";\n/**\n * To enable or disable table extraction for file types other than PDF, set\n * the skipInferTableTypes property in the UnstructuredLoaderOptions object.\n * The skipInferTableTypes property is an array of file types for which table\n * extraction is disabled. For example, to disable table extraction for .docx\n * and .doc files, set the skipInferTableTypes property to [\"docx\", \"doc\"].\n * You can also disable table extraction for all file types other than PDF by\n * setting the skipInferTableTypes property to [].\n */\nexport type SkipInferTableTypes = \"txt\" | \"text\" | \"pdf\" | \"docx\" | \"doc\" | \"jpg\" | \"jpeg\" | \"eml\" | \"html\" | \"htm\" | \"md\" | \"pptx\" | \"ppt\" | \"msg\" | \"rtf\" | \"xlsx\" | \"xls\" | \"odt\" | \"epub\";\n/**\n * Set the chunking_strategy to chunk text into larger or smaller elements. Defaults to None with optional arg of by_title\n */\nexport type ChunkingStrategy = \"None\" | \"by_title\";\nexport type UnstructuredLoaderOptions = {\n apiKey?: string;\n apiUrl?: string;\n strategy?: StringWithAutocomplete<UnstructuredLoaderStrategy>;\n encoding?: string;\n ocrLanguages?: Array<string>;\n coordinates?: boolean;\n pdfInferTableStructure?: boolean;\n xmlKeepTags?: boolean;\n skipInferTableTypes?: Array<StringWithAutocomplete<SkipInferTableTypes>>;\n hiResModelName?: StringWithAutocomplete<HiResModelName>;\n includePageBreaks?: boolean;\n chunkingStrategy?: StringWithAutocomplete<ChunkingStrategy>;\n multiPageSections?: boolean;\n combineUnderNChars?: number;\n newAfterNChars?: number;\n maxCharacters?: number;\n extractImageBlockTypes?: string[];\n overlap?: number;\n overlapAll?: boolean;\n};\nexport type UnstructuredDirectoryLoaderOptions = UnstructuredLoaderOptions & {\n recursive?: boolean;\n unknown?: UnknownHandling;\n};\nexport type UnstructuredMemoryLoaderOptions = {\n buffer: Buffer;\n fileName: string;\n};\n/**\n * A document loader that uses the Unstructured API to load unstructured\n * documents. It supports both the new syntax with options object and the\n * legacy syntax for backward compatibility. The load() method sends a\n * partitioning request to the Unstructured API and retrieves the\n * partitioned elements. It creates a Document instance for each element\n * and returns an array of Document instances.\n *\n * It accepts either a filepath or an object containing a buffer and a filename\n * as input.\n */\nexport declare class UnstructuredLoader extends BaseDocumentLoader {\n filePath: string;\n private buffer?;\n private fileName?;\n private apiUrl;\n private apiKey?;\n private strategy;\n private encoding?;\n private ocrLanguages;\n private coordinates?;\n private pdfInferTableStructure?;\n private xmlKeepTags?;\n private skipInferTableTypes?;\n private hiResModelName?;\n private includePageBreaks?;\n private chunkingStrategy?;\n private multiPageSections?;\n private combineUnderNChars?;\n private newAfterNChars?;\n private maxCharacters?;\n private extractImageBlockTypes?;\n private overlap?;\n private overlapAll?;\n constructor(filepathOrBufferOptions: string | UnstructuredMemoryLoaderOptions, unstructuredOptions?: UnstructuredLoaderOptions | string);\n _partition(): Promise<Element[]>;\n load(): Promise<Document[]>;\n imports(): Promise<{\n readFile: typeof ReadFileT;\n basename: typeof BasenameT;\n }>;\n}\n/**\n * A document loader that loads unstructured documents from a directory\n * using the UnstructuredLoader. It creates a UnstructuredLoader instance\n * for each supported file type and passes it to the DirectoryLoader\n * constructor.\n * @example\n * ```typescript\n * const loader = new UnstructuredDirectoryLoader(\"path/to/directory\", {\n * apiKey: \"MY_API_KEY\",\n * });\n * const docs = await loader.load();\n * ```\n */\nexport declare class UnstructuredDirectoryLoader extends DirectoryLoader {\n constructor(directoryPathOrLegacyApiUrl: string, optionsOrLegacyDirectoryPath: UnstructuredDirectoryLoaderOptions | string, legacyOptionRecursive?: boolean, legacyOptionUnknown?: UnknownHandling);\n}\nexport { UnknownHandling };\n//# sourceMappingURL=unstructured.d.ts.map"],"mappings":";;;;;;;;cAMqBS;;AAArB;AAA0D;AAgB1D;AAKA,KAhBKC,OAAAA,GAgBOE;EAUAC,IAAAA,EAAAA,MAAAA;EAIAC,IAAAA,EAAAA,MAAAA;EACAC,QAAAA,EAAAA;IAG0BJ,CAAAA,GAAAA,EAAAA,MAAAA,CAAAA,EAAAA,OAAAA;EAAvBN,CAAAA;CAEIW;;;;;AAKEX,KA9BTM,0BAAAA,GA8BSN,QAAAA,GAAAA,MAAAA,GAAAA,UAAAA,GAAAA,MAAAA;;;AAEwB;AAS7C;AAIYa,KAxCAN,cAAAA,GAwCAM,SAA+B;AAe3C;;;;;;;;;AA0BeG,KAvEHR,mBAAAA,GAuEGQ,KAAAA,GAAAA,MAAAA,GAAAA,KAAAA,GAAAA,MAAAA,GAAAA,KAAAA,GAAAA,KAAAA,GAAAA,MAAAA,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