@langchain/core
Version:
Core LangChain.js abstractions and schemas
1 lines • 2.16 kB
Source Map (JSON)
{"version":3,"file":"document.cjs","names":["fields: DocumentInput<Metadata>"],"sources":["../../src/documents/document.ts"],"sourcesContent":["export interface DocumentInput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Metadata extends Record<string, any> = Record<string, any>\n> {\n pageContent: string;\n\n metadata?: Metadata;\n\n /**\n * An optional identifier for the document.\n *\n * Ideally this should be unique across the document collection and formatted\n * as a UUID, but this will not be enforced.\n */\n id?: string;\n}\n\nexport interface DocumentInterface<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Metadata extends Record<string, any> = Record<string, any>\n> {\n pageContent: string;\n\n metadata: Metadata;\n\n /**\n * An optional identifier for the document.\n *\n * Ideally this should be unique across the document collection and formatted\n * as a UUID, but this will not be enforced.\n */\n id?: string;\n}\n\n/**\n * Interface for interacting with a document.\n */\nexport class Document<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Metadata extends Record<string, any> = Record<string, any>\n> implements DocumentInput, DocumentInterface\n{\n pageContent: string;\n\n metadata: Metadata;\n\n // The ID field is optional at the moment.\n // It will likely become required in a future major release after\n // it has been adopted by enough vectorstore implementations.\n /**\n * An optional identifier for the document.\n *\n * Ideally this should be unique across the document collection and formatted\n * as a UUID, but this will not be enforced.\n */\n id?: string;\n\n constructor(fields: DocumentInput<Metadata>) {\n this.pageContent =\n fields.pageContent !== undefined ? fields.pageContent.toString() : \"\";\n this.metadata = fields.metadata ?? ({} as Metadata);\n this.id = fields.id;\n }\n}\n"],"mappings":";;;;;AAqCA,IAAa,WAAb,MAIA;CACE;CAEA;;;;;;;CAWA;CAEA,YAAYA,QAAiC;EAC3C,KAAK,cACH,OAAO,gBAAgB,SAAY,OAAO,YAAY,UAAU,GAAG;EACrE,KAAK,WAAW,OAAO,YAAa,CAAE;EACtC,KAAK,KAAK,OAAO;CAClB;AACF"}