feat(handler): add chunker preview endpoint for debugging
Adds POST /api/v1/chunker/preview — a read-only endpoint that runs the adaptive chunker on supplied text and returns the chunks plus diagnostic info (which tier won, which were rejected and why, the DocProfile that the selector saw). Used by the upcoming KB editor debug panel so users can experiment with chunking parameters without re-uploading documents. Backend pieces: - chunker.SplitWithDiagnostics(text, cfg) returns chunks plus a Diagnostics struct (SelectedTier, TierChain, Rejected). Split() now delegates here. - chunker.DocProfile gets JSON tags so it serializes cleanly. - handler.PreviewChunking caps input at 256k chars and chunks at 500 per response, computes a size-distribution summary, and never touches DB or embedding APIs. Auth: lives under the v1 group so the standard JWT middleware applies. https://claude.ai/code/session_01XADhx6mtu2ZYW3DE9Lun6k
This commit is contained in:
@@ -161,11 +161,18 @@ func NewRouter(params RouterParams) *gin.Engine {
|
||||
RegisterDataSourceRoutes(v1, params.DataSourceHandler)
|
||||
RegisterWeKnoraCloudRoutes(v1, params.WeKnoraCloudHandler)
|
||||
RegisterWikiPageRoutes(v1, params.WikiPageHandler)
|
||||
RegisterChunkerDebugRoutes(v1)
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// RegisterChunkerDebugRoutes wires the read-only chunker preview endpoint
|
||||
// used by the KB editor's debug panel. Stateless — uses no service deps.
|
||||
func RegisterChunkerDebugRoutes(r *gin.RouterGroup) {
|
||||
r.POST("/chunker/preview", handler.PreviewChunking)
|
||||
}
|
||||
|
||||
// RegisterChunkRoutes 注册分块相关的路由
|
||||
func RegisterChunkRoutes(r *gin.RouterGroup, handler *handler.ChunkHandler) {
|
||||
// 分块路由组
|
||||
|
||||
Reference in New Issue
Block a user