Skip to content

Commit 5cc044b

Browse files
committed
feat: add ids
1 parent 8b5f796 commit 5cc044b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/memos/mem_reader/read_multi_modal/file_content_parser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def parse_fast(
324324
# For file content parts, default to LongTermMemory
325325
# (since we don't have role information at this level)
326326
memory_type = "LongTermMemory"
327-
327+
file_ids = [file_id] if file_id else []
328328
# Create memory items for each chunk
329329
memory_items = []
330330
for chunk_idx, chunk_text in enumerate(content_chunks):
@@ -351,6 +351,7 @@ def parse_fast(
351351
confidence=0.99,
352352
type="fact",
353353
info=info_,
354+
file_ids=file_ids,
354355
),
355356
)
356357
memory_items.append(memory_item)
@@ -373,6 +374,7 @@ def parse_fast(
373374
confidence=0.99,
374375
type="fact",
375376
info=info_,
377+
file_ids=file_ids,
376378
),
377379
)
378380
memory_items.append(memory_item)
@@ -499,7 +501,7 @@ def parse_fine(
499501
session_id = info_.pop("session_id", "")
500502
if file_id:
501503
info_["file_id"] = file_id
502-
504+
file_ids = [file_id] if file_id else []
503505
# For file content parts, default to LongTermMemory
504506
memory_type = "LongTermMemory"
505507

@@ -536,6 +538,7 @@ def _make_memory_item(
536538
confidence=0.99,
537539
type="fact",
538540
info=info_,
541+
file_ids=file_ids,
539542
),
540543
)
541544

src/memos/memories/textual/item.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ class TreeNodeTextualMemoryMetadata(TextualMemoryMetadata):
133133
description="background of this node",
134134
)
135135

136+
file_ids: list[str] | None = Field(
137+
default_factory=list,
138+
description="The ids of the files associated with the memory.",
139+
)
140+
136141
@field_validator("sources", mode="before")
137142
@classmethod
138143
def coerce_sources(cls, v):

0 commit comments

Comments
 (0)