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.
This commit is contained in:
parent
1119b99c0d
commit
d653d2a51d
3 changed files with 71 additions and 3 deletions
|
|
@ -307,9 +307,13 @@ func (c *Config) UnmarshalJSON(data []byte) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set default uploader if not configured
|
||||||
|
if c.Uploader == "" {
|
||||||
|
c.Uploader = "__yao.attachment"
|
||||||
|
}
|
||||||
|
|
||||||
// Compute features after parsing and resolving env vars
|
// Compute features after parsing and resolving env vars
|
||||||
c.Features = c.ComputeFeatures()
|
c.Features = c.ComputeFeatures()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,9 @@ type Config struct {
|
||||||
// FFmpeg configuration (Optional)
|
// FFmpeg configuration (Optional)
|
||||||
FFmpeg *FFmpegConfig `json:"ffmpeg,omitempty" yaml:"ffmpeg"`
|
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)
|
// Concurrency limits for task processing (Optional)
|
||||||
Limits *LimitsConfig `json:"limits,omitempty" yaml:"limits"`
|
Limits *LimitsConfig `json:"limits,omitempty" yaml:"limits"`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -620,8 +620,69 @@ func processXgen(process *process.Process) interface{} {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// other providers
|
extractors := []string{}
|
||||||
kbConfig = map[string]interface{}{"features": knowledgebase.Config.Features, "chunkings": chunkings, "embeddings": embeddings, "converters": converters}
|
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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue