UNPKG

generator-begcode

Version:

Spring Boot + Angular/React/Vue in one handy generator

18 lines (17 loc) 819 B
import { StandardRagBuilder } from './StandardRagBuilder.js'; import { TextChunker, TextRecombiner } from '../chunking/index.js'; export class Rag { static standard(context, collectionName, workspace, items) { return new StandardRagBuilder(context, collectionName, workspace, items); } static async filterWithSurroundingText(text, queryOrQueryVector, context, opts) { const { tokenLimit, surroundingCharacters, chunkLength, overlap } = opts; return Rag.standard(context) .addItems(TextChunker.fixedCharacterLength(text, { chunkLength, overlap, })) .query(queryOrQueryVector) .recombine(TextRecombiner.surroundingTextWithPreview(surroundingCharacters, '...\n', tokenLimit, context.chat.tokenizer, overlap)); } }