UNPKG

@langchain/community

Version:
1 lines • 2.69 kB
{"version":3,"file":"document.cjs","names":["Serializable"],"sources":["../../src/graphs/document.ts"],"sourcesContent":["import { Serializable } from \"@langchain/core/load/serializable\";\nimport { Document } from \"@langchain/core/documents\";\n\nexport class Node extends Serializable {\n id: string | number;\n\n type: string;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n properties: Record<string, any>;\n\n lc_namespace = [\"langchain\", \"graph\", \"document_node\"];\n\n constructor({\n id,\n type = \"Node\",\n properties = {},\n }: {\n id: string | number;\n type: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n properties?: Record<string, any>;\n }) {\n super();\n this.id = id;\n this.type = type;\n this.properties = properties;\n }\n}\n\nexport class Relationship extends Serializable {\n source: Node;\n\n target: Node;\n\n type: string;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n properties: Record<string, any>;\n\n lc_namespace = [\"langchain\", \"graph\", \"document_relationship\"];\n\n constructor({\n source,\n target,\n type,\n properties = {},\n }: {\n source: Node;\n target: Node;\n type: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n properties?: Record<string, any>;\n }) {\n super();\n this.source = source;\n this.target = target;\n this.type = type;\n this.properties = properties;\n }\n}\n\nexport class GraphDocument extends Serializable {\n nodes: Node[];\n\n relationships: Relationship[];\n\n source: Document;\n\n lc_namespace = [\"langchain\", \"graph\", \"graph_document\"];\n\n constructor({\n nodes,\n relationships,\n source,\n }: {\n nodes: Node[];\n relationships: Relationship[];\n source: Document;\n }) {\n super({\n nodes,\n relationships,\n source,\n });\n this.nodes = nodes;\n this.relationships = relationships;\n this.source = source;\n }\n}\n"],"mappings":";;;;;;;;;;AAGA,IAAa,OAAb,cAA0BA,gDAAa;CACrC;CAEA;CAGA;CAEA,eAAe;EAAC;EAAa;EAAS;CAAgB;CAEtD,YAAY,EACV,IACA,OAAO,QACP,aAAa,CAAE,GAMhB,EAAE;EACD,OAAO;EACP,KAAK,KAAK;EACV,KAAK,OAAO;EACZ,KAAK,aAAa;CACnB;AACF;AAED,IAAa,eAAb,cAAkCA,gDAAa;CAC7C;CAEA;CAEA;CAGA;CAEA,eAAe;EAAC;EAAa;EAAS;CAAwB;CAE9D,YAAY,EACV,QACA,QACA,MACA,aAAa,CAAE,GAOhB,EAAE;EACD,OAAO;EACP,KAAK,SAAS;EACd,KAAK,SAAS;EACd,KAAK,OAAO;EACZ,KAAK,aAAa;CACnB;AACF;AAED,IAAa,gBAAb,cAAmCA,gDAAa;CAC9C;CAEA;CAEA;CAEA,eAAe;EAAC;EAAa;EAAS;CAAiB;CAEvD,YAAY,EACV,OACA,eACA,QAKD,EAAE;EACD,MAAM;GACJ;GACA;GACA;EACD,EAAC;EACF,KAAK,QAAQ;EACb,KAAK,gBAAgB;EACrB,KAAK,SAAS;CACf;AACF"}