Skip to content

Commit 5c2c512

Browse files
feat: add REST API server and Knowledge Workbench web UI
Add a production-ready REST API (FastAPI) and a bundled React single-page app ("Knowledge Workbench") served at the same origin, so OpenKB can be driven from the browser, Postman, or other HTTP clients without the CLI. REST API (openkb/api.py): - Endpoints under /api/v1: /kbs, /init, /add, /query, /chat, /chat/sessions{,/load,/delete}, /list, /status, /lint, /remove, /recompile, /watch/{start,stop,status}, /watch/events (SSE) - Bearer-token auth, SSE streaming for query/chat/add/remove/recompile, multipart upload, and KB name resolution via OPENKB_KB_ROOT - Shared SSE event layer (iter_agent_response_events) reused by query/chat so the CLI and API emit identical event streams - Background file-watcher service (openkb/watch_service.py) for auto-compile Knowledge Workbench (frontend/, built to web/): - React + Vite dark three-pane workbench: Overview, Documents, Query, Chat, Maintenance, with a live retrieval/reasoning inspector timeline - Streamed answers, multi-turn chat with persisted sessions, drag-and-drop upload with per-file progress, lint/recompile/watch controls - Markdown via react-markdown + remark-gfm + rehype-highlight Also: initialize_kb inherits project-root config.yaml and .env (filtering OPENKB_* server vars) so a KB created from the UI runs out of the box; POSTMAN collection; README docs.
1 parent c92f2e9 commit 5c2c512

44 files changed

Lines changed: 10985 additions & 237 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@
44
# Gemini: LLM_API_KEY=AIza...
55
# DeepSeek: LLM_API_KEY=sk-...
66
LLM_API_KEY=your-key-here
7+
8+
# Optional base URL override for OpenAI-compatible gateways
9+
# OPENAI_API_BASE=https://api.deepseek.com
10+
11+
# --- REST API server variables (read by `openkb-api` / `python -m openkb.api`) ---
12+
# OPENKB_API_TOKEN=... # required bearer token clients send as Authorization: Bearer <token>
13+
# OPENKB_KB_ROOT=... # optional; where REST /init creates KBs (default: ~/.config/openkb/kbs)

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ raw/
1414
wiki/
1515
.openkb/
1616
output/
17+
kbs/
1718

1819
# Local only
1920
docs/

README.md

Lines changed: 461 additions & 42 deletions
Large diffs are not rendered by default.

config.yaml.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
model: gpt-5.4 # LLM model (any LiteLLM-supported provider)
2-
language: en # Wiki output language
1+
model: openai/deepseek-v4-flash # LLM model (any LiteLLM-supported provider)
2+
language: zh # Wiki output language
33
pageindex_threshold: 20 # PDF pages threshold for PageIndex
44

55
# Optional: override the entity-type vocabulary used for entity pages.

frontend/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
*.local

frontend/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="zh-CN">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>OpenKB · 知识工作台</title>
7+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@11/styles/github-dark.min.css" />
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.jsx"></script>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)