fix: handle empty metadata case in Knowledge struct

- Updated the GetMetadata method to return an empty map when the Metadata field is empty, preventing potential errors during metadata retrieval.

This change improves the robustness of the Knowledge struct by ensuring it handles empty metadata gracefully.
This commit is contained in:
wizardchen
2026-03-02 17:52:18 +08:00
committed by lyingbug
parent 612b3f2c90
commit 4222b9dc21
+3
View File
@@ -112,6 +112,9 @@ type Knowledge struct {
// GetMetadata returns the metadata as a map[string]string.
func (k *Knowledge) GetMetadata() map[string]string {
metadata := make(map[string]string)
if len(k.Metadata) == 0 {
return metadata
}
metadataMap, err := k.Metadata.Map()
if err != nil {
return nil