From d3e649ebfe10965cd71cc749d8f0c5acc676bdc0 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 12 Aug 2025 17:31:38 +0800 Subject: [PATCH] Add default collection and document model settings in Config struct - Introduced default values for CollectionModel and DocumentModel in the Config struct to ensure proper initialization. - Updated UnmarshalJSON method to set these defaults if not explicitly configured, enhancing the robustness of the configuration handling. --- kb/types/config.go | 10 ++++++++++ kb/types/types.go | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/kb/types/config.go b/kb/types/config.go index 97a4dcf8..c27fd92d 100644 --- a/kb/types/config.go +++ b/kb/types/config.go @@ -323,6 +323,16 @@ func (c *Config) UnmarshalJSON(data []byte) error { c.Uploader = "__yao.attachment" } + // Set default collection model if not configured + if c.CollectionModel == "" { + c.CollectionModel = "__yao.kb.collection" + } + + // Set default document model if not configured + if c.DocumentModel == "" { + c.DocumentModel = "__yao.kb.document" + } + // Note: Features will be computed later after providers are loaded return nil } diff --git a/kb/types/types.go b/kb/types/types.go index 4011d2b4..6fe2e887 100644 --- a/kb/types/types.go +++ b/kb/types/types.go @@ -63,6 +63,12 @@ type Config struct { // KV store name (Optional with default value) Store string `json:"store,omitempty" yaml:"store,omitempty"` // Default: "__yao.kb.store" + // Bind Collection Model + CollectionModel string `json:"collection_model,omitempty" yaml:"collection_model,omitempty"` // Default: "__yao.kb.collection" + + // Bind Document Model + DocumentModel string `json:"document_model,omitempty" yaml:"document_model,omitempty"` // Default: "__yao.kb.document" + // PDF parser configuration (Optional) PDF *PDFConfig `json:"pdf,omitempty" yaml:"pdf,omitempty"`