File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
src/memos/memories/textual Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 11"""Defines memory item types for textual memory."""
22
33import json
4+ import logging
45import uuid
56
67from datetime import datetime
@@ -123,6 +124,25 @@ class TreeNodeTextualMemoryMetadata(TextualMemoryMetadata):
123124 def coerce_sources (cls , v ):
124125 if v is None :
125126 return v
127+ # Handle string representation of sources (e.g., from PostgreSQL array or malformed data)
128+ if isinstance (v , str ):
129+ logging .info (f"[coerce_sources] v: { v } type: { type (v )} " )
130+ # If it's a string that looks like a list representation, try to parse it
131+ # This handles cases like: "[uuid1, uuid2, uuid3]" or "[item1, item2]"
132+ v_stripped = v .strip ()
133+ if v_stripped .startswith ("[" ) and v_stripped .endswith ("]" ):
134+ # Remove brackets and split by comma
135+ content = v_stripped [1 :- 1 ].strip ()
136+ if content :
137+ # Split by comma and clean up each item
138+ items = [item .strip () for item in content .split ("," )]
139+ # Convert to list of strings
140+ v = items
141+ else :
142+ v = []
143+ else :
144+ # Single string, wrap in list
145+ v = [v ]
126146 if not isinstance (v , list ):
127147 raise TypeError ("sources must be a list" )
128148 out = []
You can’t perform that action at this time.
0 commit comments