External providers (OpenAI/Anthropic/Gemini) can't run the local search_knowledge_base tool loop, so give them RAG by prefetching: studio retrieves before calling the provider, injects the chunks into the user prompt, and surfaces it as a synthetic tool call. Local models are untouched (they keep tool-based RAG + decomposition). Backend: - New POST /api/rag/prefetch: momentarily loads the pre-cached helper (gemma-4-E2B-it-GGUF) via LlamaCppBackend(kill_orphans=False) to decompose the question into up to 3 queries, retrieves+merges+dedups per query, unloads the helper. Raw single-query fallback if the helper can't load. New core/rag/query_decompose.py owns the helper lifecycle. - Factored the retrieval body of /search into _execute_search, reused by both endpoints. Frontend: - prefetchRag() client. - chat-adapter external branch: gated on isExternalRequest + ragToolEnabled + scope!=off + ragScopeHasDocs (no docs -> no prefetch, prior behavior preserved). Formats hits as <chunk id=N> (parseChunks shape), injects into the last user message (send-only; not shown in the user bubble), seeds a synthetic search_knowledge_base tool-call part so the existing chunk-card UI + [N] citations + source badges all work unchanged. - Extends PR #5674's disabled-tool guard: when RAG is off, reinforce 'no document search (RAG) capabilities'; when prefetch ran, point the model at the injected excerpts instead. - RAG pill enabled for external providers regardless of supports_tools. Not build/UI verified here (no bun/GPU/keys); needs bun typecheck+test and a browser round-trip with real provider keys. |
||
|---|---|---|
| .. | ||
| public | ||
| src | ||
| .gitignore | ||
| .gitkeep | ||
| .npmrc | ||
| biome.json | ||
| components.json | ||
| data-designer.openapi (1).yaml | ||
| eslint.config.js | ||
| index.html | ||
| package-lock.json | ||
| package.json | ||
| tsconfig.app.json | ||
| tsconfig.json | ||
| tsconfig.node.json | ||
| vite.config.ts | ||
| vitest.config.ts | ||