feat(phase5): optional generative RAG — ask your lectures, with citations
Strictly opt-in, gated, with the deterministic features as the always-present floor: - GenerationEngine: WebLLM (Qwen2.5-1.5B, WebGPU, CDN-loaded) + BYO-key cloud (OpenAI-compatible); native stub. Pure grounding prompt builder (4 tests). - rag.askLectures: retrieve Phase-1 hits -> grounded prompt -> answer with citations; refuses when nothing relevant; falls back to search-only when no engine is available. Never sends raw audio/transcripts — only question + snippets. - aiStore (BYO key persisted in localStorage on web), Ask screen (answer + tappable citation chips that jump to the audio + honest "verify" disclaimer), Settings AI section (engine status + bring-your-own-key form). 279 tests green, 0 tsc errors, web export builds. ROADMAP phases 0-5 complete. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
// NATIVE on-device generation stub. Running a local LLM on device (e.g. via
|
||||
// llama.rn / MLC's native runtime) is a Phase 5 follow-up; until then the native
|
||||
// webllm engine reports unavailable so callers transparently fall back to the
|
||||
// search-only path (or a BYO-key cloud model). It NEVER produces a fake answer.
|
||||
//
|
||||
// This module is selected by Metro for native (.native.ts) and is never imported
|
||||
// by any vitest test.
|
||||
|
||||
import type { GenerationEngine } from './engine';
|
||||
|
||||
const NOT_AVAILABLE = 'On-device generation is not available on native yet';
|
||||
|
||||
export const webllm: GenerationEngine = {
|
||||
kind: 'webllm',
|
||||
label: 'On-device (Qwen2.5-1.5B)',
|
||||
|
||||
async isAvailable(): Promise<boolean> {
|
||||
return false;
|
||||
},
|
||||
|
||||
async loadModel(): Promise<void> {
|
||||
throw new Error(NOT_AVAILABLE);
|
||||
},
|
||||
|
||||
isLoaded(): boolean {
|
||||
return false;
|
||||
},
|
||||
|
||||
async generate(): Promise<string> {
|
||||
throw new Error(NOT_AVAILABLE);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user