Skip to content

Commit

Permalink
ai is to stupid to understand device so i literally give up
Browse files Browse the repository at this point in the history
  • Loading branch information
K7theCompSciMan committed Aug 5, 2024
1 parent 3ec3d06 commit 64b5be4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions client/py/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ def handle_ai(text, group, client, client_devices, server_devices):
server_devices_updated = [{'name': x['name'], 'deviceCommands': x['deviceCommands']} for x in server_devices]
mod_text = text + f" | {client_devices_updated} | {server_devices_updated} "
filtered_text, group['aiMessages'] = send_to_ai(mod_text, group['aiMessages'], client)
if "[RUN COMMAND ON DEVICE: " in filtered_text:
device_name = filtered_text.split("[RUN COMMAND ON DEVICE: ")[1].split("]")[0]
return filtered_text, device_name, group
if "RUN COMMAND ON DEVICE: " in filtered_text:
new_text = filtered_text.split("|| ")[1].split(" ||")[0]
device_name = new_text.split("RUN COMMAND ON DEVICE: ")[1].split(" |")[0]
print(f"text: {new_text}, device name {device_name} ")
return new_text, device_name, group
return filtered_text, "", group
def send_to_ai(message, messages: list, client: OpenAI):
messages.append({"role": "user", "content": message})
Expand Down Expand Up @@ -81,7 +83,7 @@ def main():
text = listen()
if text:
filtered_text, device_name, updated_group = handle_ai(text, group, client, client_devices, server_devices)
if f"[RUN COMMAND ON DEVICE: {device_name}]" in filtered_text and (
if f"RUN COMMAND ON DEVICE: {device_name} |" in filtered_text and (
device_name in client_device_names or device_name in server_device_names
):
if device_name in client_device_names:
Expand All @@ -93,12 +95,12 @@ def main():
json={
"serverDeviceId": server_device['id'],
"clientDeviceId": device['id'],
"messageContent": f"[RUN COMMAND] {filtered_text- f'[RUN COMMAND ON DEVICE: {device_name}] '}",
"messageContent": f"[RUN COMMAND] {filtered_text.split(f'RUN COMMAND ON DEVICE: {device_name} | ')}",
}, headers={"Authorization": f"Bearer {access_token}"},
)
else:
speak(filtered_text)
if updated_group['aiMessages'].length > group['aiMessages'].length:
if updated_group['aiMessages'].len > group['aiMessages'].len:
requests.put(
"https://spark-api.fly.dev/group/",
json=updated_group,
Expand Down

0 comments on commit 64b5be4

Please sign in to comment.