感知meta_data字段BUG修复
This commit is contained in:
@@ -43,7 +43,7 @@ class PerceptualMemoryItem(BaseModel):
|
|||||||
file_name: str = Field(..., description="File name")
|
file_name: str = Field(..., description="File name")
|
||||||
file_ext: str = Field(..., description="File extension")
|
file_ext: str = Field(..., description="File extension")
|
||||||
summary: Optional[str] = Field(None, description="summary")
|
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")
|
created_time: int = Field(..., description="create time")
|
||||||
|
|
||||||
topic: str = Field(..., description="topic")
|
topic: str = Field(..., description="topic")
|
||||||
|
|||||||
@@ -137,8 +137,19 @@ class MemoryPerceptualService:
|
|||||||
memory_items = []
|
memory_items = []
|
||||||
for memory in memories:
|
for memory in memories:
|
||||||
meta_data = memory.meta_data or {}
|
meta_data = memory.meta_data or {}
|
||||||
content = meta_data.get("content")
|
content = meta_data.get("content", {})
|
||||||
content = Content(**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(
|
memory_item = PerceptualMemoryItem(
|
||||||
id=memory.id,
|
id=memory.id,
|
||||||
perceptual_type=PerceptualType(memory.perceptual_type),
|
perceptual_type=PerceptualType(memory.perceptual_type),
|
||||||
@@ -146,9 +157,10 @@ class MemoryPerceptualService:
|
|||||||
file_name=memory.file_name,
|
file_name=memory.file_name,
|
||||||
file_ext=memory.file_ext,
|
file_ext=memory.file_ext,
|
||||||
summary=memory.summary,
|
summary=memory.summary,
|
||||||
topic=content.topic,
|
meta_data=meta_data,
|
||||||
domain=content.domain,
|
topic=topic,
|
||||||
keywords=content.keywords,
|
domain=domain,
|
||||||
|
keywords=keywords,
|
||||||
created_time=int(memory.created_time.timestamp()*1000),
|
created_time=int(memory.created_time.timestamp()*1000),
|
||||||
storage_service=FileStorageService(memory.storage_service),
|
storage_service=FileStorageService(memory.storage_service),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user