@promptbook/utils
Version:
Promptbook: Run AI apps in plain human language across multiple models and platforms
49 lines (48 loc) • 1.39 kB
TypeScript
import type { string_url } from '../../../types/typeAliases';
import type { RAGConfig } from './types';
import type { RetrievalResult } from './types';
/**
* Frontend RAG Service that uses backend APIs for processing
* This avoids Node.js dependencies in the frontend
*
* @private - TODO: [🧠] Maybe should be public?
*/
export declare class FrontendRAGService {
private chunks;
private sources;
private config;
private isInitialized;
constructor(config?: Partial<RAGConfig>);
/**
* Initialize knowledge sources by processing them on the backend
*/
initializeKnowledgeSources(sources: string_url[]): Promise<void>;
/**
* Get relevant context for a user query
*/
getContextForQuery(query: string): Promise<string>;
/**
* Get relevant chunks for a query (for debugging/inspection)
*/
getRelevantChunks(query: string): Promise<RetrievalResult[]>;
/**
* Get knowledge base statistics
*/
getStats(): {
sources: number;
chunks: number;
isInitialized: boolean;
};
/**
* Check if the service is ready to use
*/
isReady(): boolean;
/**
* Clear all knowledge sources
*/
clearKnowledgeBase(): void;
/**
* Add a single knowledge source (for incremental updates)
*/
addKnowledgeSource(url: string_url): Promise<void>;
}