Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/memos/memories/textual/item.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Defines memory item types for textual memory."""

import json
import logging
import uuid

from datetime import datetime
Expand Down Expand Up @@ -123,6 +124,25 @@ class TreeNodeTextualMemoryMetadata(TextualMemoryMetadata):
def coerce_sources(cls, v):
if v is None:
return v
# Handle string representation of sources (e.g., from PostgreSQL array or malformed data)
if isinstance(v, str):
logging.info(f"[coerce_sources] v: {v} type: {type(v)}")
# If it's a string that looks like a list representation, try to parse it
# This handles cases like: "[uuid1, uuid2, uuid3]" or "[item1, item2]"
v_stripped = v.strip()
if v_stripped.startswith("[") and v_stripped.endswith("]"):
# Remove brackets and split by comma
content = v_stripped[1:-1].strip()
if content:
# Split by comma and clean up each item
items = [item.strip() for item in content.split(",")]
# Convert to list of strings
v = items
else:
v = []
else:
# Single string, wrap in list
v = [v]
if not isinstance(v, list):
raise TypeError("sources must be a list")
out = []
Expand Down