Spaces:
Paused
Paused
Commit ·
89e2c52
1
Parent(s): f97b9fe
feat: show KB overview summary on welcome page in both CLI and web UI
Browse filesLoads the KB meta overview (generated during ingestion) and displays it
when the chatbot starts, so users immediately see what is in their
knowledge base.
- CLI: KB summary shown in the welcome panel (truncated to ~600 chars)
- Web: KB summary shown in an expandable section before the first message
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- app_cli.py +15 -0
- app_web.py +12 -0
app_cli.py
CHANGED
|
@@ -9,6 +9,7 @@ from rich.text import Text
|
|
| 9 |
|
| 10 |
from src.config_loader import load_config, get_api_key
|
| 11 |
from src.ingest import ingest_documents
|
|
|
|
| 12 |
from src.query_engine import understand_query
|
| 13 |
from src.retriever import retrieve
|
| 14 |
from src.verifier import verify_and_respond
|
|
@@ -213,6 +214,20 @@ def main() -> None:
|
|
| 213 |
welcome.append("OFF", style="bold red")
|
| 214 |
welcome.append(". Use /websearch on to enable.\n\n")
|
| 215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
welcome.append("Type your question, or /help for commands.\n", style="italic")
|
| 217 |
welcome.append("Type /quit to exit.", style="italic dim")
|
| 218 |
console.print(Panel(welcome, title="Welcome", border_style="cyan"))
|
|
|
|
| 9 |
|
| 10 |
from src.config_loader import load_config, get_api_key
|
| 11 |
from src.ingest import ingest_documents
|
| 12 |
+
from src.kb_meta import load_kb_meta
|
| 13 |
from src.query_engine import understand_query
|
| 14 |
from src.retriever import retrieve
|
| 15 |
from src.verifier import verify_and_respond
|
|
|
|
| 214 |
welcome.append("OFF", style="bold red")
|
| 215 |
welcome.append(". Use /websearch on to enable.\n\n")
|
| 216 |
|
| 217 |
+
# KB overview summary
|
| 218 |
+
kb_overview = load_kb_meta(cfg)
|
| 219 |
+
if kb_overview:
|
| 220 |
+
welcome.append("Knowledge Base Contents:\n", style="bold")
|
| 221 |
+
# Strip the === markers and show the body
|
| 222 |
+
overview_body = kb_overview
|
| 223 |
+
for marker in ("=== KNOWLEDGE BASE OVERVIEW ===", "=== END OVERVIEW ==="):
|
| 224 |
+
overview_body = overview_body.replace(marker, "")
|
| 225 |
+
overview_body = overview_body.strip()
|
| 226 |
+
# Truncate for the welcome panel (keep first ~600 chars)
|
| 227 |
+
if len(overview_body) > 600:
|
| 228 |
+
overview_body = overview_body[:600].rsplit("\n", 1)[0] + "\n..."
|
| 229 |
+
welcome.append(overview_body + "\n\n", style="dim")
|
| 230 |
+
|
| 231 |
welcome.append("Type your question, or /help for commands.\n", style="italic")
|
| 232 |
welcome.append("Type /quit to exit.", style="italic dim")
|
| 233 |
console.print(Panel(welcome, title="Welcome", border_style="cyan"))
|
app_web.py
CHANGED
|
@@ -4,6 +4,7 @@ import streamlit as st
|
|
| 4 |
|
| 5 |
from src.config_loader import load_config, get_api_key
|
| 6 |
from src.ingest import get_chroma_collection, ingest_documents
|
|
|
|
| 7 |
from src.query_engine import understand_query
|
| 8 |
from src.retriever import retrieve
|
| 9 |
from src.verifier import verify_and_respond
|
|
@@ -288,6 +289,17 @@ def main():
|
|
| 288 |
|
| 289 |
st.title(bot_name)
|
| 290 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 291 |
render_sidebar()
|
| 292 |
render_chat()
|
| 293 |
|
|
|
|
| 4 |
|
| 5 |
from src.config_loader import load_config, get_api_key
|
| 6 |
from src.ingest import get_chroma_collection, ingest_documents
|
| 7 |
+
from src.kb_meta import load_kb_meta
|
| 8 |
from src.query_engine import understand_query
|
| 9 |
from src.retriever import retrieve
|
| 10 |
from src.verifier import verify_and_respond
|
|
|
|
| 289 |
|
| 290 |
st.title(bot_name)
|
| 291 |
|
| 292 |
+
# Show KB overview on first visit (no messages yet)
|
| 293 |
+
if not st.session_state.messages:
|
| 294 |
+
kb_overview = load_kb_meta(cfg)
|
| 295 |
+
if kb_overview:
|
| 296 |
+
overview_body = kb_overview
|
| 297 |
+
for marker in ("=== KNOWLEDGE BASE OVERVIEW ===", "=== END OVERVIEW ==="):
|
| 298 |
+
overview_body = overview_body.replace(marker, "")
|
| 299 |
+
overview_body = overview_body.strip()
|
| 300 |
+
with st.expander("Knowledge Base Contents", expanded=True):
|
| 301 |
+
st.markdown(overview_body)
|
| 302 |
+
|
| 303 |
render_sidebar()
|
| 304 |
render_chat()
|
| 305 |
|