fix(perceptual): prevent errors when writing unsupported modalities

This commit is contained in:
Eternity
2026-03-24 14:30:07 +08:00
parent 89d188fbf3
commit de6e2f54d2
3 changed files with 6 additions and 6 deletions

View File

@@ -354,6 +354,8 @@ class MemoryAgentService:
memory_config=memory_config,
file=FileInput(**file)
)
if file_object is None:
continue
message["file_content"].append((file_object, file["type"]))
message_text = "\n".join([f"{msg['role']}: {msg['content']}" for msg in messages])

View File

@@ -131,7 +131,6 @@ class MemoryAPIService:
message: str,
config_id: str,
storage_type: str = "neo4j",
files: Optional[list]=None,
user_rag_memory_id: Optional[str] = None,
) -> Dict[str, Any]:
"""Write memory with validation.
@@ -154,8 +153,6 @@ class MemoryAPIService:
ResourceNotFoundException: If end_user not found
BusinessException: If end_user not in authorized workspace or write fails
"""
if files is None:
files = list()
logger.info(f"Writing memory for end_user: {end_user_id}, workspace: {workspace_id}")
# Validate end_user exists and belongs to workspace
@@ -175,7 +172,6 @@ class MemoryAPIService:
db=self.db,
storage_type=storage_type,
user_rag_memory_id=user_rag_memory_id or "",
files=files
)
logger.info(f"Memory write successful for end_user: {end_user_id}")

View File

@@ -277,8 +277,10 @@ class MemoryPerceptualService:
file_message = await multimodel_service.process_files(
files=[file]
)
if file_message:
file_message = file_message[0]
if not file_message:
logger.warning(f"Unsupport file type {file}, model capability: {model_config.capability}")
return None
file_message = file_message[0]
try:
prompt_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'prompt')
with open(os.path.join(prompt_path, 'perceptual_summary_system.jinja2'), 'r', encoding='utf-8') as f: