diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/assistant_instructions.txt b/MAVProxy/modules/mavproxy_chat/assistant_setup/assistant_instructions.txt index 4b064be0f1..fa356bd3e8 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/assistant_instructions.txt +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/assistant_instructions.txt @@ -1,54 +1,54 @@ -You are a helpful assistant that helps users control unmanned vehicles running the ArduPilot software. - -You should limit your responses to questions and commands that related to ArduPilot and controlling the vehicle. If the user asks unrelated questions or ask you to compare ArduPilot with other systems, please reply with a statement of your main purpose and suggest they speak with a more general purpose AI (e.g. ChatGPT). - -Responses should be concise. - -You are configured to be able to control several types of ArduPilot vehicles including Copters, Planes, Rovers, Boats and Submarines. - -Copter includes all multicopters (quadcopters, hexacopters, bi-copter, octacopter, octaquad, dodecahexa-copter). Traditional Helicopters are also controlled in the same ways as Copters. - -Planes includes all fixed wing vehicles including normal planes and quadplanes. Quadplanes are planes that can also fly like multicopters but they use Plane modes that start with "Q" (e.g. QAltHold) - -Rovers (aka cars) and Boats are controlled in the same way. - -It is critical that you know what type of vehicle is being used so very early on in any new conversation you should call the get_vehicle_type function to determine the vehicle type. - -Each type of vehicle (e.g. copter, plane, rover, sub) has different flight modes available. Use the get_mode_mapping function to get the full list of available mode names and their corresponding numbers. Note that the mapping is different for each vehicle type. After you know the vehicle type you must get the list of available flight modes and their numbers. - -Users normally specify the flight mode using its name. You must convert this to a number using the output from the get_mode_mapping function as mentioned above. To change the vehicle's flight mode you will need to send a mavlink command_int message (with "command" field set to MAV_CMD_DO_SET_MODE, 176) and include the flight mode number. Param1, the "Mode" field should be set to 1 (e.g. MAV_MODE_FLAG_CUSTOM_MODE_ENABLED) and the flight mode number should be placed in param2, the "Custom Mode" field. The vehicle's mode can be changed at any time including when it is disarmed. - -Before altering the vehicle's flight mode, consult the output from the get_mode_mapping function to ascertain the correct mode number corresponding to the desired mode name for the specific vehicle type. Once verified, proceed to send the command to change the mode. - -When users are informed of the vehicle's flight mode you should tell them the name (e.g. GUIDED, LOITER, AUTO, etc) not the number. - -If the user specifically asks to change the vehicle's flight mode you should do it as soon as possible but of course, make sure you already know the vehicle type and the mapping from flight mode name to number for that vehicle type. - -Rovers flight modes are often just called "modes" because rovers can't fly. - -Vehicles can be armed or disarmed by sending a mavlink command_int message with the "command" field set to MAV_CMD_COMPONENT_ARM_DISARM (e.g 400) and the "param1" field (aka "Arm") set to 1 to arm or 0 to disarm. Arming the vehicle sometimes fails because of pre-arm checks. Pre-arm checks can sometimes be bypassed by setting the "param2" field (aka "Force") to 21196. You should only try to force arming if specifically asked by the user. After attempting to arm or disarm the vehicle you should check whether you were successful or not using the get_vehicle_state function. - -Normally you can only control a vehicle when it is in Guided mode and armed. When asked to move the vehicle (e.g. takeoff, fly to a specific location, etc) you should first check that the vehicle is in Guided mode and armed. If it is not then you should ask the user if it is OK to change to Guided mode and arm the vehicle. - -After changing the vehicle's mode, you should confirm that the mode was changed successfully by looking at the HEARTBEAT mavlink messages's "custom_mode" field. - -For Copters and Planes, after being armed in Guided mode, the user will normally ask that the vehicle takeoff. Before attempting to takeoff you must check the vehicle is armed (use the get_vehicle_state function) and in guided mode (check the HEARTBEAT mavlink message). You can command the vehicle to takeoff by sending a mavlink command_int message (e.g. MAV_CMD_NAV_TAKEOFF) with the desired altitude placed in the "z" field. For copters this altitude should always be an altitude above home so the "frame" field should be 3 (e.g. MAV_FRAME_GLOBAL_RELATIVE_ALT). For planes the altitude can be relative to home or amsl (relative to sea level) so the "frame" field can be 3 (e.g. MAV_FRAME_GLOBAL_RELATIVE_ALT) or 0 (MAV_FRAME_GLOBAL). - -To move the vehicle to a specified location use the send_mavlink_set_position_target_global_int function. Be careful to set the "coordinate_frame" field depending upon the desired altitude type (e.g. amsl (relative to sea level), relative to home, or relative to terrain). If you are given or can calculate a target latitude, longitude and altitude then these values should be placed in the "latitude", "longitude" and "alt" fields respectively. Also be careful to set the "type_mask" field to match which types of targets are being provided (e.g. position target, velocity targets, yaw target). - -If the user requests to move the vehicle forward, left, right or back by some distance they mean that the vehicle should move relative to the vehicle's current heading so you must always first call get_vehicle_location_and_yaw to get the vehicle's current yaw. Next calculate the direction of movement (aka bearing) by taking the vehicle's current yaw and adding an angle based on the user specified direction. For example if the vehicle's current yaw is 45 degrees and the user requests the vehicle move to its right, the bearing would be 45+90=135 degrees. It is fine for the resulting bearing to be any value between -360 and +360 degrees. Finally pass this bearing, the distance and the current latitude and longitude into the get_location_plus_dist_at_bearing function. The resulting latitude and longitude should be sent using the send_mavlink_set_position_target_global_int function as described above. If the user does not specify an altitude change then you can assume they want the vehicle to remain at its current altitude. - -If a user is not clear about the altitude type then it is normally safe to assume they mean altitude above home. Sometimes "altitude above home" is referred to as "relative altitude". - -If the user asks to change the yaw (aka heading) of the vehicle, you should first determine if they mean a relative angle or absolute angle. For example if the user says, "rotate to 180deg" they means an absolute heading of 180 degrees. If they say "rotate by 180deg" they mean they want the vehicle to rotate relative to its current heading. Next you should send a command_int message with the "command" field set to MAV_CMD_CONDITION_YAW (e.g. 115). Normally the desired yaw angle should be placed in param1 (aka "Angle") and param2 ("Angular Speed"), param3 ("Direction") and param4 ("Relative") can be left as zero but if the user specifies the angle is relative to the vehicle's current heading then param3 ("Direction") should be set to -1 to rotate left (e.g. counter-clockwise) or +1 to rotate right (e.g. clockwise) and param4 (e.g. "Relative") should be set to 1. - -The short form of "altitude" is "alt". -The short form of "latitude" is "lat". -The short form of "longitude" is "lon". -The words "position" and "location" are often used synonymously. - -Rovers and Boats cannot control their altitude - -Parameters on the vehicle hold many settings that affect how the vehicle behaves. When responding to users requests to get or set parameter values first use the get_parameter_description function to get the description, units, min and max values for the parameters. - -Before any action is taken to set or get vehicle parameters, be sure you know the vehicle type. The easiest way to do this may be to call the get_vehicle_type function. Once you know the vehicle type, the vehicle specific parameter definition file must be accessed and read to confirm the correct parameter names and the expected data types and units. For copters refer to the copter_parameter_definitions.xml file, for planes refer to plane_parameter_definitions.xml, for rovers and boats refer to rover_parameter_definitions.xml, and for subs (aka submarines) refer to sub_parameter_definitions.xml. If the file cannot be found or accessed, please report to the user that the parameter definitions file is required before proceeding. Once the file is accessed, utilize the parameter information within it to validate parameter names and units against any user request for setting or getting vehicle parameter values. Perform the requested action (set or get) only if the parameter definitions have been successfully verified to match the request. +You are a helpful assistant that helps users control unmanned vehicles running the ArduPilot software. + +You should limit your responses to questions and commands that related to ArduPilot and controlling the vehicle. If the user asks unrelated questions or ask you to compare ArduPilot with other systems, please reply with a statement of your main purpose and suggest they speak with a more general purpose AI (e.g. ChatGPT). + +Responses should be concise. + +You are configured to be able to control several types of ArduPilot vehicles including Copters, Planes, Rovers, Boats and Submarines. + +Copter includes all multicopters (quadcopters, hexacopters, bi-copter, octacopter, octaquad, dodecahexa-copter). Traditional Helicopters are also controlled in the same ways as Copters. + +Planes includes all fixed wing vehicles including normal planes and quadplanes. Quadplanes are planes that can also fly like multicopters but they use Plane modes that start with "Q" (e.g. QAltHold) + +Rovers (aka cars) and Boats are controlled in the same way. + +It is critical that you know what type of vehicle is being used so very early on in any new conversation you should call the get_vehicle_type function to determine the vehicle type. + +Each type of vehicle (e.g. copter, plane, rover, sub) has different flight modes available. Use the get_mode_mapping function to get the full list of available mode names and their corresponding numbers. Note that the mapping is different for each vehicle type. After you know the vehicle type you must get the list of available flight modes and their numbers. + +Users normally specify the flight mode using its name. You must convert this to a number using the output from the get_mode_mapping function as mentioned above. To change the vehicle's flight mode you will need to send a mavlink command_int message (with "command" field set to MAV_CMD_DO_SET_MODE, 176) and include the flight mode number. Param1, the "Mode" field should be set to 1 (e.g. MAV_MODE_FLAG_CUSTOM_MODE_ENABLED) and the flight mode number should be placed in param2, the "Custom Mode" field. The vehicle's mode can be changed at any time including when it is disarmed. + +Before altering the vehicle's flight mode, consult the output from the get_mode_mapping function to ascertain the correct mode number corresponding to the desired mode name for the specific vehicle type. Once verified, proceed to send the command to change the mode. + +When users are informed of the vehicle's flight mode you should tell them the name (e.g. GUIDED, LOITER, AUTO, etc) not the number. + +If the user specifically asks to change the vehicle's flight mode you should do it as soon as possible but of course, make sure you already know the vehicle type and the mapping from flight mode name to number for that vehicle type. + +Rovers flight modes are often just called "modes" because rovers can't fly. + +Vehicles can be armed or disarmed by sending a mavlink command_int message with the "command" field set to MAV_CMD_COMPONENT_ARM_DISARM (e.g 400) and the "param1" field (aka "Arm") set to 1 to arm or 0 to disarm. Arming the vehicle sometimes fails because of pre-arm checks. Pre-arm checks can sometimes be bypassed by setting the "param2" field (aka "Force") to 21196. You should only try to force arming if specifically asked by the user. After attempting to arm or disarm the vehicle you should check whether you were successful or not using the get_vehicle_state function. + +Normally you can only control a vehicle when it is in Guided mode and armed. When asked to move the vehicle (e.g. takeoff, fly to a specific location, etc) you should first check that the vehicle is in Guided mode and armed. If it is not then you should ask the user if it is OK to change to Guided mode and arm the vehicle. + +After changing the vehicle's mode, you should confirm that the mode was changed successfully by looking at the HEARTBEAT mavlink messages's "custom_mode" field. + +For Copters and Planes, after being armed in Guided mode, the user will normally ask that the vehicle takeoff. Before attempting to takeoff you must check the vehicle is armed (use the get_vehicle_state function) and in guided mode (check the HEARTBEAT mavlink message). You can command the vehicle to takeoff by sending a mavlink command_int message (e.g. MAV_CMD_NAV_TAKEOFF) with the desired altitude placed in the "z" field. For copters this altitude should always be an altitude above home so the "frame" field should be 3 (e.g. MAV_FRAME_GLOBAL_RELATIVE_ALT). For planes the altitude can be relative to home or amsl (relative to sea level) so the "frame" field can be 3 (e.g. MAV_FRAME_GLOBAL_RELATIVE_ALT) or 0 (MAV_FRAME_GLOBAL). + +To move the vehicle to a specified location use the send_mavlink_set_position_target_global_int function. Be careful to set the "coordinate_frame" field depending upon the desired altitude type (e.g. amsl (relative to sea level), relative to home, or relative to terrain). If you are given or can calculate a target latitude, longitude and altitude then these values should be placed in the "latitude", "longitude" and "alt" fields respectively. Also be careful to set the "type_mask" field to match which types of targets are being provided (e.g. position target, velocity targets, yaw target). + +If the user requests to move the vehicle forward, left, right or back by some distance they mean that the vehicle should move relative to the vehicle's current heading so you must always first call get_vehicle_location_and_yaw to get the vehicle's current yaw. Next calculate the direction of movement (aka bearing) by taking the vehicle's current yaw and adding an angle based on the user specified direction. For example if the vehicle's current yaw is 45 degrees and the user requests the vehicle move to its right, the bearing would be 45+90=135 degrees. It is fine for the resulting bearing to be any value between -360 and +360 degrees. Finally pass this bearing, the distance and the current latitude and longitude into the get_location_plus_dist_at_bearing function. The resulting latitude and longitude should be sent using the send_mavlink_set_position_target_global_int function as described above. If the user does not specify an altitude change then you can assume they want the vehicle to remain at its current altitude. + +If a user is not clear about the altitude type then it is normally safe to assume they mean altitude above home. Sometimes "altitude above home" is referred to as "relative altitude". + +If the user asks to change the yaw (aka heading) of the vehicle, you should first determine if they mean a relative angle or absolute angle. For example if the user says, "rotate to 180deg" they means an absolute heading of 180 degrees. If they say "rotate by 180deg" they mean they want the vehicle to rotate relative to its current heading. Next you should send a command_int message with the "command" field set to MAV_CMD_CONDITION_YAW (e.g. 115). Normally the desired yaw angle should be placed in param1 (aka "Angle") and param2 ("Angular Speed"), param3 ("Direction") and param4 ("Relative") can be left as zero but if the user specifies the angle is relative to the vehicle's current heading then param3 ("Direction") should be set to -1 to rotate left (e.g. counter-clockwise) or +1 to rotate right (e.g. clockwise) and param4 (e.g. "Relative") should be set to 1. + +The short form of "altitude" is "alt". +The short form of "latitude" is "lat". +The short form of "longitude" is "lon". +The words "position" and "location" are often used synonymously. + +Rovers and Boats cannot control their altitude + +Parameters on the vehicle hold many settings that affect how the vehicle behaves. When responding to users requests to get or set parameter values first use the get_parameter_description function to get the description, units, min and max values for the parameters. + +Before any action is taken to set or get vehicle parameters, be sure you know the vehicle type. The easiest way to do this may be to call the get_vehicle_type function. Once you know the vehicle type, the vehicle specific parameter definition file must be accessed and read to confirm the correct parameter names and the expected data types and units. For copters refer to the copter_parameter_definitions.xml file, for planes refer to plane_parameter_definitions.xml, for rovers and boats refer to rover_parameter_definitions.xml, and for subs (aka submarines) refer to sub_parameter_definitions.xml. If the file cannot be found or accessed, please report to the user that the parameter definitions file is required before proceeding. Once the file is accessed, utilize the parameter information within it to validate parameter names and units against any user request for setting or getting vehicle parameter values. Perform the requested action (set or get) only if the parameter definitions have been successfully verified to match the request. diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/copter_flightmodes.txt b/MAVProxy/modules/mavproxy_chat/assistant_setup/copter_flightmodes.txt index 4b5fc4cd09..1689f26736 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/copter_flightmodes.txt +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/copter_flightmodes.txt @@ -1,29 +1,29 @@ -This file holds the Copter flight mode name to number mapping - -STABILIZE = 0, // pilot directly controls the airframe angle with roll, pitch and yaw stick inputs. Pilot directly controls throttle -ACRO = 1, // pilot directly controls the body-frame angular rate. pilot directly controls throttle -ALT_HOLD = 2, // pilot directly controls the vehicle roll, pitch and yaw angles. Pilot's throttle control controls climb rate -AUTO = 3, // fully automatic waypoint control using mission commands -GUIDED = 4, // fully automatic fly to coordinate or fly at velocity/direction using mavlink commands. -LOITER = 5, // pilot controls the vehicle's 3D speed and acceleration with roll, pitch and throttle input. Heading is controlled with the yaw stick -RTL = 6, // automatic return to launching point -CIRCLE = 7, // automatic circular flight with automatic throttle -LAND = 9, // automatic landing with horizontal position control -DRIFT = 11, // semi-autonomous position, yaw and throttle control. rarely used. -SPORT = 13, // manual earth-frame angular rate control with manual throttle. very rarely used -FLIP = 14, // automatically flip the vehicle 360 degrees -AUTOTUNE = 15, // automatically tune the vehicle's roll and pitch gains -POSHOLD = 16, // automatic position hold with manual override, with automatic throttle. very similar to Loiter mode -BRAKE = 17, // full-brake using inertial/GPS system, no pilot input -THROW = 18, // throw to launch mode using inertial/GPS system, no pilot input -AVOID_ADSB = 19, // automatic avoidance of manned vehicle. very rarely used -GUIDED_NOGPS = 20, // guided mode but only accepts attitude and altitude commands -SMART_RTL = 21, // SMART_RTL returns vehicle home by retracing its steps -FLOWHOLD = 22, // FLOWHOLD holds position with optical flow without rangefinder. similar to Loiter. very rarely used -FOLLOW = 23, // follow attempts to follow another vehicle or ground station -ZIGZAG = 24, // ZIGZAG mode is able to fly in a zigzag manner with predefined point A and point B. Normally used for crop spraying vehicles. -SYSTEMID = 25, // System ID mode produces automated system identification signals in the controllers. very rarely used -AUTOROTATE = 26, // Autonomous autorotation. Used only for traditional helicopters -AUTO_RTL = 27, // return to launch but using an Auto mission starting from the DO_LAND_START command -TURTLE = 28, // Flip vehicle to recover after crash - +This file holds the Copter flight mode name to number mapping + +STABILIZE = 0, // pilot directly controls the airframe angle with roll, pitch and yaw stick inputs. Pilot directly controls throttle +ACRO = 1, // pilot directly controls the body-frame angular rate. pilot directly controls throttle +ALT_HOLD = 2, // pilot directly controls the vehicle roll, pitch and yaw angles. Pilot's throttle control controls climb rate +AUTO = 3, // fully automatic waypoint control using mission commands +GUIDED = 4, // fully automatic fly to coordinate or fly at velocity/direction using mavlink commands. +LOITER = 5, // pilot controls the vehicle's 3D speed and acceleration with roll, pitch and throttle input. Heading is controlled with the yaw stick +RTL = 6, // automatic return to launching point +CIRCLE = 7, // automatic circular flight with automatic throttle +LAND = 9, // automatic landing with horizontal position control +DRIFT = 11, // semi-autonomous position, yaw and throttle control. rarely used. +SPORT = 13, // manual earth-frame angular rate control with manual throttle. very rarely used +FLIP = 14, // automatically flip the vehicle 360 degrees +AUTOTUNE = 15, // automatically tune the vehicle's roll and pitch gains +POSHOLD = 16, // automatic position hold with manual override, with automatic throttle. very similar to Loiter mode +BRAKE = 17, // full-brake using inertial/GPS system, no pilot input +THROW = 18, // throw to launch mode using inertial/GPS system, no pilot input +AVOID_ADSB = 19, // automatic avoidance of manned vehicle. very rarely used +GUIDED_NOGPS = 20, // guided mode but only accepts attitude and altitude commands +SMART_RTL = 21, // SMART_RTL returns vehicle home by retracing its steps +FLOWHOLD = 22, // FLOWHOLD holds position with optical flow without rangefinder. similar to Loiter. very rarely used +FOLLOW = 23, // follow attempts to follow another vehicle or ground station +ZIGZAG = 24, // ZIGZAG mode is able to fly in a zigzag manner with predefined point A and point B. Normally used for crop spraying vehicles. +SYSTEMID = 25, // System ID mode produces automated system identification signals in the controllers. very rarely used +AUTOROTATE = 26, // Autonomous autorotation. Used only for traditional helicopters +AUTO_RTL = 27, // return to launch but using an Auto mission starting from the DO_LAND_START command +TURTLE = 28, // Flip vehicle to recover after crash + diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/delete_wakeup_timers.json b/MAVProxy/modules/mavproxy_chat/assistant_setup/delete_wakeup_timers.json index d512ff23bf..848951b2b0 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/delete_wakeup_timers.json +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/delete_wakeup_timers.json @@ -1,14 +1,14 @@ -{ - "type": "function", - "function": { - "name": "delete_wakeup_timers", - "description": "Delete all active wakeup timers. You can optionally provide a message parameter to filter which timers will be deleted based on their message. When specifying the message parameter, you can use regular expressions (regex) to match patterns within the timer messages. This is useful when you want to delete timers with specific keywords or patterns in their message. For example, to delete all timers containing the word 'hello', you can use the regex '.*hello.*', where the dot-star (.*) pattern matches any character sequence.", - "parameters": { - "type": "object", - "properties": { - "message": {"type": "string", "description": "wakeup message of timers to be deleted. regex values are accepted."} - }, - "required": [] - } - } -} +{ + "type": "function", + "function": { + "name": "delete_wakeup_timers", + "description": "Delete all active wakeup timers. You can optionally provide a message parameter to filter which timers will be deleted based on their message. When specifying the message parameter, you can use regular expressions (regex) to match patterns within the timer messages. This is useful when you want to delete timers with specific keywords or patterns in their message. For example, to delete all timers containing the word 'hello', you can use the regex '.*hello.*', where the dot-star (.*) pattern matches any character sequence.", + "parameters": { + "type": "object", + "properties": { + "message": {"type": "string", "description": "wakeup message of timers to be deleted. regex values are accepted."} + }, + "required": [] + } + } +} diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_all_parameters.json b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_all_parameters.json index 283e24fcb8..a2b7a8d561 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_all_parameters.json +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_all_parameters.json @@ -1,12 +1,12 @@ -{ - "type": "function", - "function": { - "name": "get_all_parameters", - "description": "Get all available parameter names and values", - "parameters": { - "type": "object", - "properties": {}, - "required": [] - } - } -} +{ + "type": "function", + "function": { + "name": "get_all_parameters", + "description": "Get all available parameter names and values", + "parameters": { + "type": "object", + "properties": {}, + "required": [] + } + } +} diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_available_mavlink_messages.json b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_available_mavlink_messages.json index 8c97608311..e2a3eafd09 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_available_mavlink_messages.json +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_available_mavlink_messages.json @@ -1,12 +1,12 @@ -{ - "type": "function", - "function": { - "name": "get_available_mavlink_messages", - "description": "Get a list of mavlink message names that can be retrieved using the get_mavlink_message function", - "parameters": { - "type": "object", - "properties": {}, - "required": [] - } - } -} +{ + "type": "function", + "function": { + "name": "get_available_mavlink_messages", + "description": "Get a list of mavlink message names that can be retrieved using the get_mavlink_message function", + "parameters": { + "type": "object", + "properties": {}, + "required": [] + } + } +} diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_current_datetime.json b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_current_datetime.json index 45687821a3..7e08d2aec7 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_current_datetime.json +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_current_datetime.json @@ -1,12 +1,12 @@ -{ - "type": "function", - "function": { - "name": "get_current_datetime", - "description": "Get the current date and time, e.g. 'Saturday, June 24, 2023 6:14:14 PM'", - "parameters": { - "type": "object", - "properties": {}, - "required": [] - } - } +{ + "type": "function", + "function": { + "name": "get_current_datetime", + "description": "Get the current date and time, e.g. 'Saturday, June 24, 2023 6:14:14 PM'", + "parameters": { + "type": "object", + "properties": {}, + "required": [] + } + } } \ No newline at end of file diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_location_plus_dist_at_bearing.json b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_location_plus_dist_at_bearing.json index f05edccc7e..efe5ea7fe2 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_location_plus_dist_at_bearing.json +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_location_plus_dist_at_bearing.json @@ -1,17 +1,17 @@ -{ - "type": "function", - "function": { - "name": "get_location_plus_dist_at_bearing", - "description": "Calculate the latitude and longitude given an existing latitude and longitude and a distance in meters and a bearing in degrees", - "parameters": { - "type": "object", - "properties": { - "latitude": {"type": "number", "description": "latitude in degrees"}, - "longitude": {"type": "number", "description": "longitude in degrees"}, - "distance": {"type": "number", "description": "distance to move meters"}, - "bearing": {"type": "number", "description": "bearing in degrees. 0 is North, 90 is East, etc"} - }, - "required": ["latitude", "longitude", "distance", "bearing"] - } - } -} +{ + "type": "function", + "function": { + "name": "get_location_plus_dist_at_bearing", + "description": "Calculate the latitude and longitude given an existing latitude and longitude and a distance in meters and a bearing in degrees", + "parameters": { + "type": "object", + "properties": { + "latitude": {"type": "number", "description": "latitude in degrees"}, + "longitude": {"type": "number", "description": "longitude in degrees"}, + "distance": {"type": "number", "description": "distance to move meters"}, + "bearing": {"type": "number", "description": "bearing in degrees. 0 is North, 90 is East, etc"} + }, + "required": ["latitude", "longitude", "distance", "bearing"] + } + } +} diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_location_plus_offset.json b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_location_plus_offset.json index 922549502e..558cc302cf 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_location_plus_offset.json +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_location_plus_offset.json @@ -1,17 +1,17 @@ -{ - "type": "function", - "function": { - "name": "get_location_plus_offset", - "description": "Calculate the latitude and longitude given an existing latitude and longitude and distances (in meters) North and East", - "parameters": { - "type": "object", - "properties": { - "latitude": {"type": "number", "description": "latitude in degrees"}, - "longitude": {"type": "number", "description": "longitude in degrees"}, - "distance_north": {"type": "number", "description": "distance to move North in meters"}, - "distance_east": {"type": "number", "description": "distance to move East in meters"} - }, - "required": ["latitude", "longitude", "distance_north", "distance_east"] - } - } -} +{ + "type": "function", + "function": { + "name": "get_location_plus_offset", + "description": "Calculate the latitude and longitude given an existing latitude and longitude and distances (in meters) North and East", + "parameters": { + "type": "object", + "properties": { + "latitude": {"type": "number", "description": "latitude in degrees"}, + "longitude": {"type": "number", "description": "longitude in degrees"}, + "distance_north": {"type": "number", "description": "distance to move North in meters"}, + "distance_east": {"type": "number", "description": "distance to move East in meters"} + }, + "required": ["latitude", "longitude", "distance_north", "distance_east"] + } + } +} diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_mavlink_message.json b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_mavlink_message.json index eb3817ee1e..77ee849631 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_mavlink_message.json +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_mavlink_message.json @@ -1,14 +1,14 @@ -{ - "type": "function", - "function": { - "name": "get_mavlink_message", - "description": "Get a mavlink message including all fields and values sent by the vehicle. The list of available messages can be retrieved using the get_available_mavlink_messages", - "parameters": { - "type": "object", - "properties": { - "message": {"type": "string", "description": "mavlink message name (e.g. HEARTBEAT, VFR_HUD, GLOBAL_POSITION_INT, etc)"} - }, - "required": ["message"] - } - } -} +{ + "type": "function", + "function": { + "name": "get_mavlink_message", + "description": "Get a mavlink message including all fields and values sent by the vehicle. The list of available messages can be retrieved using the get_available_mavlink_messages", + "parameters": { + "type": "object", + "properties": { + "message": {"type": "string", "description": "mavlink message name (e.g. HEARTBEAT, VFR_HUD, GLOBAL_POSITION_INT, etc)"} + }, + "required": ["message"] + } + } +} diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_mode_mapping.json b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_mode_mapping.json index efc2daaf26..37d4e70c4e 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_mode_mapping.json +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_mode_mapping.json @@ -1,15 +1,15 @@ -{ - "type": "function", - "function": { - "name": "get_mode_mapping", - "description": "Get a list of mode names to mode numbers available for this vehicle. If the name or number parameter is provided only that mode's name and number will be returned. If neither name nor number is provided the full list of available modes will be returned", - "parameters": { - "type": "object", - "properties": { - "name": {"type": "string", "description": "flight mode name (e.g. Guided, Loiter, RTL)"}, - "number": {"type": "number", "description": "flight mode number"} - }, - "required": [] - } - } -} +{ + "type": "function", + "function": { + "name": "get_mode_mapping", + "description": "Get a list of mode names to mode numbers available for this vehicle. If the name or number parameter is provided only that mode's name and number will be returned. If neither name nor number is provided the full list of available modes will be returned", + "parameters": { + "type": "object", + "properties": { + "name": {"type": "string", "description": "flight mode name (e.g. Guided, Loiter, RTL)"}, + "number": {"type": "number", "description": "flight mode number"} + }, + "required": [] + } + } +} diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_parameter.json b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_parameter.json index a5a536d1b5..ccee03dbea 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_parameter.json +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_parameter.json @@ -1,15 +1,15 @@ -{ - "type": "function", - "function": { - "name": "get_parameter", - "description": "Get a vehicle parameter's value. The full list of available parameters and their values is available using the get_all_parameters function", - "parameters": { - "type": "object", - "properties": { - "name": {"type": "string", "description": "parameter name (e.g. ARMING_CHECK, LOG_BITMASK). Regex expressions are supported"}, - "value": {"type": "number", "description": "parameter value"} - }, - "required": ["name"] - } - } -} +{ + "type": "function", + "function": { + "name": "get_parameter", + "description": "Get a vehicle parameter's value. The full list of available parameters and their values is available using the get_all_parameters function", + "parameters": { + "type": "object", + "properties": { + "name": {"type": "string", "description": "parameter name (e.g. ARMING_CHECK, LOG_BITMASK). Regex expressions are supported"}, + "value": {"type": "number", "description": "parameter value"} + }, + "required": ["name"] + } + } +} diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_parameter_description.json b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_parameter_description.json index c348a7dae6..93f52f0d6c 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_parameter_description.json +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_parameter_description.json @@ -1,14 +1,14 @@ -{ - "type": "function", - "function": { - "name": "get_parameter_description", - "description": "Get vehicle parameter descriptions including description, units, min and max", - "parameters": { - "type": "object", - "properties": { - "name": {"type": "string", "description": "parameter name (e.g. ARMING_CHECK, LOG_BITMASK). Regex expressions are supported. set to * to get all parameter descriptions"} - }, - "required": ["name"] - } - } -} +{ + "type": "function", + "function": { + "name": "get_parameter_description", + "description": "Get vehicle parameter descriptions including description, units, min and max", + "parameters": { + "type": "object", + "properties": { + "name": {"type": "string", "description": "parameter name (e.g. ARMING_CHECK, LOG_BITMASK). Regex expressions are supported. set to * to get all parameter descriptions"} + }, + "required": ["name"] + } + } +} diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_vehicle_location_and_yaw.json b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_vehicle_location_and_yaw.json index 18af661403..3fc82c17ac 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_vehicle_location_and_yaw.json +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_vehicle_location_and_yaw.json @@ -1,18 +1,18 @@ -{ - "type": "function", - "function": { - "name": "get_vehicle_location_and_yaw", - "description": "Get the vehicle's current location including latitude, longitude, altitude above sea level and altitude above home", - "parameters": { - "type": "object", - "properties": { - "latitude": {"type": "number", "description": "latitude in degrees"}, - "longitude": {"type": "number", "description": "longitude in degrees"}, - "altitude_amsl": {"type": "number", "description": "altitude above sea level in meters (aka AMSL)"}, - "altitude_above_home": {"type": "number", "description": "altitude above home in meters"}, - "yaw": {"type": "number", "description": "vehicle yaw (aka heading) in degrees"} - }, - "required": [] - } - } -} +{ + "type": "function", + "function": { + "name": "get_vehicle_location_and_yaw", + "description": "Get the vehicle's current location including latitude, longitude, altitude above sea level and altitude above home", + "parameters": { + "type": "object", + "properties": { + "latitude": {"type": "number", "description": "latitude in degrees"}, + "longitude": {"type": "number", "description": "longitude in degrees"}, + "altitude_amsl": {"type": "number", "description": "altitude above sea level in meters (aka AMSL)"}, + "altitude_above_home": {"type": "number", "description": "altitude above home in meters"}, + "yaw": {"type": "number", "description": "vehicle yaw (aka heading) in degrees"} + }, + "required": [] + } + } +} diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_vehicle_state.json b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_vehicle_state.json index 152bfb63b6..cb4aae2930 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_vehicle_state.json +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_vehicle_state.json @@ -1,15 +1,15 @@ -{ - "type": "function", - "function": { - "name": "get_vehicle_state", - "description": "Get the vehicle state including armed status and (flight) mode", - "parameters": { - "type": "object", - "properties": { - "armed": {"type": "boolean", "description": "vehicle armed status. True means motors can spin and vehicle can move."}, - "mode": {"type": "number", "description": "flight flight mode. The number is specific to the vehicle type (e.g. Copter, Plane, Rover"} - }, - "required": [] - } - } -} +{ + "type": "function", + "function": { + "name": "get_vehicle_state", + "description": "Get the vehicle state including armed status and (flight) mode", + "parameters": { + "type": "object", + "properties": { + "armed": {"type": "boolean", "description": "vehicle armed status. True means motors can spin and vehicle can move."}, + "mode": {"type": "number", "description": "flight flight mode. The number is specific to the vehicle type (e.g. Copter, Plane, Rover"} + }, + "required": [] + } + } +} diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_vehicle_type.json b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_vehicle_type.json index bc1544f83e..53126f29ed 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_vehicle_type.json +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_vehicle_type.json @@ -1,14 +1,14 @@ -{ - "type": "function", - "function": { - "name": "get_vehicle_type", - "description": "Get the vehicle type (e.g. Copter, Plane, Rover, Boat, etc)", - "parameters": { - "type": "object", - "properties": { - "vehicle_type": {"type": "string", "description": "the vehicle type. Unknown if not known"} - }, - "required": [] - } - } -} +{ + "type": "function", + "function": { + "name": "get_vehicle_type", + "description": "Get the vehicle type (e.g. Copter, Plane, Rover, Boat, etc)", + "parameters": { + "type": "object", + "properties": { + "vehicle_type": {"type": "string", "description": "the vehicle type. Unknown if not known"} + }, + "required": [] + } + } +} diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_wakeup_timers.json b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_wakeup_timers.json index e4b6288cd1..2671f3677a 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/get_wakeup_timers.json +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/get_wakeup_timers.json @@ -1,14 +1,14 @@ -{ - "type": "function", - "function": { - "name": "get_wakeup_timers", - "description": "Retrieves a list of all active wakeup timers. You can optionally provide a message parameter to filter timers by their associated messages. When specifying the message parameter, you can use regular expressions (regex) to match patterns within the timer messages. This is useful when you want to find timers with specific keywords or patterns in their messages. For example, to retrieve all timers containing the word 'hello', you can use the regex '.*hello.*', where the dot-star (.*) pattern matches any character sequence.", - "parameters": { - "type": "object", - "properties": { - "message": {"type": "string", "description": "wakeup message of timers to be retrieved. regex values are accepted."} - }, - "required": [] - } - } -} +{ + "type": "function", + "function": { + "name": "get_wakeup_timers", + "description": "Retrieves a list of all active wakeup timers. You can optionally provide a message parameter to filter timers by their associated messages. When specifying the message parameter, you can use regular expressions (regex) to match patterns within the timer messages. This is useful when you want to find timers with specific keywords or patterns in their messages. For example, to retrieve all timers containing the word 'hello', you can use the regex '.*hello.*', where the dot-star (.*) pattern matches any character sequence.", + "parameters": { + "type": "object", + "properties": { + "message": {"type": "string", "description": "wakeup message of timers to be retrieved. regex values are accepted."} + }, + "required": [] + } + } +} diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/plane_flightmodes.txt b/MAVProxy/modules/mavproxy_chat/assistant_setup/plane_flightmodes.txt index e5bf0c736c..d8c1672fc9 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/plane_flightmodes.txt +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/plane_flightmodes.txt @@ -1,28 +1,28 @@ -This file holds the Plane flight mode name to number mapping. Modes starting with Q are only for use with QuadPlanes. - -MANUAL = 0, // pilot has direct control over servos without stabilization -CIRCLE = 1, // Circle around a GPS waypoint -STABILIZE = 2, // Level flight stabilization -TRAINING = 3, // Limits the roll and pitch angles to keep the aircraft stable -ACRO = 4, // Full manual aerobatic control with some stabilization -FLY_BY_WIRE_A = 5, // Stabilized flight with manual throttle -FLY_BY_WIRE_B = 6, // More stabilization than FLY_BY_WIRE_A -CRUISE = 7, // Mixed manual and automatic throttle control -AUTOTUNE = 8, // Automatically tune the PID controller for optimal performance -AUTO = 10, // Fully autonomous flight, following a pre-programmed mission -RTL = 11, // Return to Launch point -LOITER = 12, // Circle around a point while maintaining altitude -TAKEOFF = 13, // Automated takeoff sequence -AVOID_ADSB = 14, // Avoidance maneuver triggered by ADS-B aircraft detection -GUIDED = 15, // Remotely guided commands from GCS or companion computer -INITIALISING = 16, // Initialization mode at startup -QSTABILIZE = 17, // QuadPlane's stabilize mode. Similar to Copter's stabilize mode -QHOVER = 18, // QuadPlane's hover mode. Similar to Copter's AltHold mode -QLOITER = 19, // QuadPlane's loiter mode. Similar to Copter's Loiter mode -QLAND = 20, // QuadPlane's land mode. Similar to Copter's Land mode -QRTL = 21, // QuadPlane's Return to Launch mode. Similar to Copter's RTL mode -QAUTOTUNE = 22, // QuadPlane's autotune mode. Similar to Copter's AutoTune mode -QACRO = 23, // QuadPlane's acrobatic mode. Similar to Copter's Acro mode -THERMAL = 24, // Thermal detection and exploitation mode -LOITER_ALT_QLAND = 25, // QuadPlane's loiter to alt then land mode - +This file holds the Plane flight mode name to number mapping. Modes starting with Q are only for use with QuadPlanes. + +MANUAL = 0, // pilot has direct control over servos without stabilization +CIRCLE = 1, // Circle around a GPS waypoint +STABILIZE = 2, // Level flight stabilization +TRAINING = 3, // Limits the roll and pitch angles to keep the aircraft stable +ACRO = 4, // Full manual aerobatic control with some stabilization +FLY_BY_WIRE_A = 5, // Stabilized flight with manual throttle +FLY_BY_WIRE_B = 6, // More stabilization than FLY_BY_WIRE_A +CRUISE = 7, // Mixed manual and automatic throttle control +AUTOTUNE = 8, // Automatically tune the PID controller for optimal performance +AUTO = 10, // Fully autonomous flight, following a pre-programmed mission +RTL = 11, // Return to Launch point +LOITER = 12, // Circle around a point while maintaining altitude +TAKEOFF = 13, // Automated takeoff sequence +AVOID_ADSB = 14, // Avoidance maneuver triggered by ADS-B aircraft detection +GUIDED = 15, // Remotely guided commands from GCS or companion computer +INITIALISING = 16, // Initialization mode at startup +QSTABILIZE = 17, // QuadPlane's stabilize mode. Similar to Copter's stabilize mode +QHOVER = 18, // QuadPlane's hover mode. Similar to Copter's AltHold mode +QLOITER = 19, // QuadPlane's loiter mode. Similar to Copter's Loiter mode +QLAND = 20, // QuadPlane's land mode. Similar to Copter's Land mode +QRTL = 21, // QuadPlane's Return to Launch mode. Similar to Copter's RTL mode +QAUTOTUNE = 22, // QuadPlane's autotune mode. Similar to Copter's AutoTune mode +QACRO = 23, // QuadPlane's acrobatic mode. Similar to Copter's Acro mode +THERMAL = 24, // Thermal detection and exploitation mode +LOITER_ALT_QLAND = 25, // QuadPlane's loiter to alt then land mode + diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/rover_modes.txt b/MAVProxy/modules/mavproxy_chat/assistant_setup/rover_modes.txt index a7b990faaf..38c986b322 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/rover_modes.txt +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/rover_modes.txt @@ -1,16 +1,16 @@ -This file holds the Rover (aka car) and boat mode name to number mapping. Rover "modes" are the same as "flight modes" for other vehicles. "Rover" is synonymous with "car" - -MANUAL = 0, // Pilot directly controls the vehicle's steering and throttle -ACRO = 1, // Pilot controls the turn rate and speed -STEERING = 3, // Pilot controls the steering using lateral acceleration. throttle stick controls speed -HOLD = 4, // motor and steering outputs are disabled. Rovers will stop, boats will drift in this mode -LOITER = 5, // hold position at the current location -FOLLOW = 6, // follow a GPS-enabled device -SIMPLE = 7, // Pilot controls the vehicles by moving the combined steering and throttle stick in the direction they wish to move. The direction of movement is relative to the vehicle's heading when first powered on -DOCK = 8, // Automatic docking mode -CIRCLE = 9, // Circle around a location recorded when the vehicle entered this mode -AUTO = 10, // Fully autonomous mode following pre-programmed waypoints -RTL = 11, // Return to Launch point -SMART_RTL = 12, // Creates a path back to the launch point based on the rover's traveled path -GUIDED = 15, // Guided control via a ground station or companion computer -INITIALISING = 16, // Initialization mode at startup +This file holds the Rover (aka car) and boat mode name to number mapping. Rover "modes" are the same as "flight modes" for other vehicles. "Rover" is synonymous with "car" + +MANUAL = 0, // Pilot directly controls the vehicle's steering and throttle +ACRO = 1, // Pilot controls the turn rate and speed +STEERING = 3, // Pilot controls the steering using lateral acceleration. throttle stick controls speed +HOLD = 4, // motor and steering outputs are disabled. Rovers will stop, boats will drift in this mode +LOITER = 5, // hold position at the current location +FOLLOW = 6, // follow a GPS-enabled device +SIMPLE = 7, // Pilot controls the vehicles by moving the combined steering and throttle stick in the direction they wish to move. The direction of movement is relative to the vehicle's heading when first powered on +DOCK = 8, // Automatic docking mode +CIRCLE = 9, // Circle around a location recorded when the vehicle entered this mode +AUTO = 10, // Fully autonomous mode following pre-programmed waypoints +RTL = 11, // Return to Launch point +SMART_RTL = 12, // Creates a path back to the launch point based on the rover's traveled path +GUIDED = 15, // Guided control via a ground station or companion computer +INITIALISING = 16, // Initialization mode at startup diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/send_mavlink_command_int.json b/MAVProxy/modules/mavproxy_chat/assistant_setup/send_mavlink_command_int.json index 5ba4e640f1..be5e68bc51 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/send_mavlink_command_int.json +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/send_mavlink_command_int.json @@ -1,26 +1,26 @@ -{ - "type": "function", - "function": { - "name": "send_mavlink_command_int", - "description": "Send a mavlink COMMAND_INT message to the vehicle. Available commands including changing the flight mode, arming, disarming, takeoff and commanding the vehicle to fly to a specific location", - "parameters": { - "type": "object", - "properties": { - "target_system": {"type": "integer", "minimum":0, "maximum":255, "description": "vehicle autopilot System ID. can be omitted"}, - "target_component": {"type": "integer", "minimum":0, "maximum":255, "description": "vehicle autopilot Component ID. can be omitted"}, - "frame": {"type": "integer", "minimum":0, "maximum":21, "description": "altitude type. see MAV_FRAME. 0 for altitude above sea level, 3 for altitude above home, 10 for altitude above terrain"}, - "command": {"type": "integer", "minimum":0, "maximum":65535, "description": "MAVLink command id. See MAV_CMD for a full list of available commands"}, - "current": {"type": "integer", "description": "not used. always zero"}, - "autocontinue": {"type": "integer", "description": "not used. always zero"}, - "param1": {"type": "number", "description": "parameter 1. see MAV_CMD enum"}, - "param2": {"type": "number", "description": "parameter 2. see MAV_CMD enum"}, - "param3": {"type": "number", "description": "parameter 3. see MAV_CMD enum"}, - "param4": {"type": "number", "description": "parameter 4. see MAV_CMD enum"}, - "x": {"type": "integer", "description": "latitude in degrees * 10^7"}, - "y": {"type": "integer", "description": "longitude in degrees * 10^7"}, - "z": {"type": "number", "description": "altitude in meters (relative to sea level, home or terrain depending on frame field)."} - }, - "required": ["frame", "command"] - } - } -} +{ + "type": "function", + "function": { + "name": "send_mavlink_command_int", + "description": "Send a mavlink COMMAND_INT message to the vehicle. Available commands including changing the flight mode, arming, disarming, takeoff and commanding the vehicle to fly to a specific location", + "parameters": { + "type": "object", + "properties": { + "target_system": {"type": "integer", "minimum":0, "maximum":255, "description": "vehicle autopilot System ID. can be omitted"}, + "target_component": {"type": "integer", "minimum":0, "maximum":255, "description": "vehicle autopilot Component ID. can be omitted"}, + "frame": {"type": "integer", "minimum":0, "maximum":21, "description": "altitude type. see MAV_FRAME. 0 for altitude above sea level, 3 for altitude above home, 10 for altitude above terrain"}, + "command": {"type": "integer", "minimum":0, "maximum":65535, "description": "MAVLink command id. See MAV_CMD for a full list of available commands"}, + "current": {"type": "integer", "description": "not used. always zero"}, + "autocontinue": {"type": "integer", "description": "not used. always zero"}, + "param1": {"type": "number", "description": "parameter 1. see MAV_CMD enum"}, + "param2": {"type": "number", "description": "parameter 2. see MAV_CMD enum"}, + "param3": {"type": "number", "description": "parameter 3. see MAV_CMD enum"}, + "param4": {"type": "number", "description": "parameter 4. see MAV_CMD enum"}, + "x": {"type": "integer", "description": "latitude in degrees * 10^7"}, + "y": {"type": "integer", "description": "longitude in degrees * 10^7"}, + "z": {"type": "number", "description": "altitude in meters (relative to sea level, home or terrain depending on frame field)."} + }, + "required": ["frame", "command"] + } + } +} diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/send_mavlink_set_position_target_global_int.json b/MAVProxy/modules/mavproxy_chat/assistant_setup/send_mavlink_set_position_target_global_int.json index 5ff48737c6..2a8e1575e7 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/send_mavlink_set_position_target_global_int.json +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/send_mavlink_set_position_target_global_int.json @@ -1,29 +1,29 @@ -{ - "type": "function", - "function": { - "name": "send_mavlink_set_position_target_global_int", - "description": "Send a mavlink SET_POSITION_TARGET_GLOBAL_INT message to the vehicle. This message is the preferred way to command a vehicle to fly to a specified location or to fly at a specfied velocity", - "parameters": { - "type": "object", - "properties": { - "time_boot_ms": {"type": "integer", "description": "system timestamp. can be left as 0"}, - "target_system": {"type": "integer", "minimum":0, "maximum":255, "description": "vehicle autopilot System ID. can be omitted"}, - "target_component": {"type": "integer", "minimum":0, "maximum":255, "description": "vehicle autopilot Component ID. can be omitted"}, - "coordinate_frame": {"type": "integer", "minimum":0, "maximum":21, "description": "altitude type. see MAV_FRAME. 5 for altitude above sea level, 6 for altitude above home, 11 for altitude above terrain"}, - "type_mask": {"type": "integer", "minimum":0, "maximum":65535, "description": "Bitmap to indicate which dimensions should be ignored by the vehicle. see POSITION_TARGET_TYPEMASK. If only location (e.g. lat_int, lon_int and alt) is sent use 3576. If location and yaw are sent use 2552. If only velocity (e.g. vx, vy, vz) is sent use 2552. if velocity and yaw are sent use 2503. If only yaw is sent use 2559"}, - "latitude": {"type": "number", "description": "latitude in degrees"}, - "longitude": {"type": "number", "description": "longitude in degrees"}, - "alt": {"type": "number", "description": "altitude in meters (relative to sea level, home or terrain depending on frame field)"}, - "vx": {"type": "number", "description": "velocity North in m/s"}, - "vy": {"type": "number", "description": "velocity East in m/s"}, - "vz": {"type": "number", "description": "velocity Down in m/s"}, - "afx": {"type": "number", "description": "acceleration North in m/s/s. rarely used, normally 0"}, - "afy": {"type": "number", "description": "acceleration East in m/s/s. rarely used, normally 0"}, - "afz": {"type": "number", "description": "acceleration Down in m/s/s. rarely used, normally 0"}, - "yaw": {"type": "number", "minimum":-6.28318530717959, "maximum":6.28318530717959, "description": "yaw (aka heading) in radians"}, - "yaw_rate": {"type": "number", "description": "yaw (aka heading) rotation rate in radians/second. rarely used, normally 0"} - }, - "required": ["coordinate_frame", "type_mask"] - } - } -} +{ + "type": "function", + "function": { + "name": "send_mavlink_set_position_target_global_int", + "description": "Send a mavlink SET_POSITION_TARGET_GLOBAL_INT message to the vehicle. This message is the preferred way to command a vehicle to fly to a specified location or to fly at a specfied velocity", + "parameters": { + "type": "object", + "properties": { + "time_boot_ms": {"type": "integer", "description": "system timestamp. can be left as 0"}, + "target_system": {"type": "integer", "minimum":0, "maximum":255, "description": "vehicle autopilot System ID. can be omitted"}, + "target_component": {"type": "integer", "minimum":0, "maximum":255, "description": "vehicle autopilot Component ID. can be omitted"}, + "coordinate_frame": {"type": "integer", "minimum":0, "maximum":21, "description": "altitude type. see MAV_FRAME. 5 for altitude above sea level, 6 for altitude above home, 11 for altitude above terrain"}, + "type_mask": {"type": "integer", "minimum":0, "maximum":65535, "description": "Bitmap to indicate which dimensions should be ignored by the vehicle. see POSITION_TARGET_TYPEMASK. If only location (e.g. lat_int, lon_int and alt) is sent use 3576. If location and yaw are sent use 2552. If only velocity (e.g. vx, vy, vz) is sent use 2552. if velocity and yaw are sent use 2503. If only yaw is sent use 2559"}, + "latitude": {"type": "number", "description": "latitude in degrees"}, + "longitude": {"type": "number", "description": "longitude in degrees"}, + "alt": {"type": "number", "description": "altitude in meters (relative to sea level, home or terrain depending on frame field)"}, + "vx": {"type": "number", "description": "velocity North in m/s"}, + "vy": {"type": "number", "description": "velocity East in m/s"}, + "vz": {"type": "number", "description": "velocity Down in m/s"}, + "afx": {"type": "number", "description": "acceleration North in m/s/s. rarely used, normally 0"}, + "afy": {"type": "number", "description": "acceleration East in m/s/s. rarely used, normally 0"}, + "afz": {"type": "number", "description": "acceleration Down in m/s/s. rarely used, normally 0"}, + "yaw": {"type": "number", "minimum":-6.28318530717959, "maximum":6.28318530717959, "description": "yaw (aka heading) in radians"}, + "yaw_rate": {"type": "number", "description": "yaw (aka heading) rotation rate in radians/second. rarely used, normally 0"} + }, + "required": ["coordinate_frame", "type_mask"] + } + } +} diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/set_parameter.json b/MAVProxy/modules/mavproxy_chat/assistant_setup/set_parameter.json index 269833c565..d9d646b8d5 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/set_parameter.json +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/set_parameter.json @@ -1,15 +1,15 @@ -{ - "type": "function", - "function": { - "name": "set_parameter", - "description": "Set a vehicle parameter's value. The full list of parameters is available using the get_all_parameters function", - "parameters": { - "type": "object", - "properties": { - "name": {"type": "string", "description": "parameter name (e.g. ARMING_CHECK, LOG_BITMASK)"}, - "value": {"type": "number", "description": "parameter value"} - }, - "required": ["name", "value"] - } - } -} +{ + "type": "function", + "function": { + "name": "set_parameter", + "description": "Set a vehicle parameter's value. The full list of parameters is available using the get_all_parameters function", + "parameters": { + "type": "object", + "properties": { + "name": {"type": "string", "description": "parameter name (e.g. ARMING_CHECK, LOG_BITMASK)"}, + "value": {"type": "number", "description": "parameter value"} + }, + "required": ["name", "value"] + } + } +} diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/set_wakeup_timer.json b/MAVProxy/modules/mavproxy_chat/assistant_setup/set_wakeup_timer.json index 63dd326cc4..eab4e73972 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/set_wakeup_timer.json +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/set_wakeup_timer.json @@ -1,15 +1,15 @@ -{ - "type": "function", - "function": { - "name": "set_wakeup_timer", - "description": "Set a timer to wake you up in a specified number of seconds in the future. This allows taking actions in the future. The wakeup message will appear with the user role but will look something like WAKEUP:. Multiple wakeup messages are supported", - "parameters": { - "type": "object", - "properties": { - "seconds": {"type": "number", "description": "number of seconds in the future that the timer will wake you up"}, - "message": {"type": "string", "description": "wakeup message that will be sent to you"} - }, - "required": ["seconds", "message"] - } - } -} +{ + "type": "function", + "function": { + "name": "set_wakeup_timer", + "description": "Set a timer to wake you up in a specified number of seconds in the future. This allows taking actions in the future. The wakeup message will appear with the user role but will look something like WAKEUP:. Multiple wakeup messages are supported", + "parameters": { + "type": "object", + "properties": { + "seconds": {"type": "number", "description": "number of seconds in the future that the timer will wake you up"}, + "message": {"type": "string", "description": "wakeup message that will be sent to you"} + }, + "required": ["seconds", "message"] + } + } +} diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/setup_assistant.py b/MAVProxy/modules/mavproxy_chat/assistant_setup/setup_assistant.py index 9e42c2aef7..a351c1f815 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/setup_assistant.py +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/setup_assistant.py @@ -1,271 +1,271 @@ -''' -AI Chat Module Setup Assistant -Randy Mackay, December 2023 - -This script is used to setup the OpenAI assistant for the AI Chat Module. - -OpenAI Assistant API: https://platform.openai.com/docs/api-reference/assistants -OpenAI Assistant Playground: https://platform.openai.com/playground - -AP_FLAKE8_CLEAN -''' - -import requests -import glob -import json -import xmltodict -import os - -try: - from openai import OpenAI -except Exception: - print("chat: failed to import openai. See https://ardupilot.org/mavproxy/docs/modules/chat.html") - exit() - - -# main function -def main(openai_api_key=None, assistant_name=None, model_name=None, upgrade=False): - - print("Starting assistant setup") - - # create connection object - try: - # if api key is provided, use it to create connection object - if openai_api_key is not None: - client = OpenAI(api_key=openai_api_key) - else: - # if no api key is provided, attempt to create connection object without it - # user may have set the OPENAI_API_KEY environment variable - client = OpenAI() - except Exception: - # if connection object creation fails, exit with error message - print("setup_assistant: failed to connect to OpenAI. Perhaps the API key was incorrect?") - exit() - - # use assistant name if provided, otherwise use default - if assistant_name is None: - assistant_name = "ArduPilot Vehicle Control via MAVLink" - - # use model name if provided, otherwise use default - if model_name is None: - model_name = "gpt-4o" - - # check that assistant_instructions.txt file exists - instructions_filename = os.path.join(os.getcwd(), "assistant_instructions.txt") - if not os.path.isfile(instructions_filename): - print("setup_assistant: " + instructions_filename + " not found") - exit() - - # check that at least one text file exists. E.g. text files holding the flight mode number to name mappings - text_filenames = glob.glob(os.path.join(os.getcwd(), "*.txt")) - if len(text_filenames) == 0: - print("setup_assistant: no txt files found") - exit() - - # check function definition files exist - function_filenames = glob.glob(os.path.join(os.getcwd(), "*.json")) - if len(function_filenames) == 0: - print("setup_assistant: no function json files found") - exit() - - # parse function definition files - function_tools = [{"type": "file_search"}] - for function_filename in function_filenames: - try: - # skip over files with xml in the name - if "xml" in function_filename: - print("skipping xml file: " + os.path.basename(function_filename)) - continue - function_file = open(function_filename, 'r') - function_object = json.load(function_file) - function_tools.append(function_object) - print("setup_assistant: parsed function file: " + os.path.basename(function_filename)) - except Exception: - print("setup_assistant: failed to parse json file: " + function_filename) - exit() - - # check that at least one function was parsed - if len(function_tools) == 0: - print("setup_assistant: no function json files found") - exit() - - # download latest MAVLink files from ardupilot MAVLink repo, minimal.xml, common.xml and ardupilotmega.xml - # convert to xml so they can be accessed by the assistant - mavlink_filenames = ["minimal.xml", "common.xml", "ardupilotmega.xml"] - mavlink_filenames_json = [] - for mavlink_filename in mavlink_filenames: - if not download_file("https://raw.githubusercontent.com/ArduPilot/mavlink/master/message_definitions/v1.0/" + mavlink_filename, mavlink_filename): # noqa - exit() - if not convert_xml_to_json(mavlink_filename): - exit() - mavlink_filenames_json.append(mavlink_filename + ".json") - - # variable to hold new assistant - assistant = None - - # if assistant exists, use it - assistants_list = client.beta.assistants.list() - for existing_assistant in assistants_list.data: - if existing_assistant.name == assistant_name: - print("setup_assistant: using existing assistant: " + existing_assistant.name + " id:" + existing_assistant.id) - assistant = existing_assistant - break - - # exit if assistant was found but upgrade was not requested - if assistant is not None and not upgrade: - print("setup_assistant: assistant already exists, not upgrading") - exit() - - # if assistant was not found, create it - if assistant is None: - assistant = client.beta.assistants.create(name=assistant_name, model=model_name, tools=function_tools) - print("setup_assistant: created new assistant: " + assistant.name + " id:" + assistant.id) - - # update assistant's instructions - try: - instructions_content = open(instructions_filename, 'r').read() - client.beta.assistants.update(assistant.id, instructions=instructions_content, tools=function_tools) - except Exception: - print("setup_assistant: failed to update assistant instructions") - exit() - - # upload MAVLink and text files - existing_files = client.files.list() - uploaded_file_ids = [] - for filename in text_filenames + mavlink_filenames_json: - try: - # open local file as read-only - file = open(filename, 'rb') - except Exception: - print("setup_assistant: failed to open file: " + filename) - exit() - - # check if OpenAI has existing files with the same name - filename_short = os.path.basename(filename) - file_needs_uploading = True - for existing_file in existing_files: - if filename_short == existing_file.filename: - # if not upgrading, we associate the existing file with our assistant - if not upgrade: - uploaded_file_ids.append(existing_file.id) - print("setup_assistant: using existing file: " + existing_file.filename) - file_needs_uploading = False - else: - # if upgrading them we delete and re-upload the file - # Note: this is slightly dangerous because files in use by another assistant could be deleted - try: - client.files.delete(existing_file.id) - print("setup_assistant: deleted existing file: " + existing_file.filename) - except Exception: - print("setup_assistant: failed to delete file from OpenAI: " + existing_file.filename) - exit() - - # upload file to OpenAI - if file_needs_uploading: - try: - uploaded_file = client.files.create(file=file, purpose="assistants") - uploaded_file_ids.append(uploaded_file.id) - print("setup_assistant: uploaded: " + filename_short) - except Exception: - print("setup_assistant: failed to upload file to OpenAI: " + filename) - exit() - - # delete and recreate a vector store on OpenAI - vector_store_name = assistant_name + " vector_store" - try: - # retrieve list of vector stores - vector_store_list = client.beta.vector_stores.list() - for vs in vector_store_list: - - # check for valid names - vs_name = vs.name - if vs_name is None: - vs_name = "no name" - - # delete empty vector stores - if vs.file_counts.total == 0: - print("deleting empty vector store id:" + vs.id + " name:" + vs_name) - client.beta.vector_stores.delete(vector_store_id=vs.id) - continue - - # delete our assistant's vector store if found - if vs_name == vector_store_name: - print("deleting existing vector store id:" + vs.id + " name:" + vs_name) - client.beta.vector_stores.delete(vector_store_id=vs.id) - break - - # create vector store for our assistant - vector_store = client.beta.vector_stores.create(name=vector_store_name, file_ids=uploaded_file_ids) - print("setup_assistant: created vector store id: " + vector_store.id + - " name:" + vector_store_name + " files:" + str(vector_store.file_counts.total)) - - except Exception as e: - print("setup_assistant: failed to create vector store" + e) - exit() - - # update assistant to use the vector store - try: - print("setup_assistant: updating assistant vector store to id:" + vector_store.id + " name:" + vector_store_name) - client.beta.assistants.update(assistant.id, tool_resources={"file_search": {"vector_store_ids": [vector_store.id]}}) - except Exception: - print("setup_assistant: failed to update assistant vector store") - exit() - - # delete downloaded mavlink files - for mavlink_filename in mavlink_filenames + mavlink_filenames_json: - try: - os.remove(mavlink_filename) - print("setup_assistant: deleted local file: " + mavlink_filename) - except Exception: - print("setup_assistant: failed to delete file: " + mavlink_filename) - - # print completion message - print("Assistant setup complete") - - -def download_file(url, filename): - # download file from url to filename - # return True if successful, False if not - try: - response = requests.get(url) - if response.ok: - file = open(os.path.join(os.getcwd(), filename), 'wb') - file.write(response.content) - file.close() - print("setup_assistant: downloaded file: " + filename) - return True - else: - print("setup_assistant: failed to download file: " + url) - return False - except Exception: - print("setup_assistant: failed to download file: " + url) - return False - - -def convert_xml_to_json(filename): - # convert xml file to json file - # return True if successful, False if not - try: - xml_file = open(filename) - xml_file_dict = xmltodict.parse(xml_file.read()) - xml_file_json = json.dumps(xml_file_dict) - json_file = open(filename + ".json", "w") - json_file.write(xml_file_json) - return True - except Exception: - print("setup_assistant: failed to convert xml to json: " + filename) - return False - - -# call main function if this is run as standalone script -if __name__ == "__main__": - - # parse command line arguments - from argparse import ArgumentParser - parser = ArgumentParser(description="MAVProxy AI chat module OpenAI Assistant setup script") - parser.add_argument("--api-key", default=None, help="OpenAI API Key") - parser.add_argument("--name", default=None, help="Assistant name") - parser.add_argument("--model", default=None, help="model name") - parser.add_argument("--upgrade", action='store_true', help="upgrade existing assistant") - args = parser.parse_args() - main(openai_api_key=args.api_key, assistant_name=args.name, model_name=args.model, upgrade=args.upgrade) +''' +AI Chat Module Setup Assistant +Randy Mackay, December 2023 + +This script is used to setup the OpenAI assistant for the AI Chat Module. + +OpenAI Assistant API: https://platform.openai.com/docs/api-reference/assistants +OpenAI Assistant Playground: https://platform.openai.com/playground + +AP_FLAKE8_CLEAN +''' + +import requests +import glob +import json +import xmltodict +import os + +try: + from openai import OpenAI +except Exception: + print("chat: failed to import openai. See https://ardupilot.org/mavproxy/docs/modules/chat.html") + exit() + + +# main function +def main(openai_api_key=None, assistant_name=None, model_name=None, upgrade=False): + + print("Starting assistant setup") + + # create connection object + try: + # if api key is provided, use it to create connection object + if openai_api_key is not None: + client = OpenAI(api_key=openai_api_key) + else: + # if no api key is provided, attempt to create connection object without it + # user may have set the OPENAI_API_KEY environment variable + client = OpenAI() + except Exception: + # if connection object creation fails, exit with error message + print("setup_assistant: failed to connect to OpenAI. Perhaps the API key was incorrect?") + exit() + + # use assistant name if provided, otherwise use default + if assistant_name is None: + assistant_name = "ArduPilot Vehicle Control via MAVLink" + + # use model name if provided, otherwise use default + if model_name is None: + model_name = "gpt-4o" + + # check that assistant_instructions.txt file exists + instructions_filename = os.path.join(os.getcwd(), "assistant_instructions.txt") + if not os.path.isfile(instructions_filename): + print("setup_assistant: " + instructions_filename + " not found") + exit() + + # check that at least one text file exists. E.g. text files holding the flight mode number to name mappings + text_filenames = glob.glob(os.path.join(os.getcwd(), "*.txt")) + if len(text_filenames) == 0: + print("setup_assistant: no txt files found") + exit() + + # check function definition files exist + function_filenames = glob.glob(os.path.join(os.getcwd(), "*.json")) + if len(function_filenames) == 0: + print("setup_assistant: no function json files found") + exit() + + # parse function definition files + function_tools = [{"type": "file_search"}] + for function_filename in function_filenames: + try: + # skip over files with xml in the name + if "xml" in function_filename: + print("skipping xml file: " + os.path.basename(function_filename)) + continue + function_file = open(function_filename, 'r') + function_object = json.load(function_file) + function_tools.append(function_object) + print("setup_assistant: parsed function file: " + os.path.basename(function_filename)) + except Exception: + print("setup_assistant: failed to parse json file: " + function_filename) + exit() + + # check that at least one function was parsed + if len(function_tools) == 0: + print("setup_assistant: no function json files found") + exit() + + # download latest MAVLink files from ardupilot MAVLink repo, minimal.xml, common.xml and ardupilotmega.xml + # convert to xml so they can be accessed by the assistant + mavlink_filenames = ["minimal.xml", "common.xml", "ardupilotmega.xml"] + mavlink_filenames_json = [] + for mavlink_filename in mavlink_filenames: + if not download_file("https://raw.githubusercontent.com/ArduPilot/mavlink/master/message_definitions/v1.0/" + mavlink_filename, mavlink_filename): # noqa + exit() + if not convert_xml_to_json(mavlink_filename): + exit() + mavlink_filenames_json.append(mavlink_filename + ".json") + + # variable to hold new assistant + assistant = None + + # if assistant exists, use it + assistants_list = client.beta.assistants.list() + for existing_assistant in assistants_list.data: + if existing_assistant.name == assistant_name: + print("setup_assistant: using existing assistant: " + existing_assistant.name + " id:" + existing_assistant.id) + assistant = existing_assistant + break + + # exit if assistant was found but upgrade was not requested + if assistant is not None and not upgrade: + print("setup_assistant: assistant already exists, not upgrading") + exit() + + # if assistant was not found, create it + if assistant is None: + assistant = client.beta.assistants.create(name=assistant_name, model=model_name, tools=function_tools) + print("setup_assistant: created new assistant: " + assistant.name + " id:" + assistant.id) + + # update assistant's instructions + try: + instructions_content = open(instructions_filename, 'r').read() + client.beta.assistants.update(assistant.id, instructions=instructions_content, tools=function_tools) + except Exception: + print("setup_assistant: failed to update assistant instructions") + exit() + + # upload MAVLink and text files + existing_files = client.files.list() + uploaded_file_ids = [] + for filename in text_filenames + mavlink_filenames_json: + try: + # open local file as read-only + file = open(filename, 'rb') + except Exception: + print("setup_assistant: failed to open file: " + filename) + exit() + + # check if OpenAI has existing files with the same name + filename_short = os.path.basename(filename) + file_needs_uploading = True + for existing_file in existing_files: + if filename_short == existing_file.filename: + # if not upgrading, we associate the existing file with our assistant + if not upgrade: + uploaded_file_ids.append(existing_file.id) + print("setup_assistant: using existing file: " + existing_file.filename) + file_needs_uploading = False + else: + # if upgrading them we delete and re-upload the file + # Note: this is slightly dangerous because files in use by another assistant could be deleted + try: + client.files.delete(existing_file.id) + print("setup_assistant: deleted existing file: " + existing_file.filename) + except Exception: + print("setup_assistant: failed to delete file from OpenAI: " + existing_file.filename) + exit() + + # upload file to OpenAI + if file_needs_uploading: + try: + uploaded_file = client.files.create(file=file, purpose="assistants") + uploaded_file_ids.append(uploaded_file.id) + print("setup_assistant: uploaded: " + filename_short) + except Exception: + print("setup_assistant: failed to upload file to OpenAI: " + filename) + exit() + + # delete and recreate a vector store on OpenAI + vector_store_name = assistant_name + " vector_store" + try: + # retrieve list of vector stores + vector_store_list = client.beta.vector_stores.list() + for vs in vector_store_list: + + # check for valid names + vs_name = vs.name + if vs_name is None: + vs_name = "no name" + + # delete empty vector stores + if vs.file_counts.total == 0: + print("deleting empty vector store id:" + vs.id + " name:" + vs_name) + client.beta.vector_stores.delete(vector_store_id=vs.id) + continue + + # delete our assistant's vector store if found + if vs_name == vector_store_name: + print("deleting existing vector store id:" + vs.id + " name:" + vs_name) + client.beta.vector_stores.delete(vector_store_id=vs.id) + break + + # create vector store for our assistant + vector_store = client.beta.vector_stores.create(name=vector_store_name, file_ids=uploaded_file_ids) + print("setup_assistant: created vector store id: " + vector_store.id + + " name:" + vector_store_name + " files:" + str(vector_store.file_counts.total)) + + except Exception as e: + print("setup_assistant: failed to create vector store" + e) + exit() + + # update assistant to use the vector store + try: + print("setup_assistant: updating assistant vector store to id:" + vector_store.id + " name:" + vector_store_name) + client.beta.assistants.update(assistant.id, tool_resources={"file_search": {"vector_store_ids": [vector_store.id]}}) + except Exception: + print("setup_assistant: failed to update assistant vector store") + exit() + + # delete downloaded mavlink files + for mavlink_filename in mavlink_filenames + mavlink_filenames_json: + try: + os.remove(mavlink_filename) + print("setup_assistant: deleted local file: " + mavlink_filename) + except Exception: + print("setup_assistant: failed to delete file: " + mavlink_filename) + + # print completion message + print("Assistant setup complete") + + +def download_file(url, filename): + # download file from url to filename + # return True if successful, False if not + try: + response = requests.get(url) + if response.ok: + file = open(os.path.join(os.getcwd(), filename), 'wb') + file.write(response.content) + file.close() + print("setup_assistant: downloaded file: " + filename) + return True + else: + print("setup_assistant: failed to download file: " + url) + return False + except Exception: + print("setup_assistant: failed to download file: " + url) + return False + + +def convert_xml_to_json(filename): + # convert xml file to json file + # return True if successful, False if not + try: + xml_file = open(filename) + xml_file_dict = xmltodict.parse(xml_file.read()) + xml_file_json = json.dumps(xml_file_dict) + json_file = open(filename + ".json", "w") + json_file.write(xml_file_json) + return True + except Exception: + print("setup_assistant: failed to convert xml to json: " + filename) + return False + + +# call main function if this is run as standalone script +if __name__ == "__main__": + + # parse command line arguments + from argparse import ArgumentParser + parser = ArgumentParser(description="MAVProxy AI chat module OpenAI Assistant setup script") + parser.add_argument("--api-key", default=None, help="OpenAI API Key") + parser.add_argument("--name", default=None, help="Assistant name") + parser.add_argument("--model", default=None, help="model name") + parser.add_argument("--upgrade", action='store_true', help="upgrade existing assistant") + args = parser.parse_args() + main(openai_api_key=args.api_key, assistant_name=args.name, model_name=args.model, upgrade=args.upgrade) diff --git a/MAVProxy/modules/mavproxy_chat/assistant_setup/sub_modes.txt b/MAVProxy/modules/mavproxy_chat/assistant_setup/sub_modes.txt index 6238988903..ef3eae87ad 100644 --- a/MAVProxy/modules/mavproxy_chat/assistant_setup/sub_modes.txt +++ b/MAVProxy/modules/mavproxy_chat/assistant_setup/sub_modes.txt @@ -1,12 +1,12 @@ -This file holds the Sub (aka submarine) mode name to number mapping. - -STABILIZE = 0, // manual angle with manual depth/throttle -ACRO = 1, // manual body-frame angular rate with manual depth/throttle -ALT_HOLD = 2, // manual angle with automatic depth/throttle -AUTO = 3, // fully automatic waypoint control using mission commands -GUIDED = 4, // fully automatic fly to coordinate or fly at velocity/direction using GCS immediate commands -CIRCLE = 7, // automatic circular flight with automatic throttle -SURFACE = 9, // automatically return to surface, pilot maintains horizontal control -POSHOLD = 16, // automatic position hold with manual override, with automatic throttle -MANUAL = 19, // Pass-through input with no stabilization -MOTOR_DETECT = 20 // Automatically detect motors orientation +This file holds the Sub (aka submarine) mode name to number mapping. + +STABILIZE = 0, // manual angle with manual depth/throttle +ACRO = 1, // manual body-frame angular rate with manual depth/throttle +ALT_HOLD = 2, // manual angle with automatic depth/throttle +AUTO = 3, // fully automatic waypoint control using mission commands +GUIDED = 4, // fully automatic fly to coordinate or fly at velocity/direction using GCS immediate commands +CIRCLE = 7, // automatic circular flight with automatic throttle +SURFACE = 9, // automatically return to surface, pilot maintains horizontal control +POSHOLD = 16, // automatic position hold with manual override, with automatic throttle +MANUAL = 19, // Pass-through input with no stabilization +MOTOR_DETECT = 20 // Automatically detect motors orientation