feat: add knowledge management functionality with CRUD operations and database schema

- Implemented KnowledgeHandler for managing knowledge groups and items, including listing, creating, updating, and deleting operations.
- Added database migration scripts to create necessary tables for knowledge management, including knowledge_groups, knowledge_items, knowledge_parse_tasks, and knowledge_chunks_meta.
- Introduced prompt_rule_knowledge_groups table to associate prompt rules with knowledge groups.
This commit is contained in:
2026-04-05 17:14:13 +08:00
parent 134dd063c3
commit 446f865cdf
62 changed files with 9503 additions and 2664 deletions
+11 -1
View File
@@ -16,10 +16,12 @@ import (
"github.com/geo-platform/tenant-api/internal/shared/config"
"github.com/geo-platform/tenant-api/internal/shared/llm"
"github.com/geo-platform/tenant-api/internal/shared/middleware"
"github.com/geo-platform/tenant-api/internal/shared/objectstorage"
"github.com/geo-platform/tenant-api/internal/shared/observability"
"github.com/geo-platform/tenant-api/internal/shared/repository/postgres"
"github.com/geo-platform/tenant-api/internal/shared/repository/redis"
"github.com/geo-platform/tenant-api/internal/shared/response"
"github.com/geo-platform/tenant-api/internal/shared/retrieval"
"github.com/geo-platform/tenant-api/internal/shared/stream"
)
@@ -32,6 +34,9 @@ type App struct {
JWT *auth.Manager
Sessions *auth.SessionStore
LLM llm.Client
RetrievalProvider retrieval.Provider
VectorStore retrieval.VectorStore
ObjectStorage objectstorage.Client
AuditLogs *auditlog.AsyncWriter
GenerationStreams *stream.GenerationHub
Cache cache.Cache
@@ -64,6 +69,9 @@ func New(configPath string) (*App, error) {
jwtMgr := auth.NewManager(cfg.JWT.Secret, cfg.JWT.AccessTTL, cfg.JWT.RefreshTTL)
sessions := auth.NewSessionStore(rdb)
llmClient := llm.New(cfg.LLM)
retrievalProvider := retrieval.NewProvider(cfg.Retrieval, logger)
vectorStore := retrieval.NewQdrantStore(cfg.Qdrant, logger)
objectStorageClient := objectstorage.New(cfg.ObjectStorage, logger)
auditLogs := auditlog.NewAsyncWriter(pool, logger)
generationStreams := stream.NewGenerationHub()
appCache := cache.New(cfg.Cache.Driver, rdb)
@@ -76,7 +84,6 @@ func New(configPath string) (*App, error) {
engine.Use(
middleware.Recovery(logger),
middleware.RequestID(),
middleware.Logger(logger),
middleware.CORS(),
)
@@ -104,6 +111,9 @@ func New(configPath string) (*App, error) {
JWT: jwtMgr,
Sessions: sessions,
LLM: llmClient,
RetrievalProvider: retrievalProvider,
VectorStore: vectorStore,
ObjectStorage: objectStorageClient,
AuditLogs: auditLogs,
GenerationStreams: generationStreams,
Cache: appCache,