Skip to content

Commit

Permalink
Added os_name to telemetry (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
onuratakan authored Jun 6, 2024
1 parent bd830ec commit 9129d39
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
17 changes: 12 additions & 5 deletions gpt_computer_assistant/agent/proccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ..audio.record import audio_data
from ..gui.signal import signal_handler
from ..utils.db import *
from ..utils.telemetry import my_tracer
from ..utils.telemetry import my_tracer, os_name
except ImportError:
from llm import *
from agent.assistant import *
Expand All @@ -17,7 +17,7 @@
from audio.record import audio_data
from gui.signal import signal_handler
from utils.db import *
from utils.telemetry import my_tracer
from utils.telemetry import my_tracer, os_name

import threading

Expand All @@ -36,11 +36,13 @@

last_ai_response = None
user_id = load_user_id()
os_name_ = os_name()


def process_audio(take_screenshot=True, take_system_audio=False, dont_save_image=False):
with my_tracer.start_span("process_audio") as span:
span.set_attribute("user_id", user_id)
span.set_attribute("os_name", os_name_)

global audio_data, last_ai_response

Expand Down Expand Up @@ -82,7 +84,8 @@ def play_text():

def play_audio():
with my_tracer.start_span("play_audio") as span:
span.set_attribute("user_id", user_id)
span.set_attribute("user_id", user_id)
span.set_attribute("os_name", os_name_)
play_text()
mixer.init()
mixer.music.load(response_path)
Expand Down Expand Up @@ -110,6 +113,7 @@ def play_text():
def process_screenshot():
with my_tracer.start_span("process_screenshot") as span:
span.set_attribute("user_id", user_id)
span.set_attribute("os_name", os_name_)

global last_ai_response

Expand Down Expand Up @@ -143,7 +147,8 @@ def play_text():

def play_audio():
with my_tracer.start_span("play_audio") as span:
span.set_attribute("user_id", user_id)
span.set_attribute("user_id", user_id)
span.set_attribute("os_name", os_name_)
play_text()
mixer.init()
mixer.music.load(response_path)
Expand Down Expand Up @@ -172,6 +177,7 @@ def play_text():
def process_text(text, screenshot_path=None):
with my_tracer.start_span("process_text") as span:
span.set_attribute("user_id", user_id)
span.set_attribute("os_name", os_name_)

global last_ai_response

Expand Down Expand Up @@ -204,7 +210,8 @@ def play_text():
signal_handler.assistant_response_ready.emit()
def play_audio():
with my_tracer.start_span("play_audio") as span:
span.set_attribute("user_id", user_id)
span.set_attribute("user_id", user_id)
span.set_attribute("os_name", os_name_)
play_text()
mixer.init()
mixer.music.load(response_path)
Expand Down
7 changes: 5 additions & 2 deletions gpt_computer_assistant/audio/record.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
try:
from ..gui.signal import *
from ..utils.db import mic_record_location, system_sound_location, load_user_id
from ..utils.telemetry import my_tracer
from ..utils.telemetry import my_tracer, os_name
except ImportError:
from gui.signal import *
from utils.db import mic_record_location, system_sound_location, load_user_id
from utils.telemetry import my_tracer
from utils.telemetry import my_tracer, os_name
import numpy as np
import sounddevice as sd
import soundfile as sf
Expand All @@ -27,10 +27,12 @@
sound_data = None

user_id = load_user_id()
os_name_ = os_name()

def start_recording(take_system_audio=False):
with my_tracer.start_span("start_recording") as span:
span.set_attribute("user_id", user_id)
span.set_attribute("os_name", os_name_)

from ..gpt_computer_assistant import the_input_box
the_input_box.setText("Click again when recording is done")
Expand All @@ -54,6 +56,7 @@ def callback(indata, frames, time, status):
def record_audio():
with my_tracer.start_span("record_audio") as span:
span.set_attribute("user_id", user_id)
span.set_attribute("os_name", os_name_)
global recording, sound_data
mics = sc.all_microphones(include_loopback=True)

Expand Down
6 changes: 4 additions & 2 deletions gpt_computer_assistant/gpt_computer_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .gui.signal import *
from .gui.button import *
from .utils.db import *
from .utils.telemetry import my_tracer
from .utils.telemetry import my_tracer, os_name
except ImportError:
# This is for running the script directly
# in order to test the GUI without rebuilding the package
Expand All @@ -18,7 +18,7 @@
from agent.agent import *
from agent.background import *
from utils.db import *
from utils.telemetry import my_tracer
from utils.telemetry import my_tracer, os_name
from gui.signal import *
from gui.button import *

Expand Down Expand Up @@ -80,6 +80,7 @@


user_id = load_user_id()
os_name_ = os_name()


class MainWindow(QMainWindow):
Expand Down Expand Up @@ -361,6 +362,7 @@ def pulse_circle(self):
def mousePressEvent(self, event: QMouseEvent):
with my_tracer.start_span("mouse_press_event") as span:
span.set_attribute("user_id", user_id)
span.set_attribute("os_name", os_name_)
if self.state == 'idle' or self.state == 'talking':
if self.circle_rect.contains(event.pos()):
self.button_handler.toggle_recording(dont_save_image=True)
Expand Down
19 changes: 19 additions & 0 deletions gpt_computer_assistant/utils/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,24 @@ def CreateTracer(service_name, trace_name, infrastackai_api_key=None):

return tracer


def os_name():
import platform

system_name = platform.system()
if system_name == 'Windows':
return 'Windows'
elif system_name == 'Darwin':
return 'macOS'
elif system_name == 'Linux':
return 'Linux'
else:
return 'Unknown OS'




my_tracer = CreateTracer("gpt_computer_assistant", "app", infrastackai_api_key="sk-2b29c6da910d2883de0599d4c5dd6b9d2e4ec61bbfa834d5")



0 comments on commit 9129d39

Please sign in to comment.