e147209e77
This commit introduces the complete wiki feature for WeKnora, enabling AI-powered wiki page generation and management. The implementation includes: **Backend Changes:** - Wiki data model: WikiPage type with support for multiple page types (Summary, Entity, Concept, Index, Log) - Database schema: wiki_pages table with full migration support - WikiPageService: CRUD operations and page management - WikiPageRepository: GORM-based persistence layer - Wiki ingest pipeline: Automated generation of wiki pages from knowledge documents * Summary page generation using LLM * Entity and concept extraction in a single LLM call * Synthesis opportunity detection * Index page rebuilding * Log page maintenance - Wiki boost feature: Enhance chat retrieval with wiki context - Wiki linting: Maintenance and validation utilities - Agent wiki tools: Enable agents to query and interact with wiki pages - Wiki prompts: Comprehensive LLM prompt templates for all wiki generation tasks - Language support: Reuse existing middleware language infrastructure for LLM prompts **Frontend Changes:** - Wiki browser UI: View all wiki pages with filtering and search - Wiki API client: Knowledge base wiki management endpoints - Knowledge base editor: Configure wiki settings (language, auto-ingest, synthesis model) - i18n updates: Support for English, Korean, Russian, and Chinese interfaces **Configuration:** - Container DI: Wire up all wiki services - Router: Register wiki API endpoints - Task handling: Support async wiki ingest tasks **Testing:** - Unit tests for wiki page types - Service layer tests - Endpoint tests for wiki operations - Integration tests with LLM mocking **Documentation:** - Language refactoring analysis and guides - Implementation completion reports - Quick reference guides for developers **Key Features:** ✅ LLM-powered wiki page generation from documents ✅ Multi-language support (9+ languages) ✅ Automatic extraction of entities and concepts ✅ Synthesis opportunity detection ✅ Index and log page maintenance ✅ Progressive wiki building across multiple documents ✅ Agent-based wiki interaction ✅ Chat retrieval enhancement with wiki context ✅ Full frontend UI for wiki browsing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
107 lines
2.8 KiB
TypeScript
107 lines
2.8 KiB
TypeScript
import { get, post, put, del } from "../../utils/request";
|
|
|
|
// Wiki Page Types
|
|
export interface WikiPage {
|
|
id: string;
|
|
tenant_id: number;
|
|
knowledge_base_id: string;
|
|
slug: string;
|
|
title: string;
|
|
page_type: string;
|
|
status: string;
|
|
content: string;
|
|
summary: string;
|
|
source_refs: string[];
|
|
in_links: string[];
|
|
out_links: string[];
|
|
page_metadata: Record<string, any>;
|
|
version: number;
|
|
created_at: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export interface WikiPageListResponse {
|
|
pages: WikiPage[];
|
|
total: number;
|
|
page: number;
|
|
page_size: number;
|
|
total_pages: number;
|
|
}
|
|
|
|
export interface WikiGraphData {
|
|
nodes: { slug: string; title: string; page_type: string; link_count: number }[];
|
|
edges: { source: string; target: string }[];
|
|
}
|
|
|
|
export interface WikiStats {
|
|
total_pages: number;
|
|
pages_by_type: Record<string, number>;
|
|
total_links: number;
|
|
orphan_count: number;
|
|
recent_updates: WikiPage[];
|
|
}
|
|
|
|
// Wiki API Functions
|
|
export function listWikiPages(kbId: string, params?: {
|
|
page_type?: string;
|
|
status?: string;
|
|
query?: string;
|
|
page?: number;
|
|
page_size?: number;
|
|
sort_by?: string;
|
|
sort_order?: string;
|
|
}) {
|
|
const query = new URLSearchParams();
|
|
if (params) {
|
|
Object.entries(params).forEach(([key, value]) => {
|
|
if (value !== undefined && value !== '') {
|
|
query.set(key, String(value));
|
|
}
|
|
});
|
|
}
|
|
const qs = query.toString();
|
|
return get(`/api/v1/knowledgebase/${kbId}/wiki/pages${qs ? '?' + qs : ''}`);
|
|
}
|
|
|
|
export function createWikiPage(kbId: string, data: Partial<WikiPage>) {
|
|
return post(`/api/v1/knowledgebase/${kbId}/wiki/pages`, data);
|
|
}
|
|
|
|
export function getWikiPage(kbId: string, slug: string) {
|
|
return get(`/api/v1/knowledgebase/${kbId}/wiki/pages/${slug}`);
|
|
}
|
|
|
|
export function updateWikiPage(kbId: string, slug: string, data: Partial<WikiPage>) {
|
|
return put(`/api/v1/knowledgebase/${kbId}/wiki/pages/${slug}`, data);
|
|
}
|
|
|
|
export function deleteWikiPage(kbId: string, slug: string) {
|
|
return del(`/api/v1/knowledgebase/${kbId}/wiki/pages/${slug}`);
|
|
}
|
|
|
|
export function getWikiIndex(kbId: string) {
|
|
return get(`/api/v1/knowledgebase/${kbId}/wiki/index`);
|
|
}
|
|
|
|
export function getWikiLog(kbId: string) {
|
|
return get(`/api/v1/knowledgebase/${kbId}/wiki/log`);
|
|
}
|
|
|
|
export function getWikiGraph(kbId: string) {
|
|
return get(`/api/v1/knowledgebase/${kbId}/wiki/graph`);
|
|
}
|
|
|
|
export function getWikiStats(kbId: string) {
|
|
return get(`/api/v1/knowledgebase/${kbId}/wiki/stats`);
|
|
}
|
|
|
|
export function searchWikiPages(kbId: string, q: string, limit?: number) {
|
|
const params = new URLSearchParams({ q });
|
|
if (limit) params.set('limit', String(limit));
|
|
return get(`/api/v1/knowledgebase/${kbId}/wiki/search?${params.toString()}`);
|
|
}
|
|
|
|
export function rebuildWikiLinks(kbId: string) {
|
|
return post(`/api/v1/knowledgebase/${kbId}/wiki/rebuild-links`, {});
|
|
}
|