feat: standardize storage configuration and enhance backward compatibility

- Updated the `KnowledgeBase` struct to rename `cos_config` to `storage_config` for consistency across the application.
- Implemented a custom `UnmarshalJSON` method to maintain backward compatibility with legacy responses that still use `cos_config`.
- Modified various frontend components to reflect the new `storage_config` naming, ensuring seamless integration with the updated backend structure.
- Enhanced Dockerfiles and service configurations to support the new storage engine setup.

This update improves the clarity of storage configurations and ensures compatibility with existing data structures.
This commit is contained in:
wizardchen
2026-02-28 17:39:59 +08:00
committed by lyingbug
parent 31755726a0
commit 393ebf9f92
13 changed files with 168 additions and 25 deletions
+20 -1
View File
@@ -60,7 +60,7 @@ type KnowledgeBase struct {
// VLM config
VLMConfig VLMConfig `yaml:"vlm_config" json:"vlm_config" gorm:"type:json"`
// Storage config
StorageConfig StorageConfig `yaml:"cos_config" json:"cos_config" gorm:"column:cos_config;type:json"`
StorageConfig StorageConfig `yaml:"storage_config" json:"storage_config" gorm:"column:cos_config;type:json"`
// Extract config
ExtractConfig *ExtractConfig `yaml:"extract_config" json:"extract_config" gorm:"column:extract_config;type:json"`
// FAQConfig stores FAQ specific configuration such as indexing strategy
@@ -163,6 +163,25 @@ func (c *StorageConfig) Scan(value interface{}) error {
return json.Unmarshal(b, c)
}
// UnmarshalJSON keeps backward compatibility for legacy clients that still send
// `cos_config`, while standardizing the API field as `storage_config`.
func (kb *KnowledgeBase) UnmarshalJSON(data []byte) error {
type alias KnowledgeBase
aux := struct {
*alias
LegacyStorageConfig *StorageConfig `json:"cos_config"`
}{
alias: (*alias)(kb),
}
if err := json.Unmarshal(data, &aux); err != nil {
return err
}
if aux.LegacyStorageConfig != nil && kb.StorageConfig == (StorageConfig{}) {
kb.StorageConfig = *aux.LegacyStorageConfig
}
return nil
}
// ImageProcessingConfig represents the image processing configuration
type ImageProcessingConfig struct {
// Model ID