feat(client): enhance knowledge file upload with process configuration support

- Updated the `CreateKnowledgeFromFile` function to accept an optional `processConfig` parameter for per-upload parse configuration overrides.
- Introduced the `KnowledgeProcessOverrides` type to define various parsing settings, including parser engine rules and chunking configurations.
- Modified the API client and related components to handle the new process configuration, improving flexibility in knowledge file uploads.
- Updated documentation and API specifications to reflect the new `process_config` parameter in the upload process.
- Added a new `UploadConfirmHost` component to facilitate user confirmation for uploads, integrating with the updated upload logic.
- Enhanced user experience by providing detailed configuration options during the upload process.
This commit is contained in:
wizardchen
2026-06-09 17:49:39 +08:00
committed by lyingbug
parent 589d2a6e52
commit ed9e780c8c
41 changed files with 3546 additions and 596 deletions
+20 -8
View File
@@ -290,10 +290,22 @@ func (s *ChunkExtractService) Handle(ctx context.Context, t *asynq.Task) error {
handleErr = err
return err
}
if kb.ExtractConfig == nil {
logger.Warnf(ctx, "failed to get extract config")
graphOut["skipped"] = "no_extract_config"
return err
var processOverrides *types.KnowledgeProcessOverrides
knowledgeID := p.KnowledgeID
if knowledgeID == "" {
knowledgeID = chunk.KnowledgeID
}
if knowledgeID != "" && s.knowledgeRepo != nil {
if k, kerr := s.knowledgeRepo.GetKnowledgeByIDOnly(ctx, knowledgeID); kerr == nil && k != nil {
processOverrides, _ = k.ProcessOverrides()
}
}
extractCfg := ResolveProcessConfig(kb, processOverrides).ExtractConfig
if !extractCfg.Enabled {
logger.Warnf(ctx, "extract config not enabled")
graphOut["skipped"] = "extract_disabled"
return nil
}
chatModel, err := s.modelService.GetChatModel(ctx, p.ModelID)
@@ -305,12 +317,12 @@ func (s *ChunkExtractService) Handle(ctx context.Context, t *asynq.Task) error {
template := &types.PromptTemplateStructured{
Description: s.template.Description,
Tags: kb.ExtractConfig.Tags,
Tags: extractCfg.Tags,
Examples: []types.GraphData{
{
Text: kb.ExtractConfig.Text,
Node: kb.ExtractConfig.Nodes,
Relation: kb.ExtractConfig.Relations,
Text: extractCfg.Text,
Node: extractCfg.Nodes,
Relation: extractCfg.Relations,
},
},
}