From afe77233f9837b7ca84bdaf5a5bfb45c3d1b54d3 Mon Sep 17 00:00:00 2001 From: ValueOn AG Date: Mon, 16 Mar 2026 15:24:20 +0100 Subject: [PATCH] fixed content mapping --- .../services/serviceAgent/mainServiceAgent.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/serviceCenter/services/serviceAgent/mainServiceAgent.py b/modules/serviceCenter/services/serviceAgent/mainServiceAgent.py index cfa28f73..77e65d21 100644 --- a/modules/serviceCenter/services/serviceAgent/mainServiceAgent.py +++ b/modules/serviceCenter/services/serviceAgent/mainServiceAgent.py @@ -339,7 +339,7 @@ def _registerCoreTools(registry: ToolRegistry, services): chunks = knowledgeService._knowledgeDb.getContentChunks(fileId) textChunks = [ c for c in (chunks or []) - if c.get("contentType") == "text" and c.get("data") + if c.get("contentType") != "image" and c.get("data") ] if textChunks: assembled = "\n\n".join(c["data"] for c in textChunks) @@ -389,7 +389,8 @@ def _registerCoreTools(registry: ToolRegistry, services): contentObjects = [] for part in extracted.parts: - ct = "image" if part.typeGroup == "image" else ("text" if part.typeGroup == "text" else "other") + tg = (part.typeGroup or "").lower() + ct = "image" if tg == "image" else "text" if not part.data or not part.data.strip(): continue contentObjects.append({ @@ -414,7 +415,7 @@ def _registerCoreTools(registry: ToolRegistry, services): except Exception: pass - textParts = [o["data"] for o in contentObjects if o["contentType"] == "text"] + textParts = [o["data"] for o in contentObjects if o["contentType"] != "image"] if textParts: joined = "\n\n".join(textParts) if len(joined) > _MAX_TOOL_RESULT_CHARS: @@ -427,7 +428,7 @@ def _registerCoreTools(registry: ToolRegistry, services): return ToolResult( toolCallId="", toolName="readFile", success=True, data=f"[Extracted {len(contentObjects)} content objects from '{fileName}' " - f"({imgCount} images, 0 text). " + f"({imgCount} images, no readable text). " f"Use describeImage(fileId='{fileId}') to analyze visual content.]", ) except Exception as extractErr: @@ -1252,7 +1253,7 @@ def _registerCoreTools(registry: ToolRegistry, services): if not objects: return ToolResult(toolCallId="", toolName="summarizeContent", success=True, data="No content found to summarize.") - textParts = [obj.get("data", "") for obj in objects if obj.get("contentType") == "text"] + textParts = [obj.get("data", "") for obj in objects if obj.get("contentType") != "image"] combinedText = "\n\n".join(textParts)[:6000] aiService = services.ai @@ -1383,7 +1384,8 @@ def _registerCoreTools(registry: ToolRegistry, services): contentObjects = [] for part in extracted.parts: - ct = "image" if part.typeGroup == "image" else ("text" if part.typeGroup == "text" else "other") + tg = (part.typeGroup or "").lower() + ct = "image" if tg == "image" else "text" if not part.data or not part.data.strip(): continue contentObjects.append({