Skip to content

Commit

Permalink
chat: flake fixes - WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rmackay9 committed Jan 3, 2024
1 parent eacee97 commit 0b7a699
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 2 additions & 0 deletions MAVProxy/modules/mavproxy_chat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from threading import Thread
import time


class chat(mp_module.MPModule):
def __init__(self, mpstate):

Expand Down Expand Up @@ -110,6 +111,7 @@ def wait_for_command_ack(self, mav_cmd, timeout=1):
del self.command_ack_waiting[mav_cmd]
return False


# initialise module
def init(mpstate):
return chat(mpstate)
13 changes: 6 additions & 7 deletions MAVProxy/modules/mavproxy_chat/chat_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ def handle_function_call(self, run):
run_reply = self.client.beta.threads.runs.submit_tool_outputs(
thread_id=run.thread_id,
run_id=run.id,
tool_outputs=tool_outputs
)
tool_outputs=tool_outputs)
except:
print("chat: error replying to function call")
print(tool_outputs)
Expand Down Expand Up @@ -278,7 +277,7 @@ def get_vehicle_type(self, arguments):
mavutil.mavlink.MAV_TYPE_OCTOROTOR,
mavutil.mavlink.MAV_TYPE_TRICOPTER,
mavutil.mavlink.MAV_TYPE_DODECAROTOR]:
vehicle_type_str = "Copter"
vehicle_type_str = "Copter"
if hearbeat_msg.type == mavutil.mavlink.MAV_TYPE_HELICOPTER:
vehicle_type_str = "Heli"
if hearbeat_msg.type == mavutil.mavlink.MAV_TYPE_ANTENNA_TRACKER:
Expand Down Expand Up @@ -306,7 +305,7 @@ def get_mode_mapping(self, arguments):
# prepare list of modes
mode_list = []
mode_mapping = self.mpstate.master().mode_mapping()

# handle request for all modes
if mode_name is None and mode_number is None:
for mname in mode_mapping:
Expand Down Expand Up @@ -335,7 +334,7 @@ def get_vehicle_state(self, arguments):
hearbeat_msg = self.mpstate.master().messages.get('HEARTBEAT', None)
if hearbeat_msg is None:
mode_number = 0
print ("chat: get_vehicle_state: vehicle mode is unknown")
print("chat: get_vehicle_state: vehicle mode is unknown")
else:
mode_number = hearbeat_msg.custom_mode
return {
Expand Down Expand Up @@ -631,7 +630,7 @@ def wrap_latitude(self, latitude_deg):
if latitude_deg < -90:
return -(180 + latitude_deg)
return latitude_deg

# wrap longitude to range -180 to 180
def wrap_longitude(self, longitude_deg):
if longitude_deg > 180:
Expand All @@ -647,7 +646,7 @@ def send_status(self, status):

# returns true if string contains regex characters
def contains_regex(self, string):
regex_characters = ".^$*+?{}[]\|()"
regex_characters = ".^$*+?{}[]\\|()"
for x in regex_characters:
if string.count(x):
return True
Expand Down

0 comments on commit 0b7a699

Please sign in to comment.