add minimax support
This commit is contained in:
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.watcherExclude": {
|
||||
"**/target": true
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"selected_provider": "TSSC",
|
||||
"selected_provider": "MiniMax",
|
||||
"provider_configs": {
|
||||
"Ollama": {
|
||||
"type": "ollama",
|
||||
@@ -65,6 +65,22 @@
|
||||
"allow_endpoint_edit": true,
|
||||
"allow_api_toggle": true,
|
||||
"system_prompt": "You are a very friendly drone control agent. No matter what language I use to give you instructions, please call the tools to perform the task and then reply in English."
|
||||
},
|
||||
"MiniMax": {
|
||||
"type": "openai-compatible",
|
||||
"base_url": "https://api.minimaxi.com/v1",
|
||||
"models_endpoint": "/v1/models",
|
||||
"chat_endpoint": "/v1/chat/completions",
|
||||
"requires_api_key": true,
|
||||
"api_key": "sk-api-JmFQPSmEc0ErvwEHHJYEkP17TPqpxCx6yK2yS9rU4pBP9eMmdZKPuOo76z8y-bTcA0XsYY6vam33KGM53kQ5GInRCb1clhlNm1Mq-Fq1-CTZQDNXYhYxu7c",
|
||||
"encoding": "utf-8",
|
||||
"default_model": "MiniMax-M2.1",
|
||||
"default_models": [
|
||||
"MiniMax-M2.1"
|
||||
],
|
||||
"allow_endpoint_edit": true,
|
||||
"allow_api_toggle": true,
|
||||
"system_prompt": "You are a very friendly drone control agent. No matter what language I use to give you instructions, please call the tools to perform the task and then reply in English."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,5 +15,6 @@ REMINDER - Action Input must be valid JSON:
|
||||
- For multiple parameters: {{"drone_id": "drone-001", "altitude": 15.0}}
|
||||
- Numbers WITHOUT quotes, strings WITH quotes
|
||||
- We put your answer to langchain, so if you want to return {{ or }}, return double of the characters.
|
||||
- When the task is done, output "Final Answer:\n[TASK DONE]"
|
||||
|
||||
Please try again with proper JSON format."""
|
||||
|
||||
140
tp
140
tp
@@ -1,140 +0,0 @@
|
||||
These are all the APIs you can use.
|
||||
|
||||
Drone Management
|
||||
|
||||
| Method | Endpoint | Description |
|
||||
|--------|----------|-------------|
|
||||
| GET | `/drones` | List all drones |
|
||||
| POST | `/drones` | Register new drone |
|
||||
| GET | `/drones/{{id}}` | Get drone details |
|
||||
| PUT | `/drones/{{id}}` | Update drone properties (metadata, state, battery, position, home) |
|
||||
| PUT | `/drones/{{id}}/position` | Update drone position only |
|
||||
| DELETE | `/drones/{{id}}` | Delete drone |
|
||||
| POST | `/drones/{{id}}/battery` | Update battery level |
|
||||
|
||||
Command Management
|
||||
|
||||
Generic Command Endpoint
|
||||
|
||||
| Method | Endpoint | Description |
|
||||
|--------|----------|-------------|
|
||||
| POST | `/drones/{{id}}/command` | Send any command |
|
||||
| GET | `/drones/{{id}}/commands` | Get command history |
|
||||
| GET | `/commands/{{command_id}}` | Get command status |
|
||||
|
||||
Direct Command Endpoints
|
||||
|
||||
All commands use **POST** method with `/drones/{{id}}/command/{{command_name}}`
|
||||
|
||||
Charge can only done at Waypoint target.
|
||||
|
||||
| Command | Parameters | Description |
|
||||
|---------|-----------|-------------|
|
||||
| `take_off` | `?altitude=10.0` | Takeoff to altitude |
|
||||
| `land` | - | Land at position |
|
||||
| `move_to` | `?x=50&y=50&z=15` | Move to coordinates |
|
||||
| `move_towards` | `?distance=20&heading=90` | Move distance in direction (uses current heading if not specified) |
|
||||
| `move_along_path` | Body: `{{waypoints:[...]}}` | Follow waypoints |
|
||||
| `change_altitude` | `?altitude=20.0` | Change altitude only |
|
||||
| `hover` | `duration` (optional) | Hold position |
|
||||
| `rotate` | `?heading=180.0` | Change heading/orientation |
|
||||
| `return_home` | - | Return to launch |
|
||||
| `set_home` | - | Set home position |
|
||||
| `calibrate` | - | Calibrate sensors |
|
||||
| `take_photo` | - | Capture image |
|
||||
| `send_message` | `?target_drone_id=X&message=Y` | Send to drone |
|
||||
| `broadcast` | `?message=text` | Send to all |
|
||||
| `charge` | `?charge_amount=30.0` | Charge battery |
|
||||
|
||||
Target Management
|
||||
|
||||
Type of target we have fixed, moving, waypoint, circle, polygon. - Note: fixed type can also represent points of interest
|
||||
|
||||
| Method | Endpoint | Description |
|
||||
|--------|----------|-------------|
|
||||
| GET | `/targets` | List all targets |
|
||||
| GET | `/targets/{{id}}` | Get target details |
|
||||
| GET | `/targets/type/{{type}}` | Get by type |
|
||||
|
||||
Waypoint Endpoints
|
||||
|
||||
| Method | Endpoint | Description |
|
||||
|--------|----------|-------------|
|
||||
| GET | `/targets/waypoints` | List charging stations |
|
||||
| POST | `/targets/waypoints/{{id}}/check-drone` | Check if drone at waypoint |
|
||||
| GET | `/targets/waypoints/nearest` | Find nearest waypoint |
|
||||
|
||||
Obstacle Management
|
||||
|
||||
Type of obstacle we hvave point, circle, ellipse, polygon.
|
||||
|
||||
| Method | Endpoint | Description |
|
||||
|--------|----------|-------------|
|
||||
| GET | `/obstacles` | List all obstacles |
|
||||
| GET | `/obstacles/{{id}}` | Get obstacle |
|
||||
| GET | `/obstacles/type/{{type}}` | Get by type |
|
||||
|
||||
Collision Detection
|
||||
|
||||
**Endpoint:** `POST /obstacles/path_collision`
|
||||
|
||||
**Authentication:** Requires SYSTEM role (ADMIN inherits)
|
||||
|
||||
**Description:** Checks if a flight path from start to end collides with any obstacles. Returns the **first** obstacle that collides with the path.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Name | Type | Required | Description |
|
||||
|------|------|----------|-------------|
|
||||
| start | object | Yes | Start point {{x, y, z}} |
|
||||
| end | object | Yes | End point {{x, y, z}} |
|
||||
| safety_margin | float | No | Additional clearance distance (in meters) around the flight path (default: 0.0). Creates a corridor with specified width on each side. Use 0.0 for direct line path, or > 0.0 for safety corridor (e.g., 5.0 creates a 10m-wide corridor). Note: Drone movement commands use 0.0 by default |
|
||||
|
||||
**Height Logic:**
|
||||
- `height = 0`: Impassable at any altitude
|
||||
- `height > 0`: Collision only if max flight altitude <= obstacle.height
|
||||
|
||||
**Response:** Collision response object or null if no collision
|
||||
|
||||
**Example Request:**
|
||||
```bash
|
||||
curl -X POST http://localhost:8000/obstacles/path_collision \\
|
||||
-H "Content-Type: application/json" \\
|
||||
-H "X-API-Key: system_secret_key_change_in_production" \\
|
||||
-d '{{
|
||||
"start": {{"x": 0.0, "y": 0.0, "z": 10.0}},
|
||||
"end": {{"x": 200.0, "y": 300.0, "z": 10.0}},
|
||||
"safety_margin": 2.0
|
||||
}}'
|
||||
```
|
||||
|
||||
**Example Response (Collision):**
|
||||
```json
|
||||
{{
|
||||
"obstacle_id": "550e8400-e29b-41d4-a716-446655440001",
|
||||
"obstacle_name": "Water Tower",
|
||||
"obstacle_type": "circle",
|
||||
"collision_type": "path_intersection",
|
||||
"distance": 5.0
|
||||
}}
|
||||
```
|
||||
|
||||
**Example Response (No Collision):**
|
||||
```json
|
||||
null
|
||||
```
|
||||
|
||||
| Method | Endpoint | Description | Auth |
|
||||
|--------|----------|-------------|------|
|
||||
| POST | `/obstacles/path_collision` | Check if flight path collides with obstacles | SYSTEM |
|
||||
| POST | `/obstacles/point_collision` | Check if point is inside any obstacles (returns all matches) | SYSTEM |
|
||||
|
||||
Proximity
|
||||
|
||||
| Method | Endpoint | Description |
|
||||
|--------|----------|-------------|
|
||||
| GET | `/drones/{{id}}/nearby` | Aggregated nearby drones, targets, obstacles (uses drone's perceived_radius) |
|
||||
| GET | `/drones/{{id}}/nearby/drones` | Nearby drones (uses drone's perceived_radius) |
|
||||
| GET | `/drones/{{id}}/nearby/targets` | Nearby targets (uses drone's perceived_radius) |
|
||||
| GET | `/drones/{{id}}/nearby/obstacles` | Nearby obstacles (uses drone's perceived_radius) |
|
||||
All proximity endpoints use the drone's `perceived_radius` to determine the search area.
|
||||
@@ -405,6 +405,7 @@ Drones: {len(drones)} available
|
||||
Returns:
|
||||
Dictionary with 'output', 'intermediate_steps', and 'success' keys
|
||||
"""
|
||||
|
||||
if self.debug:
|
||||
print(f"\n{'='*60}")
|
||||
print(f"🎯 Executing Command")
|
||||
|
||||
@@ -118,9 +118,9 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
"""Get detailed status of a specific drone including position, battery, heading, and visited targets.
|
||||
|
||||
Input should be a JSON string with:
|
||||
- drone_id: The ID of the drone (required)
|
||||
- drone_id: The ID of the drone (required, get from Action list_drones)
|
||||
|
||||
Example: {{"drone_id": "drone-001"}}
|
||||
Example: {{"drone_id": "04d6cfe7"}}
|
||||
"""
|
||||
try:
|
||||
params = json.loads(input_json) if isinstance(input_json, str) else input_json
|
||||
@@ -141,7 +141,7 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
"""Get drones, targets, and obstacles near a specific drone (within its perception radius).
|
||||
|
||||
Input should be a JSON string with:
|
||||
- drone_id: The ID of the drone (required)
|
||||
- drone_id: The ID of the drone (required, get from Action list_drones)
|
||||
|
||||
Example: {{"drone_id": "drone-001"}}
|
||||
"""
|
||||
@@ -164,7 +164,7 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
"""Command a drone to land at its current position.
|
||||
|
||||
Input should be a JSON string with:
|
||||
- drone_id: The ID of the drone (required)
|
||||
- drone_id: The ID of the drone (required, get from Action list_drones)
|
||||
|
||||
Example: {{"drone_id": "drone-001"}}
|
||||
"""
|
||||
@@ -187,7 +187,7 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
"""Command a drone to hover at its current position.
|
||||
|
||||
Input should be a JSON string with:
|
||||
- drone_id: The ID of the drone (required)
|
||||
- drone_id: The ID of the drone (required, get from Action list_drones)
|
||||
- duration: Optional duration in seconds to hover (optional)
|
||||
|
||||
Example: {{"drone_id": "drone-001", "duration": 5.0}}
|
||||
@@ -212,7 +212,7 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
"""Command a drone to return to its home position.
|
||||
|
||||
Input should be a JSON string with:
|
||||
- drone_id: The ID of the drone (required)
|
||||
- drone_id: The ID of the drone (required, get from Action list_drones)
|
||||
|
||||
Example: {{"drone_id": "drone-001"}}
|
||||
"""
|
||||
@@ -235,7 +235,7 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
"""Set the drone's current position as its new home position.
|
||||
|
||||
Input should be a JSON string with:
|
||||
- drone_id: The ID of the drone (required)
|
||||
- drone_id: The ID of the drone (required, get from Action list_drones)
|
||||
|
||||
Example: {{"drone_id": "drone-001"}}
|
||||
"""
|
||||
@@ -258,7 +258,7 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
"""Calibrate the drone's sensors.
|
||||
|
||||
Input should be a JSON string with:
|
||||
- drone_id: The ID of the drone (required)
|
||||
- drone_id: The ID of the drone (required, get from Action list_drones)
|
||||
|
||||
Example: {{"drone_id": "drone-001"}}
|
||||
"""
|
||||
@@ -281,7 +281,7 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
"""Command a drone to take a photo.
|
||||
|
||||
Input should be a JSON string with:
|
||||
- drone_id: The ID of the drone (required)
|
||||
- drone_id: The ID of the drone (required, get from Action list_drones)
|
||||
|
||||
Example: {{"drone_id": "drone-001"}}
|
||||
"""
|
||||
@@ -307,7 +307,7 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
Drone must be on ground (idle or ready status).
|
||||
|
||||
Input should be a JSON string with:
|
||||
- drone_id: The ID of the drone (required)
|
||||
- drone_id: The ID of the drone (required, get from Action list_drones)
|
||||
- altitude: Target altitude in meters (optional, default: 10.0)
|
||||
|
||||
Example: {{"drone_id": "drone-001", "altitude": 15.0}}
|
||||
@@ -332,7 +332,7 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
"""Change a drone's altitude while maintaining X/Y position.
|
||||
|
||||
Input should be a JSON string with:
|
||||
- drone_id: The ID of the drone (required)
|
||||
- drone_id: The ID of the drone (required, get from Action list_drones)
|
||||
- altitude: Target altitude in meters (required)
|
||||
|
||||
Example: {{"drone_id": "drone-001", "altitude": 20.0}}
|
||||
@@ -360,7 +360,7 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
0=North, 90=East, 180=South, 270=West.
|
||||
|
||||
Input should be a JSON string with:
|
||||
- drone_id: The ID of the drone (required)
|
||||
- drone_id: The ID of the drone (required, get from Action list_drones)
|
||||
- heading: Target heading in degrees 0-360 (required)
|
||||
|
||||
Example: {{"drone_id": "drone-001", "heading": 90.0}}
|
||||
@@ -387,8 +387,8 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
"""Send a message from one drone to another.
|
||||
|
||||
Input should be a JSON string with:
|
||||
- drone_id: The ID of the sender drone (required)
|
||||
- target_drone_id: The ID of the recipient drone (required)
|
||||
- drone_id: The ID of the sender drone (required, get from Action list_drones)
|
||||
- target_drone_id: The ID of the recipient drone (required, get from Action list_drones)
|
||||
- message: The message content (required)
|
||||
|
||||
Example: {{"drone_id": "drone-001", "target_drone_id": "drone-002", "message": "Hello"}}
|
||||
@@ -418,7 +418,7 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
"""Broadcast a message from one drone to all other drones.
|
||||
|
||||
Input should be a JSON string with:
|
||||
- drone_id: The ID of the sender drone (required)
|
||||
- drone_id: The ID of the sender drone (required, get from Action list_drones)
|
||||
- message: The message content (required)
|
||||
|
||||
Example: {{"drone_id": "drone-001", "message": "Alert"}}
|
||||
@@ -446,7 +446,7 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
Drone must be landed at a charging station.
|
||||
|
||||
Input should be a JSON string with:
|
||||
- drone_id: The ID of the drone (required)
|
||||
- drone_id: The ID of the drone (required, get from Action list_drones)
|
||||
- charge_amount: Amount to charge in percent (required)
|
||||
|
||||
Example: {{"drone_id": "drone-001", "charge_amount": 25.0}}
|
||||
@@ -473,7 +473,7 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
"""Move a drone a specific distance in a direction.
|
||||
|
||||
Input should be a JSON string with:
|
||||
- drone_id: The ID of the drone (required)
|
||||
- drone_id: The ID of the drone (required, get from Action list_drones)
|
||||
- distance: Distance to move in meters (required)
|
||||
- heading: Heading direction in degrees 0-360 (optional, default: current heading)
|
||||
- dz: Vertical component in meters (optional)
|
||||
@@ -578,6 +578,8 @@ def create_uav_tools(client: UAVAPIClient) -> list:
|
||||
return "Error: x, y, and z coordinates are required"
|
||||
|
||||
result = client.move_to(drone_id, x, y, z)
|
||||
if result["status"] == "error":
|
||||
result["message"] += " 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."
|
||||
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\", \"x\": 100.0, \"y\": 50.0, \"z\": 20.0}}"
|
||||
|
||||
Reference in New Issue
Block a user