mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-08-10 12:51:11 +03:00
Don't require object type for parameter in categorized names tool
This commit is contained in:
+4
-16
@@ -542,9 +542,7 @@ async def execute_tool(
|
|||||||
|
|
||||||
if tool_name == "get_categorized_object_names":
|
if tool_name == "get_categorized_object_names":
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content=_execute_get_categorized_object_names(
|
content=_execute_get_categorized_object_names(request, allowed_cameras)
|
||||||
request, arguments, allowed_cameras
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if tool_name == "find_similar_objects":
|
if tool_name == "find_similar_objects":
|
||||||
@@ -727,22 +725,14 @@ async def _execute_set_camera_state(
|
|||||||
|
|
||||||
def _execute_get_categorized_object_names(
|
def _execute_get_categorized_object_names(
|
||||||
request: Request,
|
request: Request,
|
||||||
arguments: dict[str, Any],
|
|
||||||
allowed_cameras: list[str],
|
allowed_cameras: list[str],
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
object_type = arguments.get("object_type") or None
|
names = get_categorized_object_names(request.app.frigate_config, allowed_cameras)
|
||||||
names = get_categorized_object_names(
|
|
||||||
request.app.frigate_config, allowed_cameras, object_type
|
|
||||||
)
|
|
||||||
|
|
||||||
if not names:
|
if not names:
|
||||||
return {
|
return {
|
||||||
"names": {},
|
"names": {},
|
||||||
"message": (
|
"message": "No names configured; search by label or semantic_query.",
|
||||||
f"No names configured for '{object_type}'."
|
|
||||||
if object_type
|
|
||||||
else "No names configured; search by label or semantic_query."
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {"names": names}
|
return {"names": names}
|
||||||
@@ -773,9 +763,7 @@ async def _execute_tool_internal(
|
|||||||
logger.warning(f"Failed to extract tool result: {e}")
|
logger.warning(f"Failed to extract tool result: {e}")
|
||||||
return {"error": "Failed to parse tool result"}
|
return {"error": "Failed to parse tool result"}
|
||||||
elif tool_name == "get_categorized_object_names":
|
elif tool_name == "get_categorized_object_names":
|
||||||
return _execute_get_categorized_object_names(
|
return _execute_get_categorized_object_names(request, allowed_cameras)
|
||||||
request, arguments, allowed_cameras
|
|
||||||
)
|
|
||||||
elif tool_name == "find_similar_objects":
|
elif tool_name == "find_similar_objects":
|
||||||
return await _execute_find_similar_objects(request, arguments, allowed_cameras)
|
return await _execute_find_similar_objects(request, arguments, allowed_cameras)
|
||||||
elif tool_name == "set_camera_state":
|
elif tool_name == "set_camera_state":
|
||||||
|
|||||||
@@ -354,16 +354,12 @@ def get_tool_definitions(
|
|||||||
"description": (
|
"description": (
|
||||||
"Every name that can be attached as a sub_label, grouped by object "
|
"Every name that can be attached as a sub_label, grouped by object "
|
||||||
"type: recognized faces, named license plates, classification "
|
"type: recognized faces, named license plates, classification "
|
||||||
"categories, and delivery logos."
|
"categories, and delivery logos. Takes no arguments and always "
|
||||||
|
"returns the complete map."
|
||||||
),
|
),
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {},
|
||||||
"object_type": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "Optional object label (e.g. 'person', 'car'). Omit for all.",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": [],
|
"required": [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user