Spaces:
Running
Running
Commit
·
3d90278
1
Parent(s):
e11d6d3
fixes
Browse files- drone/drone_chat.py +45 -43
- main.py +1 -1
drone/drone_chat.py
CHANGED
@@ -137,51 +137,34 @@ class DroneAssistant(CodeAgent):
|
|
137 |
|
138 |
# Add a tool reference guide to help the model use the correct function names
|
139 |
tool_reference = """
|
140 |
-
IMPORTANT: These tool functions need to be called as shown below:
|
141 |
|
|
|
|
|
142 |
# Connect to a drone simulator
|
143 |
connect_to_real_drone('udp:127.0.0.1:14550')
|
144 |
|
145 |
-
# Take off to a specific altitude
|
146 |
-
drone_takeoff(
|
147 |
|
148 |
-
#
|
149 |
-
|
150 |
-
|
151 |
-
# Return to home location
|
152 |
-
drone_return_home()
|
153 |
-
|
154 |
-
# Fly to specific coordinates
|
155 |
-
drone_fly_to(latitude=37.7749, longitude=-122.4194, altitude=30)
|
156 |
-
|
157 |
-
# Get current drone location
|
158 |
-
get_drone_location()
|
159 |
-
|
160 |
-
# Get battery status
|
161 |
-
get_drone_battery()
|
162 |
-
|
163 |
-
# Execute a mission with waypoints
|
164 |
-
# The waypoints parameter should be a list of dictionaries with 'lat', 'lon', and 'alt' keys.
|
165 |
-
execute_drone_mission(waypoints=[
|
166 |
{'lat': 37.7749, 'lon': -122.4194, 'alt': 30},
|
167 |
-
{'lat': 37.7750, 'lon': -122.4195, 'alt':
|
168 |
-
]
|
169 |
-
|
170 |
-
# Disconnect from the drone
|
171 |
-
disconnect_from_drone()
|
172 |
|
173 |
-
#
|
174 |
-
|
175 |
-
generate_mission_plan(mission_type='survey', duration_minutes=20)
|
176 |
|
177 |
-
#
|
178 |
-
|
179 |
|
180 |
-
#
|
181 |
-
|
|
|
182 |
|
183 |
-
|
184 |
-
|
185 |
|
186 |
When creating a flight plan, be sure to:
|
187 |
1. Generate a mission plan with generate_mission_plan()
|
@@ -274,21 +257,40 @@ class DroneAssistant(CodeAgent):
|
|
274 |
# Use the run method directly and capture the output
|
275 |
import time
|
276 |
|
277 |
-
#
|
278 |
-
|
279 |
|
280 |
-
#
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
|
287 |
# Give a slight delay so users can see the "completed" message
|
288 |
time.sleep(1)
|
289 |
|
290 |
# Clear the thinking placeholder
|
291 |
thinking_placeholder.empty()
|
|
|
292 |
|
293 |
return response
|
294 |
else:
|
|
|
137 |
|
138 |
# Add a tool reference guide to help the model use the correct function names
|
139 |
tool_reference = """
|
140 |
+
IMPORTANT: These tool functions need to be called EXACTLY as shown below for successful execution:
|
141 |
|
142 |
+
# EXAMPLE OF COMPLETE WORKING MISSION:
|
143 |
+
```python
|
144 |
# Connect to a drone simulator
|
145 |
connect_to_real_drone('udp:127.0.0.1:14550')
|
146 |
|
147 |
+
# Take off to a specific altitude (always use integer or simple float values)
|
148 |
+
drone_takeoff(30) # Not 30. 0 or other invalid syntax
|
149 |
|
150 |
+
# You can define waypoints like this
|
151 |
+
waypoints = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
{'lat': 37.7749, 'lon': -122.4194, 'alt': 30},
|
153 |
+
{'lat': 37.7750, 'lon': -122.4195, 'alt': 30}
|
154 |
+
]
|
|
|
|
|
|
|
155 |
|
156 |
+
# Execute mission with waypoints
|
157 |
+
execute_drone_mission(waypoints=waypoints)
|
|
|
158 |
|
159 |
+
# Return to home
|
160 |
+
drone_return_home()
|
161 |
|
162 |
+
# Always disconnect when done
|
163 |
+
disconnect_from_drone()
|
164 |
+
```
|
165 |
|
166 |
+
NOTE: Each function must be called individually on its own line, with exact parameter names.
|
167 |
+
For latitude/longitude values, always use simple format without extra spaces after periods.
|
168 |
|
169 |
When creating a flight plan, be sure to:
|
170 |
1. Generate a mission plan with generate_mission_plan()
|
|
|
257 |
# Use the run method directly and capture the output
|
258 |
import time
|
259 |
|
260 |
+
# Create an error placeholder
|
261 |
+
error_placeholder = st.empty()
|
262 |
|
263 |
+
# Add error handling
|
264 |
+
try:
|
265 |
+
# Execute the run
|
266 |
+
response = self.run(message)
|
267 |
+
|
268 |
+
# Display some feedback about the model thinking completion
|
269 |
+
thinking_placeholder.markdown(tools_reference + """
|
270 |
+
<div style="background-color: #111111; border: 1px dashed #00cc00; border-radius: 5px; padding: 8px; margin-bottom: 10px; color: #00cc00; font-family: monospace; font-size: 12px;">
|
271 |
+
<b>MODEL THINKING:</b> Plan completed! Executing drone operations...
|
272 |
+
</div>
|
273 |
+
""", unsafe_allow_html=True)
|
274 |
+
except Exception as e:
|
275 |
+
# Display any errors that occur during execution
|
276 |
+
error_message = f"""
|
277 |
+
<div style="background-color: #330000; border: 1px solid #ff0000; border-radius: 5px; padding: 8px; margin-bottom: 10px; color: #ff0000; font-family: monospace; font-size: 12px;">
|
278 |
+
<b>EXECUTION ERROR:</b> {str(e)}<br>
|
279 |
+
Please try again with correct syntax.
|
280 |
+
</div>
|
281 |
+
"""
|
282 |
+
error_placeholder.markdown(error_message, unsafe_allow_html=True)
|
283 |
+
response = f"Error executing drone operations: {str(e)}. Please try again with proper syntax for parameters."
|
284 |
+
|
285 |
+
# Update mission status to show error
|
286 |
+
update_mission_status("ERROR", f"Code execution error: {str(e)}")
|
287 |
|
288 |
# Give a slight delay so users can see the "completed" message
|
289 |
time.sleep(1)
|
290 |
|
291 |
# Clear the thinking placeholder
|
292 |
thinking_placeholder.empty()
|
293 |
+
error_placeholder.empty()
|
294 |
|
295 |
return response
|
296 |
else:
|
main.py
CHANGED
@@ -87,7 +87,7 @@ def show_auth_screen():
|
|
87 |
st.markdown("<hr style='border: 1px solid #00ff00; margin: 10px 0;'>", unsafe_allow_html=True)
|
88 |
|
89 |
# Token input with custom styling
|
90 |
-
st.markdown("<h3 style='color: #00ff00; font-family: \"Courier New\", monospace; text-shadow: 0 0 5px #00ff00;'>ENTER AUTHENTICATION TOKEN:</h3>", unsafe_allow_html=True)
|
91 |
|
92 |
# Create a container with dark background for the input
|
93 |
st.markdown("<div style='background-color: #0A0A0A; padding: 10px; border-radius: 5px;'>", unsafe_allow_html=True)
|
|
|
87 |
st.markdown("<hr style='border: 1px solid #00ff00; margin: 10px 0;'>", unsafe_allow_html=True)
|
88 |
|
89 |
# Token input with custom styling
|
90 |
+
st.markdown("<h3 style='color: #00ff00; font-family: \"Courier New\", monospace; text-shadow: 0 0 5px #00ff00;'>ENTER HUGGING FACE AUTHENTICATION TOKEN FOR THE LLM TO RUN:</h3>", unsafe_allow_html=True)
|
91 |
|
92 |
# Create a container with dark background for the input
|
93 |
st.markdown("<div style='background-color: #0A0A0A; padding: 10px; border-radius: 5px;'>", unsafe_allow_html=True)
|