Spaces:
Running
Running
bigwolfe
commited on
Commit
·
61c13df
1
Parent(s):
c23d869
new seed
Browse files- backend/src/services/seed.py +124 -56
backend/src/services/seed.py
CHANGED
|
@@ -21,24 +21,114 @@ DEMO_NOTES = [
|
|
| 21 |
|
| 22 |
Welcome to the Document Viewer! This is an AI-powered documentation system with wikilinks, full-text search, and backlinks.
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
## Key Features
|
| 25 |
|
| 26 |
- **Wikilinks**: Link between notes using `[[Note Name]]` syntax
|
| 27 |
- **Full-Text Search**: Powered by SQLite FTS5 with BM25 ranking
|
| 28 |
-
- **
|
| 29 |
- **MCP Integration**: AI agents can read and write docs via [[MCP Integration]]
|
| 30 |
- **Multi-Tenant**: Each user has an isolated vault
|
| 31 |
|
| 32 |
## Next Steps
|
| 33 |
|
| 34 |
-
1.
|
| 35 |
-
2.
|
| 36 |
-
3.
|
| 37 |
-
4.
|
|
|
|
| 38 |
|
| 39 |
## Demo Mode
|
| 40 |
|
| 41 |
⚠️ This is a **demo instance** - all data is temporary and resets on server restart."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
},
|
| 43 |
{
|
| 44 |
"path": "API Documentation.md",
|
|
@@ -80,7 +170,8 @@ Get your token from [[Settings]] after signing in with Hugging Face OAuth.
|
|
| 80 |
|
| 81 |
## Related
|
| 82 |
|
| 83 |
-
- [[
|
|
|
|
| 84 |
- [[Wikilink Examples]] - How to use wikilinks"""
|
| 85 |
},
|
| 86 |
{
|
|
@@ -96,10 +187,10 @@ The Model Context Protocol (MCP) allows AI agents like Claude to interact with y
|
|
| 96 |
The MCP server exposes these tools:
|
| 97 |
|
| 98 |
- `list_notes` - List all notes in the vault
|
| 99 |
-
- `read_note` - Read a specific note with metadata
|
| 100 |
- `write_note` - Create or update a note
|
| 101 |
- `delete_note` - Remove a note
|
| 102 |
-
- `search_notes` - Full-text search with ranking
|
| 103 |
- `get_backlinks` - Find notes linking to a target
|
| 104 |
- `get_tags` - List all tags
|
| 105 |
|
|
@@ -124,6 +215,7 @@ For **HTTP mode** (HF Space), use:
|
|
| 124 |
|
| 125 |
## Related
|
| 126 |
|
|
|
|
| 127 |
- [[API Documentation]] - REST API reference
|
| 128 |
- [[Architecture Overview]] - System design"""
|
| 129 |
},
|
|
@@ -179,7 +271,7 @@ The Document Viewer is built with a modern tech stack optimized for AI-human col
|
|
| 179 |
### Backend
|
| 180 |
|
| 181 |
- **FastAPI** - HTTP API server
|
| 182 |
-
- **FastMCP** - MCP server for AI agents
|
| 183 |
- **SQLite FTS5** - Full-text search engine
|
| 184 |
- **python-frontmatter** - YAML metadata parsing
|
| 185 |
|
|
@@ -188,35 +280,16 @@ The Document Viewer is built with a modern tech stack optimized for AI-human col
|
|
| 188 |
- **React + Vite** - Modern web framework
|
| 189 |
- **shadcn/ui** - Beautiful UI components
|
| 190 |
- **Tailwind CSS** - Utility-first styling
|
| 191 |
-
- **react-
|
| 192 |
-
|
| 193 |
-
## Data Model
|
| 194 |
-
|
| 195 |
-
### Notes
|
| 196 |
-
|
| 197 |
-
Each note is a Markdown file with optional YAML frontmatter:
|
| 198 |
-
|
| 199 |
-
```yaml
|
| 200 |
-
---
|
| 201 |
-
title: My Note
|
| 202 |
-
tags: [guide, tutorial]
|
| 203 |
-
created: 2025-01-15T10:00:00Z
|
| 204 |
-
updated: 2025-01-15T14:30:00Z
|
| 205 |
-
---
|
| 206 |
-
|
| 207 |
-
# Note content here
|
| 208 |
-
```
|
| 209 |
|
| 210 |
-
|
| 211 |
|
| 212 |
-
|
| 213 |
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
See [[Search Features]] for ranking details.
|
| 220 |
|
| 221 |
## Multi-Tenancy
|
| 222 |
|
|
@@ -363,6 +436,15 @@ Common issues and solutions.
|
|
| 363 |
- Wikilinks match on normalized slugs (case-insensitive, spaces→dashes)
|
| 364 |
- See [[Wikilink Examples]] for how resolution works
|
| 365 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 366 |
## Version Conflict on Save
|
| 367 |
|
| 368 |
**Problem**: "This note changed since you opened it" error when saving.
|
|
@@ -373,15 +455,6 @@ Common issues and solutions.
|
|
| 373 |
- Copy your changes and re-apply them
|
| 374 |
- This prevents data loss from concurrent edits
|
| 375 |
|
| 376 |
-
## Authentication Issues
|
| 377 |
-
|
| 378 |
-
**Problem**: Keep getting logged out or "401 Unauthorized" errors.
|
| 379 |
-
|
| 380 |
-
**Solution**:
|
| 381 |
-
- JWT tokens expire after 7 days
|
| 382 |
-
- Sign in again to get a new token
|
| 383 |
-
- Check that your [[MCP Integration]] config uses a valid token
|
| 384 |
-
|
| 385 |
## Data Disappeared
|
| 386 |
|
| 387 |
**Problem**: Notes or changes are missing after page reload.
|
|
@@ -389,8 +462,7 @@ Common issues and solutions.
|
|
| 389 |
**Solution**:
|
| 390 |
- This is a **DEMO instance** with ephemeral storage
|
| 391 |
- Data resets when the server restarts
|
| 392 |
-
- For permanent storage, deploy your own instance
|
| 393 |
-
- See [[Getting Started]] for demo disclaimer"""
|
| 394 |
},
|
| 395 |
{
|
| 396 |
"path": "FAQ.md",
|
|
@@ -408,25 +480,21 @@ A: An AI-powered documentation system where AI agents (via [[MCP Integration]])
|
|
| 408 |
|
| 409 |
**Q: Is my data persistent?**
|
| 410 |
|
| 411 |
-
A: **No, this is a demo instance.** All data is ephemeral and resets on server restart. For permanent storage, deploy your own instance.
|
| 412 |
|
| 413 |
**Q: How do I sign in?**
|
| 414 |
|
| 415 |
A: Click "Sign in with Hugging Face" on the login page. You'll authenticate via HF OAuth and get isolated vault access.
|
| 416 |
|
| 417 |
-
##
|
| 418 |
-
|
| 419 |
-
**Q: What are wikilinks?**
|
| 420 |
-
|
| 421 |
-
A: Wikilinks let you link between notes using `[[Note Name]]` syntax. See [[Wikilink Examples]].
|
| 422 |
|
| 423 |
-
**Q: How does
|
| 424 |
|
| 425 |
-
A:
|
| 426 |
|
| 427 |
-
**Q: Can
|
| 428 |
|
| 429 |
-
A: Yes!
|
| 430 |
|
| 431 |
## Technical
|
| 432 |
|
|
|
|
| 21 |
|
| 22 |
Welcome to the Document Viewer! This is an AI-powered documentation system with wikilinks, full-text search, and backlinks.
|
| 23 |
|
| 24 |
+
## 🌟 New: ChatGPT App Integration
|
| 25 |
+
|
| 26 |
+
Transform ChatGPT into your personal knowledge assistant. View notes directly in the chat with our new **Interactive Widgets**.
|
| 27 |
+
|
| 28 |
+
👉 **[[ChatGPT App Integration]]** - Learn how to connect and use the widget.
|
| 29 |
+
|
| 30 |
## Key Features
|
| 31 |
|
| 32 |
- **Wikilinks**: Link between notes using `[[Note Name]]` syntax
|
| 33 |
- **Full-Text Search**: Powered by SQLite FTS5 with BM25 ranking
|
| 34 |
+
- **Interactive Graph**: Visualize your vault's connections (Toggle via top-right menu)
|
| 35 |
- **MCP Integration**: AI agents can read and write docs via [[MCP Integration]]
|
| 36 |
- **Multi-Tenant**: Each user has an isolated vault
|
| 37 |
|
| 38 |
## Next Steps
|
| 39 |
|
| 40 |
+
1. Connect to **[[ChatGPT App Integration]]**
|
| 41 |
+
2. Browse the [[API Documentation]]
|
| 42 |
+
3. Learn about [[Wikilink Examples]]
|
| 43 |
+
4. Understand the [[Architecture Overview]]
|
| 44 |
+
5. Check out [[Self Hosting]] guide
|
| 45 |
|
| 46 |
## Demo Mode
|
| 47 |
|
| 48 |
⚠️ This is a **demo instance** - all data is temporary and resets on server restart."""
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"path": "ChatGPT App Integration.md",
|
| 52 |
+
"title": "ChatGPT App Integration",
|
| 53 |
+
"tags": ["chatgpt", "integration", "widgets"],
|
| 54 |
+
"body": """# ChatGPT App Integration
|
| 55 |
+
|
| 56 |
+
We've built a custom integration that allows ChatGPT to natively interact with this documentation vault.
|
| 57 |
+
|
| 58 |
+
## Features
|
| 59 |
+
|
| 60 |
+
- **Search Widget**: Ask ChatGPT "Search for API docs" and get a clean list of results.
|
| 61 |
+
- **Note Viewer**: Ask "Show me the Getting Started note" and see the full markdown rendered in an interactive widget.
|
| 62 |
+
- **In-Context Editing**: Ask ChatGPT to edit a note, and see the changes reflected immediately.
|
| 63 |
+
|
| 64 |
+
## How to Connect
|
| 65 |
+
|
| 66 |
+
1. Go to **ChatGPT** -> **Explore GPTs** -> **Create**.
|
| 67 |
+
2. Click **Configure** -> **Create new action**.
|
| 68 |
+
3. Select **Authentication**: `None` (for this Demo instance).
|
| 69 |
+
4. Enter the **Schema**: Import from URL `https://[your-space-url].hf.space/openapi.json`.
|
| 70 |
+
5. Save and test!
|
| 71 |
+
|
| 72 |
+
## Using the App
|
| 73 |
+
|
| 74 |
+
Try these prompts:
|
| 75 |
+
|
| 76 |
+
- "What notes do I have about architecture?"
|
| 77 |
+
- "Read the [[Architecture Overview]] note."
|
| 78 |
+
- "Create a new note called 'Meeting Notes' with a summary of our chat."
|
| 79 |
+
|
| 80 |
+
## Technical Details
|
| 81 |
+
|
| 82 |
+
This integration uses the **OpenAI Apps SDK** and our **FastMCP** backend.
|
| 83 |
+
The backend injects special metadata (`_meta.openai.outputTemplate`) into MCP tool responses, telling ChatGPT to render our custom **Widget** (`widget.html`) instead of plain text.
|
| 84 |
+
|
| 85 |
+
See [[Architecture Overview]] for more."""
|
| 86 |
+
},
|
| 87 |
+
{
|
| 88 |
+
"path": "Self Hosting.md",
|
| 89 |
+
"title": "Self Hosting",
|
| 90 |
+
"tags": ["guide", "hosting", "deployment"],
|
| 91 |
+
"body": """# Self Hosting
|
| 92 |
+
|
| 93 |
+
While this demo runs on Hugging Face Spaces, the Document Viewer is designed to be self-hosted for privacy and persistence.
|
| 94 |
+
|
| 95 |
+
## Requirements
|
| 96 |
+
|
| 97 |
+
- **Docker** or **Python 3.11+** & **Node.js 20+**
|
| 98 |
+
|
| 99 |
+
## Docker Deployment (Recommended)
|
| 100 |
+
|
| 101 |
+
1. Clone the repository.
|
| 102 |
+
2. Run:
|
| 103 |
+
```bash
|
| 104 |
+
docker compose up --build
|
| 105 |
+
```
|
| 106 |
+
3. Access at `http://localhost:5173`.
|
| 107 |
+
|
| 108 |
+
## Manual Deployment
|
| 109 |
+
|
| 110 |
+
1. **Backend**:
|
| 111 |
+
```bash
|
| 112 |
+
cd backend
|
| 113 |
+
uv sync
|
| 114 |
+
./start.sh
|
| 115 |
+
```
|
| 116 |
+
2. **Frontend**:
|
| 117 |
+
```bash
|
| 118 |
+
cd frontend
|
| 119 |
+
npm install
|
| 120 |
+
npm run build
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
## Configuration
|
| 124 |
+
|
| 125 |
+
Configure the app via environment variables or `.env` file:
|
| 126 |
+
|
| 127 |
+
- `JWT_SECRET_KEY`: Set a strong secret for authentication.
|
| 128 |
+
- `VAULT_BASE_PATH`: Directory where notes are stored (mount a persistent volume here).
|
| 129 |
+
- `ENABLE_NOAUTH_MCP`: Set to `false` for production to require tokens.
|
| 130 |
+
|
| 131 |
+
See [[API Documentation]] for more config details."""
|
| 132 |
},
|
| 133 |
{
|
| 134 |
"path": "API Documentation.md",
|
|
|
|
| 170 |
|
| 171 |
## Related
|
| 172 |
|
| 173 |
+
- [[ChatGPT App Integration]] - Use the API via ChatGPT
|
| 174 |
+
- [[MCP Integration]] - Standard MCP tool reference
|
| 175 |
- [[Wikilink Examples]] - How to use wikilinks"""
|
| 176 |
},
|
| 177 |
{
|
|
|
|
| 187 |
The MCP server exposes these tools:
|
| 188 |
|
| 189 |
- `list_notes` - List all notes in the vault
|
| 190 |
+
- `read_note` - Read a specific note with metadata (Returns widget metadata for ChatGPT)
|
| 191 |
- `write_note` - Create or update a note
|
| 192 |
- `delete_note` - Remove a note
|
| 193 |
+
- `search_notes` - Full-text search with ranking (Returns widget metadata for ChatGPT)
|
| 194 |
- `get_backlinks` - Find notes linking to a target
|
| 195 |
- `get_tags` - List all tags
|
| 196 |
|
|
|
|
| 215 |
|
| 216 |
## Related
|
| 217 |
|
| 218 |
+
- [[ChatGPT App Integration]] - The advanced widget experience
|
| 219 |
- [[API Documentation]] - REST API reference
|
| 220 |
- [[Architecture Overview]] - System design"""
|
| 221 |
},
|
|
|
|
| 271 |
### Backend
|
| 272 |
|
| 273 |
- **FastAPI** - HTTP API server
|
| 274 |
+
- **FastMCP** - MCP server for AI agents (supports StdIO and SSE/HTTP)
|
| 275 |
- **SQLite FTS5** - Full-text search engine
|
| 276 |
- **python-frontmatter** - YAML metadata parsing
|
| 277 |
|
|
|
|
| 280 |
- **React + Vite** - Modern web framework
|
| 281 |
- **shadcn/ui** - Beautiful UI components
|
| 282 |
- **Tailwind CSS** - Utility-first styling
|
| 283 |
+
- **react-force-graph** - Interactive graph visualization
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
|
| 285 |
+
## ChatGPT Integration
|
| 286 |
|
| 287 |
+
We use a hybrid approach for the [[ChatGPT App Integration]]:
|
| 288 |
|
| 289 |
+
1. **FastMCP** exposes tools (`read_note`) via HTTP.
|
| 290 |
+
2. Tools return `CallToolResult` with `_meta.openai.outputTemplate`.
|
| 291 |
+
3. ChatGPT renders our **Widget** (`widget.html`) in an iframe.
|
| 292 |
+
4. The Widget reuses React components from the main app (`NoteViewer`) for a consistent look.
|
|
|
|
|
|
|
| 293 |
|
| 294 |
## Multi-Tenancy
|
| 295 |
|
|
|
|
| 436 |
- Wikilinks match on normalized slugs (case-insensitive, spaces→dashes)
|
| 437 |
- See [[Wikilink Examples]] for how resolution works
|
| 438 |
|
| 439 |
+
## ChatGPT Widget Empty
|
| 440 |
+
|
| 441 |
+
**Problem**: The ChatGPT widget loads but shows a blank screen or error.
|
| 442 |
+
|
| 443 |
+
**Solution**:
|
| 444 |
+
- Check that `ENABLE_NOAUTH_MCP` is set to `true` (if using the demo instance).
|
| 445 |
+
- Ensure the backend URL is reachable from ChatGPT.
|
| 446 |
+
- Check if the note actually exists in the `demo-user` vault.
|
| 447 |
+
|
| 448 |
## Version Conflict on Save
|
| 449 |
|
| 450 |
**Problem**: "This note changed since you opened it" error when saving.
|
|
|
|
| 455 |
- Copy your changes and re-apply them
|
| 456 |
- This prevents data loss from concurrent edits
|
| 457 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 458 |
## Data Disappeared
|
| 459 |
|
| 460 |
**Problem**: Notes or changes are missing after page reload.
|
|
|
|
| 462 |
**Solution**:
|
| 463 |
- This is a **DEMO instance** with ephemeral storage
|
| 464 |
- Data resets when the server restarts
|
| 465 |
+
- For permanent storage, deploy your own instance (See [[Self Hosting]])"""
|
|
|
|
| 466 |
},
|
| 467 |
{
|
| 468 |
"path": "FAQ.md",
|
|
|
|
| 480 |
|
| 481 |
**Q: Is my data persistent?**
|
| 482 |
|
| 483 |
+
A: **No, this is a demo instance.** All data is ephemeral and resets on server restart. For permanent storage, deploy your own instance (see [[Self Hosting]]).
|
| 484 |
|
| 485 |
**Q: How do I sign in?**
|
| 486 |
|
| 487 |
A: Click "Sign in with Hugging Face" on the login page. You'll authenticate via HF OAuth and get isolated vault access.
|
| 488 |
|
| 489 |
+
## ChatGPT Integration
|
|
|
|
|
|
|
|
|
|
|
|
|
| 490 |
|
| 491 |
+
**Q: How does the ChatGPT widget work?**
|
| 492 |
|
| 493 |
+
A: Our MCP server returns special metadata that tells ChatGPT to load an iframe with our custom `widget.html`. This reuses our React frontend code to render notes beautifully inside the chat. See [[ChatGPT App Integration]].
|
| 494 |
|
| 495 |
+
**Q: Can ChatGPT create notes?**
|
| 496 |
|
| 497 |
+
A: Yes! Ask it to "Create a note about X" and it will use the `write_note` tool.
|
| 498 |
|
| 499 |
## Technical
|
| 500 |
|