Skip to main content

Text Processing & Search

AgentOS processes, measures, searches and scores text with classes and functions a host calls directly, with no agent in the loop. The memory and retrieval layers use the same parts: HybridRetriever searches with a BM25Index, LibraryIndex fuses its legs with reciprocalRankFusion, and RetrievalAugmentor reranks with RerankerService.

ToUsePage
Split text into words, drop stop words, stemTextProcessingPipeline, createProsePipeline(), createRagPipeline(), createCodePipeline()Text Processing Pipeline
Count, compare and classify text: sentences, n-grams, keywords, readability, similarity, language, summaries, sentimentStatisticalUtilityAI, LLMUtilityAI, HybridUtilityAIText Statistics and Classification
Translate a live transcript's final lines for a reader, one line into one target a call, with a spend boundTranscriptTranslatorTranscriptTranslator
Search by keywords, save the index as JSON, search in a browserLexicalIndex, BM25IndexLexical and Hybrid Search
Search records as someone types, with typos, word beginnings and field weights, and mark the matchesFuzzyIndexLexical and Hybrid Search
Fuse keyword and vector searchHybridSearcher, reciprocalRankFusion()Lexical and Hybrid Search
Fuse any number of ranked lists, with a weight a list and a cap a list and a groupfuseRanked()Lexical and Hybrid Search
Cut documents and transcripts into passages, show a hit's wordsSemanticChunker, chunkTurns(), ChunkingEngine, snippetAround()Chunking and Snippets
Reorder retrieved passagesRerankerService and its providersReranking
Search a library of sources by tenant and access groupLibraryIndexLibrary Index
Fuse BM25 with memory retrievalHybridRetrieverHybrid BM25 + Dense Retriever

Where each part runs​

PartImportRuns inCalls a model
LexicalIndex, FuzzyIndex, lexicalTokens, snippetAround, countWords, foldText, chunkTurns@framers/agentos/cognition/library/browserA browser or NodeNo
Text pipeline and presets@framers/agentos/cognition/nlpNode: it loads natural through node:moduleNo
StatisticalUtilityAIThe package root, @framers/agentos/cognition/nlp, @framers/agentos/cognition/nlp/ai_utilitiesNodeNo
LLMUtilityAIThe package root, @framers/agentos/cognition/nlp, @framers/agentos/cognition/nlp/ai_utilitiesNodeYes: a provider's key or a local model server
TranscriptTranslator, LanguageServiceThe package root, @framers/agentos/cognition/nlp/languageNodeTranscriptTranslator calls OpenAI with the key the host passes; LanguageService calls its configured provider
BM25Index, HybridSearcher, SemanticChunker@framers/agentos/cognition/ragNodeHybridSearcher calls the embedder you give it
reciprocalRankFusion@framers/agentos/cognition/memoryNodeNo
fuseRanked@framers/agentos/cognition/ragNodeNo
Rerankers@framers/agentos/cognition/rag/rerankingNode or a browser: no reranking module imports a Node module. Cohere sends its requests with the global fetch, and the local cross-encoder imports Transformers.js on its first callThe local cross-encoder scores in process (it downloads its model once); Cohere sends the query and passages to Cohere; the LLM judge calls the model your llmCallFn calls

Examples​

Five examples in the repository's examples/ folder run with no API key:

FileWhat it shows
text-processing-pipeline.mjsThe three preset pipelines over a paragraph and a line of code; tokens with positions and stems; a pipeline built stage by stage
text-statistics.mjsStatisticalUtilityAI's measures over one text
text-search-bm25.mjsBM25Index with any, all and prefix matching, saved as JSON and restored; a stemming pipeline; LexicalIndex with snippets
text-hybrid-search.mjsHybridSearcher over an in-memory vector store, with a stand-in embedder written in the example, and each result's ranks
rerank-llm-judge.mjsLlmJudgeReranker through RerankerService, with a stand-in judge written in the example; with RERANK_JUDGE_PROVIDER set it calls that provider's cheap model

They import the package by its name, which resolves to the build through the package's exports map, and CI runs all five against each build. Reranking lists the local cross-encoder and Cohere examples too. From a clone:

pnpm install && pnpm run build
node examples/text-search-bm25.mjs