fix(perceptual): prevent errors when writing unsupported modalities
This commit is contained in:
@@ -354,6 +354,8 @@ class MemoryAgentService:
|
|||||||
memory_config=memory_config,
|
memory_config=memory_config,
|
||||||
file=FileInput(**file)
|
file=FileInput(**file)
|
||||||
)
|
)
|
||||||
|
if file_object is None:
|
||||||
|
continue
|
||||||
message["file_content"].append((file_object, file["type"]))
|
message["file_content"].append((file_object, file["type"]))
|
||||||
|
|
||||||
message_text = "\n".join([f"{msg['role']}: {msg['content']}" for msg in messages])
|
message_text = "\n".join([f"{msg['role']}: {msg['content']}" for msg in messages])
|
||||||
|
|||||||
@@ -131,7 +131,6 @@ class MemoryAPIService:
|
|||||||
message: str,
|
message: str,
|
||||||
config_id: str,
|
config_id: str,
|
||||||
storage_type: str = "neo4j",
|
storage_type: str = "neo4j",
|
||||||
files: Optional[list]=None,
|
|
||||||
user_rag_memory_id: Optional[str] = None,
|
user_rag_memory_id: Optional[str] = None,
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Write memory with validation.
|
"""Write memory with validation.
|
||||||
@@ -154,8 +153,6 @@ class MemoryAPIService:
|
|||||||
ResourceNotFoundException: If end_user not found
|
ResourceNotFoundException: If end_user not found
|
||||||
BusinessException: If end_user not in authorized workspace or write fails
|
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}")
|
logger.info(f"Writing memory for end_user: {end_user_id}, workspace: {workspace_id}")
|
||||||
|
|
||||||
# Validate end_user exists and belongs to workspace
|
# Validate end_user exists and belongs to workspace
|
||||||
@@ -175,7 +172,6 @@ class MemoryAPIService:
|
|||||||
db=self.db,
|
db=self.db,
|
||||||
storage_type=storage_type,
|
storage_type=storage_type,
|
||||||
user_rag_memory_id=user_rag_memory_id or "",
|
user_rag_memory_id=user_rag_memory_id or "",
|
||||||
files=files
|
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info(f"Memory write successful for end_user: {end_user_id}")
|
logger.info(f"Memory write successful for end_user: {end_user_id}")
|
||||||
|
|||||||
@@ -277,8 +277,10 @@ class MemoryPerceptualService:
|
|||||||
file_message = await multimodel_service.process_files(
|
file_message = await multimodel_service.process_files(
|
||||||
files=[file]
|
files=[file]
|
||||||
)
|
)
|
||||||
if file_message:
|
if not file_message:
|
||||||
file_message = file_message[0]
|
logger.warning(f"Unsupport file type {file}, model capability: {model_config.capability}")
|
||||||
|
return None
|
||||||
|
file_message = file_message[0]
|
||||||
try:
|
try:
|
||||||
prompt_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'prompt')
|
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:
|
with open(os.path.join(prompt_path, 'perceptual_summary_system.jinja2'), 'r', encoding='utf-8') as f:
|
||||||
|
|||||||
Reference in New Issue
Block a user