You can load any XML file from your local file system or through a URL. Headers are included for each line, so if you have an age column, 18 will be added as age: 18.

Install XML addon

npm install @llm-tools/embedjs-loader-xml

Usage

Load from a local file

import { RAGApplicationBuilder } from '@llm-tools/embedjs';

import { OpenAiEmbeddings } from '@llm-tools/embedjs-openai';

import { HNSWDb } from '@llm-tools/embedjs-hnswlib';

import { XmlLoader } from '@llm-tools/embedjs-loader-csv';



const app = await new RAGApplicationBuilder()

.setModel(SIMPLE_MODELS.OPENAI_GPT4_O)

.setEmbeddingModel(new OpenAiEmbeddings())

.setVectorDatabase(new HNSWDb())

.build();



app.addLoader(new XmlLoader({ filePathOrUrl: '/path/to/file.xml' }))

Load from URL

import { RAGApplicationBuilder } from '@llm-tools/embedjs';

import { OpenAiEmbeddings } from '@llm-tools/embedjs-openai';

import { HNSWDb } from '@llm-tools/embedjs-hnswlib';

import { XmlLoader } from '@llm-tools/embedjs-loader-csv';



const app = await new RAGApplicationBuilder()

.setModel(SIMPLE_MODELS.OPENAI_GPT4_O)

.setEmbeddingModel(new OpenAiEmbeddings())

.setVectorDatabase(new HNSWDb())

.build();



app.addLoader(new XmlLoader({ filePathOrUrl: 'https://www.w3schools.com/xml/plant_catalog.xml' }))