Files
Zportal-Wiki-VectorDB-Chat/README.md
admin ae621ecbb5 Initial release: Multi-provider AI chat with RAG
FastAPI backend (wiki-vector-chat.py) with Odysseus-style frontend.
Features: multi-provider LLM, Wiki KB + VectorDB RAG, session history,
chat modes, save-to-wiki, markdown rendering, SSE streaming.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-03 10:25:29 +00:00

2.8 KiB

Zportal Wiki VectorDB Chat

Multi-provider AI chat with RAG (Wiki KB + VectorDB) for the Z.ai portal.

Architecture

Component Port File Purpose
wiki-vector-chat 8770 wiki-vector-chat.py FastAPI chat backend — multi-provider LLM, RAG pipeline, SSE streaming
wiki-api 8097 wiki-api.py KB keyword search over wiki-kb.json (1,301 Q&A entries)
vector-db-service 8099 vector-db-service.py TF-IDF vector search on Discord/Reddit messages
Frontend static zportal-chat.html Odysseus-style chat UI at /zportal/chat
wiki-chat-server 8098 wiki-chat-server.py Legacy Z.ai GLM-4 proxy (being replaced)
wiki-chat-proxy wiki-chat-proxy.py Legacy chat proxy helper

Features

  • Multi-provider LLM — OpenAI, Anthropic, Ollama, OpenRouter, Groq, custom endpoints
  • RAG pipeline — Dual-source context from Wiki KB + VectorDB with per-session toggles
  • Chat modes — Chat, Code, Brainstorm with mode-specific system prompts
  • Session history — localStorage persistence, switch between sessions, auto-save
  • Save to Wiki — Save AI answers as new Q&A entries in the Wiki KB
  • Message actions — Copy, Redo, Save-to-Wiki buttons on AI responses
  • Markdown rendering — Bold, italic, code blocks, lists in AI replies
  • SSE streaming — Server-Sent Events for real-time token streaming
  • Provider management — CRUD for custom providers, preset forking with API keys
  • Odysseus UI — Tokyo Night palette, sidebar, chat bubbles, model picker

Provider Presets

ID Name Format
zai-coding Z.ai Coding Plan OpenAI
openadapter OpenAdapter OpenAI
openrouter OpenRouter OpenRouter
crofai Crof.AI OpenAI
opencode-zen Opencode Zen OpenAI

Nginx Config

location = /zportal/chat {
    default_type text/html;
    alias /opt/zportal/chat.html;
}
location ^~ /zportal/wiki/api/chat/ {
    proxy_pass http://127.0.0.1:8770/;
    proxy_http_version 1.1;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_buffering off;
    proxy_cache off;
    proxy_read_timeout 120s;
}

Systemd

sudo systemctl restart wiki-vector-chat
sudo systemctl status wiki-vector-chat

API Endpoints

Method Path Description
POST /chat/message Main chat (SSE stream)
POST /chat/tunnel Server-side token chat
POST /chat/save-to-wiki Save Q&A to wiki KB
GET /providers List all providers
GET /providers/presets Built-in presets
POST /providers/save Save/edit custom provider
DELETE /providers/{id} Remove custom provider
GET /health Health check