router: enforce direct image inputs for plant tools and inject runtime image_data
This commit is contained in:
@@ -2007,6 +2007,19 @@ async def agent_infer(agent_id: str, request: InferRequest):
|
||||
tool_args = {"params": {"count": 3, "timezone": "Europe/Kyiv"}}
|
||||
logger.info("🛠️ oneok: auto-filled schedule_propose_slots.params")
|
||||
|
||||
# Plant tools: inject runtime image payload from current request to avoid
|
||||
# hallucinated page URLs (e.g. t.me/<chat>/<msg>) that are not direct images.
|
||||
if tool_name in {"nature_id_identify", "plantnet_lookup"}:
|
||||
if not isinstance(tool_args, dict):
|
||||
tool_args = {}
|
||||
runtime_image_data = None
|
||||
if isinstance(request.images, list) and request.images:
|
||||
first_image = request.images[0]
|
||||
if isinstance(first_image, str) and first_image.startswith("data:image/") and ";base64," in first_image:
|
||||
runtime_image_data = first_image
|
||||
if runtime_image_data:
|
||||
tool_args["_runtime_image_data"] = runtime_image_data
|
||||
|
||||
result = await tool_manager.execute_tool(
|
||||
tool_name,
|
||||
tool_args,
|
||||
|
||||
Reference in New Issue
Block a user