error feedback improvement
This commit is contained in:
@@ -493,6 +493,8 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
return "Error: distance is required"
|
||||
|
||||
result = client.move_towards(drone_id, distance, heading, dz)
|
||||
if result["status"] == "error":
|
||||
result["message"] += "(1) If the task is to move a certain distance in a specific direction but the path is blocked by an obstacle, first move a certain distance in another direction within the plane, and then proceed to move in the target direction. Do not alter the intended distance of movement in the target direction unless explicitly permitted by the task. You may invoke `get_obstacles` to observe the positions of obstacles. (2) If the obstacle’s height is lower than the maximum altitude the drone can reach, the drone may ascend to an altitude higher than the obstacle and fly over it. If the obstacle's height is 0, then it indicates no drone can fly over it (In this case you need to detour)."
|
||||
return json.dumps(result, indent=2)
|
||||
except json.JSONDecodeError as e:
|
||||
return f"Error parsing JSON input: {str(e)}. Expected format: {{\"drone_id\": \"drone-001\", \"distance\": 10.0}}"
|
||||
@@ -587,7 +589,7 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
return f"Error moving drone: {str(e)}"
|
||||
|
||||
@tool
|
||||
def optimal_way_to(input_json: str) -> str:
|
||||
def navigate_to(input_json: str) -> str:
|
||||
"""
|
||||
Plan an obstacle-avoiding path to the target position (x, y, z), automatically determining whether to detour or overfly:
|
||||
1. Detour around obstacles that cannot be overflown—such as those exceeding the drone’s maximum operational altitude or located within no-fly zones.
|
||||
@@ -908,9 +910,9 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
waypoint_move_result = client.move_to(drone_id, wp[0], wp[1], wp[2])
|
||||
if waypoint_move_result["status"] == "error":
|
||||
print(f"Error moving to waypoint {wp}: {waypoint_move_result['message']}")
|
||||
return f"Error executing path finding: {str(e)}\nPlease try finding a path dynamically. Do not repeatedly call optimal_way_to."
|
||||
return f"Error moving to waypoint {wp}: {waypoint_move_result['message']}\nPlease try finding a path dynamically. Do not repeatedly call optimal_way_to."
|
||||
|
||||
return json.dumps({"status": "success", "path": waypoints, "info": "You can call get_drone_status to check the drone's current status."})
|
||||
return json.dumps({"status": "success", "path": waypoints, "message": waypoint_move_result["message"] + "You can call get_drone_status to check the drone's current status."})
|
||||
|
||||
except Exception as e:
|
||||
return f"Error executing path finding: {str(e)}\nPlease try finding a path dynamically."
|
||||
@@ -929,7 +931,7 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
take_off,
|
||||
land,
|
||||
move_to,
|
||||
optimal_way_to,
|
||||
navigate_to,
|
||||
move_towards,
|
||||
change_altitude,
|
||||
hover,
|
||||
|
||||
Reference in New Issue
Block a user