@promptbook/utils
Version:
Promptbook: Run AI apps in plain human language across multiple models and platforms
55 lines (54 loc) • 1.42 kB
TypeScript
import type { string_url } from '../../../types/typeAliases';
import type { RAGConfig } from './types';
import type { RetrievalResult } from './types';
/**
* RAG (Retrieval-Augmented Generation) Service
* Handles knowledge source processing and retrieval
*
* @private
*/
export declare class RAGService {
private knowledgeBase;
private config;
constructor(config?: Partial<RAGConfig>);
/**
* Add a knowledge source from URL
*/
addKnowledgeSource(url: string_url): Promise<void>;
/**
* Retrieve relevant chunks for a query
*/
retrieveRelevantChunks(query: string): RetrievalResult[];
/**
* Get formatted context for the agent
*/
getContextForQuery(query: string): string;
/**
* Get knowledge base statistics
*/
getStats(): {
sources: number;
chunks: number;
lastUpdated: Date;
};
/**
* Clear all knowledge sources
*/
clearKnowledgeBase(): void;
/**
* Tokenize query into words for relevance scoring
*/
private tokenizeQuery;
/**
* Calculate relevance score between content and query words
* Simple keyword matching - in production, use embeddings
*/
private calculateRelevanceScore;
/**
* Generate content hash for caching
*/
private generateContentHash;
}
/**
* TODO: !!!! use the already existing RAG instead of this
*/