If RAG is toggled on but the active scope (thread or KB) has zero indexed documents, exposing search_knowledge_base to the model just wastes a tool-call turn — the model calls the tool, gets back 'no matching chunks', and has to re-plan. The system prompt nudge that instructs the model to call the tool before answering is similarly counterproductive. Frontend: before computing ragToolPathTaken in chat-adapter, fetch the document list for the current scope (KB or thread) and require docs to exist. The flag now gates both the system prompt injection and the enabled_tools list. Defensive fallback: if the docs lookup fails the flag stays true so we don't silently swallow RAG. Backend: add _drop_rag_tool_if_scope_empty in routes/inference.py that counts rag_documents for the request's rag_scope and strips search_knowledge_base from the tool list when 0. Applied at both chat-completion tool-filter sites so the protection works regardless of which streaming path serves the request. |
||
|---|---|---|
| .. | ||
| backend | ||
| frontend | ||
| src-tauri | ||
| __init__.py | ||
| install_llama_prebuilt.py | ||
| install_python_stack.py | ||
| LICENSE.AGPL-3.0 | ||
| package-lock.json | ||
| package.json | ||
| setup.bat | ||
| setup.ps1 | ||
| setup.sh | ||
| Unsloth_Studio_Colab.ipynb | ||