Docs/knowledge demo example#156
Conversation
Replace OpenRAG with a built-in knowledge engine supporting: - Vector store abstraction (SQLite default, Milvus, PGVector) - Docling document parsing (PDF, DOCX, HTML, etc.) - Session-scoped and agent-scoped document management - Knowledge MCP server, REST routes, and frontend panels - Configurable RAG profiles (speed/standard/balanced/max_quality) - Backward-compatible deprecation of OpenRAGClient Includes rebuilt frontend bundles reflecting knowledge UI additions.
Merge main into knowledge feature branch to incorporate: - Out-of-the-box agents (demo_docs, demo_health, oak_health) - Authorization flow improvements - Agent name customization - FastMCP security bump - Docker/deployment updates - Frontend dist relocation to src/cuga/frontend/dist Knowledge features preserved and integrated with new demo presets.
…eddings sentence-transformers/torch were removed from the project in favor of fastembed. Switch knowledge engine to FastEmbedEmbeddings to match.
…he with policies Replace langchain-community FastEmbedEmbeddings with a thin adapter that uses fastembed.TextEmbedding directly and reuses the model cache from embedding_service. Keeps langchain-community for SQLiteVec and Ollama.
…ai/ollama) - fastembed: default, uses fastembed.TextEmbedding directly - openai: requires api_key (config or env), supports custom base_url - ollama: supports custom base_url, defaults to localhost:11434 - Remove huggingface as provider (auto-migrated to fastembed) - Add api_key and base_url config fields for embeddings - Clear error messages when config is missing
…i, ollama Four distinct providers, each logically correct: - fastembed: default, lightweight local embeddings (installed with cuga) - huggingface: sentence-transformers (optional dep, clear install instructions) - openai: API-based, requires api_key config or OPENAI_API_KEY env var - ollama: local server, configurable base_url
Create the converter once (lazy) and pass it to DoclingLoader, avoiding model weight reloads on every document ingestion.
…d, knowledge agent ID - Replace Debug (bug) icon with Settings icon for Configuration section - Fix conversation history not loading when clicking previous sessions (pass selectedThreadId to CarbonChat so threadId changes trigger history reload, and keep isReadonly=true so homescreen doesn't override loaded history) - Fix knowledge documents not showing (setKnowledgeAgentId was using display name instead of actual agent ID) - Fix "body stream already read" error (manageRes.json() was called twice) - Restyle right panel section switcher with grounded tab-strip borders
…ead of ~/.cuga/ Move vector DB, metadata, uploaded files, session state, and auth token from ~/.cuga/ (shared home dir) to <cwd>/.cuga/ (per-project isolation), matching how policies already use <cwd>/.cuga/. Also fix test_defaults assertion for embedding_provider (fastembed not auto).
…gine start - Add `cuga start demo_knowledge` CLI mode (knowledge enabled from startup) - Add `cuga start demo_knowledge --reset` to wipe all knowledge data - Add `cuga stop demo_knowledge` handler - Default knowledge to disabled (knowledge_settings.toml, KnowledgeConfig dataclass) - Knowledge engine can be started on-demand via POST /api/knowledge/enable (called when user toggles knowledge ON in the manage UI) - Extract initialize_knowledge_engine() as reusable async function on app_state (full init: engine + session provider + MCP server + token + warmup) - Fix demo restart bug: no longer wipes knowledge data on every demo start (only wipes when --reset explicitly passed) - Fix reset: delete WAL sidecar files, check flock before deleting, log warnings instead of silently swallowing errors - Warn when --reset passed to non-knowledge demos - Fix Dynaconf caching: force enabled=true in saved config for demo_knowledge (env var set after settings import is not picked up by Dynaconf cache)
…agent into feat/knowledge-engine
[skip ci]
[skip ci]
# Conflicts: # .gitignore # .secrets.baseline # pyproject.toml # src/cuga/backend/cuga_graph/nodes/chat/chat_agent/chat_agent.py # src/cuga/backend/cuga_graph/nodes/cuga_lite/cuga_lite_graph.py # src/cuga/config.py # src/cuga/frontend/dist/index.html # uv.lock
Adds a new example under docs/examples/knowledge_demo/ that demonstrates the knowledge engine end-to-end with an HR Benefits Assistant scenario: - 4 agent-level sample docs (handbook, health plan, PTO, 401(k)) - 3 session-level sample docs (one employee's enrollment, PTO balance, pay stub) that exercise cross-scope RAG reasoning - main.py showing the programmatic SDK surface (agent.knowledge.ingest/search + agent.invoke) - README covering both Path A (SDK) and Path B (cuga start demo_knowledge) - pyproject.toml + .python-version + .env.example matching the cuga_as_mcp / cuga_with_runtime_tools example convention Also fixes a blocking bug in src/cuga/backend/knowledge/client.py: get_langchain_tools() generated tool functions that didn't accept the `thread_id` kwarg that cuga_lite_graph injects at runtime, which made any SDK-mode knowledge use via agent.invoke() crash with TypeError. Adding **_ to the 7 tool wrappers absorbs the injected kwarg while keeping the JSON schema (and thus the LLM-facing API) unchanged. Root README.md gets two new links to the example (Knowledge Base section + Additional Resources list). .gitignore adds the local-only demo_knowledge_docs/ scratch folder. Verified end-to-end: - 69/69 knowledge unit tests pass - Path A clean run answers "40 hours (5 days)" for PTO carryover, session search returns sarah_chen_pto_balance.md as top hit - Path B: cuga start demo_knowledge boots, /api/knowledge/health reports healthy+ready, HTTP upload + search both succeed
Merge
|
Summary
This PR adds a new hands-on example under
docs/examples/knowledge_demo/that demonstrates CUGA's knowledge engine end to end through a realistic HR Benefits Assistant scenario.It also fixes a blocking bug that prevented knowledge usage in SDK mode.
Why
The repo already documents the knowledge engine at a reference level in
KNOWLEDGE_PIPELINE.mdand the rootREADME.mdunder the Knowledge Base section, but it does not include a walkable example that shows the difference between agent-level and session-level knowledge in practice.That distinction is one of the most compelling parts of the feature, yet developers browsing
docs/examples/did not have a concrete example they could copy when integrating knowledge into their own agents.What is included
This PR adds a fictional HR Benefits Assistant for Acme Corp.
Agent-level documents
Persistent, shared across conversations:
employee_handbook.mdhealth_insurance_plan.mdpto_policy.md401k_plan.mdSession-level documents
Ephemeral, per-conversation documents for a single employee, Sarah Chen:
benefits_enrollment.mdpto_balance.mdmarch_2026_pay_stub.mdAll numbers in the example, including IRS limits, accrual rates, and premiums, are realistic for 2026 so the agent's answers are easy to verify.
Integration paths shown in the example
Both paths are documented in the example
README.md.Path A: SDK (
main.py)Demonstrates the full programmatic surface using:
CugaAgent(enable_knowledge=True)agent.knowledge.ingest(...)agent.knowledge.search(...)agent.invoke(...)Path B: UI (
cuga start demo_knowledge)Demonstrates the UI flow:
Demo prompts included
The example
README.mdincludes prompts that exercise different retrieval scopes:"What's the vacation carryover limit?"Agent-level only
"How many PTO days do I have left?"Session-level only
"Based on my pay stub and HSA enrollment, am I on track to max out my HSA?"Combines agent-level IRS limit and employer contribution rules with Sarah's YTD payroll deductions
"Will I have enough PTO for a 10-day July vacation?"Combines policy with Sarah's personal balance and accrual rate
Conventions
The example follows the same conventions as:
docs/examples/cuga_as_mcp/docs/examples/cuga_with_runtime_tools/Specifically:
cuga.env.exampleuv run --project ../../../ main.pyBug fix included
Problem
KnowledgeClient.get_langchain_tools()generated 7 tool wrapper functions whose signatures did not accept athread_idkeyword argument.At runtime,
cuga_lite_graph.pyinjectsthread_id, which caused SDK-mode calls toagent.invoke()with knowledge enabled to crash with: