感知meta_data字段BUG修复

This commit is contained in:
lixinyue
2026-01-26 11:06:49 +08:00
parent 94cced8323
commit 9de6b4f151
2 changed files with 18 additions and 6 deletions

View File

@@ -43,7 +43,7 @@ class PerceptualMemoryItem(BaseModel):
file_name: str = Field(..., description="File name")
file_ext: str = Field(..., description="File extension")
summary: Optional[str] = Field(None, description="summary")
meta_data: str = Field(...,description="")
meta_data: Optional[dict] = Field(None, description="Metadata information")
created_time: int = Field(..., description="create time")
topic: str = Field(..., description="topic")

View File

@@ -137,8 +137,19 @@ class MemoryPerceptualService:
memory_items = []
for memory in memories:
meta_data = memory.meta_data or {}
content = meta_data.get("content")
content = Content(**content)
content = meta_data.get("content", {})
# 安全地提取 content 字段,提供默认值
if content:
content_obj = Content(**content)
topic = content_obj.topic
domain = content_obj.domain
keywords = content_obj.keywords
else:
topic = "Unknown"
domain = "Unknown"
keywords = []
memory_item = PerceptualMemoryItem(
id=memory.id,
perceptual_type=PerceptualType(memory.perceptual_type),
@@ -146,9 +157,10 @@ class MemoryPerceptualService:
file_name=memory.file_name,
file_ext=memory.file_ext,
summary=memory.summary,
topic=content.topic,
domain=content.domain,
keywords=content.keywords,
meta_data=meta_data,
topic=topic,
domain=domain,
keywords=keywords,
created_time=int(memory.created_time.timestamp()*1000),
storage_service=FileStorageService(memory.storage_service),
)