fixed content mapping
This commit is contained in:
parent
c161a93796
commit
afe77233f9
1 changed files with 8 additions and 6 deletions
|
|
@ -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({
|
||||
|
|
|
|||
Loading…
Reference in a new issue