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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user