From d653d2a51d10ac77513e6164e3a8e3c508c72ac0 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 6 Aug 2025 10:08:19 +0800 Subject: [PATCH] Add uploader configuration and default value in Config - Introduced Uploader field in the Config struct to allow optional file uploader configuration. - Implemented logic to set a default uploader value if not explicitly configured during JSON unmarshalling. --- kb/types/config.go | 6 ++++- kb/types/types.go | 3 +++ widgets/app/app.go | 65 ++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 71 insertions(+), 3 deletions(-) diff --git a/kb/types/config.go b/kb/types/config.go index c141a207..51b86d7a 100644 --- a/kb/types/config.go +++ b/kb/types/config.go @@ -307,9 +307,13 @@ func (c *Config) UnmarshalJSON(data []byte) error { return err } + // Set default uploader if not configured + if c.Uploader == "" { + c.Uploader = "__yao.attachment" + } + // Compute features after parsing and resolving env vars c.Features = c.ComputeFeatures() - return nil } diff --git a/kb/types/types.go b/kb/types/types.go index 3205830c..250e5acc 100644 --- a/kb/types/types.go +++ b/kb/types/types.go @@ -69,6 +69,9 @@ type Config struct { // FFmpeg configuration (Optional) FFmpeg *FFmpegConfig `json:"ffmpeg,omitempty" yaml:"ffmpeg"` + // File uploader configuration (Optional) + Uploader string `json:"uploader,omitempty" yaml:"uploader"` // Default: "__yao.attachment" + // Concurrency limits for task processing (Optional) Limits *LimitsConfig `json:"limits,omitempty" yaml:"limits"` diff --git a/widgets/app/app.go b/widgets/app/app.go index de1e3f9a..47380003 100644 --- a/widgets/app/app.go +++ b/widgets/app/app.go @@ -620,8 +620,69 @@ func processXgen(process *process.Process) interface{} { } } - // other providers - kbConfig = map[string]interface{}{"features": knowledgebase.Config.Features, "chunkings": chunkings, "embeddings": embeddings, "converters": converters} + extractors := []string{} + if knowledgebase.Config.Extractors != nil { + for _, extractor := range knowledgebase.Config.Extractors { + extractors = append(extractors, extractor.ID) + } + } + + fetchers := []string{} + if knowledgebase.Config.Fetchers != nil { + for _, fetcher := range knowledgebase.Config.Fetchers { + fetchers = append(fetchers, fetcher.ID) + } + } + + searchers := []string{} + if knowledgebase.Config.Searchers != nil { + for _, searcher := range knowledgebase.Config.Searchers { + searchers = append(searchers, searcher.ID) + } + } + + rerankers := []string{} + if knowledgebase.Config.Rerankers != nil { + for _, reranker := range knowledgebase.Config.Rerankers { + rerankers = append(rerankers, reranker.ID) + } + } + + votes := []string{} + if knowledgebase.Config.Votes != nil { + for _, vote := range knowledgebase.Config.Votes { + votes = append(votes, vote.ID) + } + } + + weights := []string{} + if knowledgebase.Config.Weights != nil { + for _, weight := range knowledgebase.Config.Weights { + weights = append(weights, weight.ID) + } + } + + scores := []string{} + if knowledgebase.Config.Scores != nil { + for _, score := range knowledgebase.Config.Scores { + scores = append(scores, score.ID) + } + } + + kbConfig = map[string]interface{}{ + "features": knowledgebase.Config.Features, + "chunkings": chunkings, + "embeddings": embeddings, + "converters": converters, + "extractors": extractors, + "fetchers": fetchers, + "searchers": searchers, + "rerankers": rerankers, + "votes": votes, + "weights": weights, + "scores": scores, + "uploader": knowledgebase.Config.Uploader, // Default: "__yao.attachment" + } } }