UNPKG

llamaindex

Version:

<p align="center"> <img height="100" width="100" alt="LlamaIndex logo" src="https://ts.llamaindex.ai/square.svg" /> </p> <h1 align="center">LlamaIndex.TS</h1> <h3 align="center"> Data framework for your LLM application. </h3>

14 lines (13 loc) 441 B
import { MetadataMode } from "@llamaindex/core/schema"; export class MetadataReplacementPostProcessor { targetMetadataKey; constructor(targetMetadataKey){ this.targetMetadataKey = targetMetadataKey; } async postprocessNodes(nodes) { for (const n of nodes){ n.node.setContent(n.node.metadata[this.targetMetadataKey] ?? n.node.getContent(MetadataMode.NONE)); } return nodes; } }