GravityPhone / Hats

0 stars 0 forks source link

Sweep: write logging code #6

Closed GravityPhone closed 6 months ago

GravityPhone commented 6 months ago

Details

write code so save a very detailed log to the same dir as the scripts

Branch

No response

Checklist - [X] Create `src/logging_module.py` ✓ https://github.com/GravityPhone/Hats/commit/6e2128a5e53686f05a6452f703b3389360204af6 [Edit](https://github.com/GravityPhone/Hats/edit/sweep/write_logging_code/src/logging_module.py) - [X] Running GitHub Actions for `src/logging_module.py` ✓ [Edit](https://github.com/GravityPhone/Hats/edit/sweep/write_logging_code/src/logging_module.py) - [X] Modify `main_controller.py` ✓ https://github.com/GravityPhone/Hats/commit/1e00e2015a585996bf4b444a35959266156a9bc5 [Edit](https://github.com/GravityPhone/Hats/edit/sweep/write_logging_code/main_controller.py) - [X] Running GitHub Actions for `main_controller.py` ✓ [Edit](https://github.com/GravityPhone/Hats/edit/sweep/write_logging_code/main_controller.py)
sweep-ai[bot] commented 6 months ago

🚀 Here's the PR! #7

See Sweep's progress at the progress dashboard!
💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: 01ff9a5bbf)

[!TIP] I can email you next time I complete a pull request if you set up your email here!


Actions (click)


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/GravityPhone/Hats/blob/40539aa030efe5092cc562c742751e059ec17f24/main_controller.py#L1-L91

Step 2: ⌨️ Coding

Ran GitHub Actions for 6e2128a5e53686f05a6452f703b3389360204af6:

--- 
+++ 
@@ -1,4 +1,5 @@
 import os
+import logging_module
 import time
 from word_detector import setup_keyword_detection, set_message_handler
 from audio_recorder import start_recording, stop_recording
@@ -20,7 +21,8 @@
 last_interaction_time = None

 def handle_detected_words(words):
-    global is_recording, picture_mode, last_thread_id, last_interaction_time
+    global is_recording, picture_mode, last_thread_id, last_interaction_time, log_file_path
+    logging_module.write_log('handle_detected_words function started.', log_file_path)
     detected_phrase = ' '.join(words).lower().strip()
     print(f"Detected phrase: {detected_phrase}")

@@ -36,11 +38,13 @@
         is_recording = False
         print("Recording stopped. Processing...")
         process_recording()
+    logging_module.write_log('handle_detected_words function ended.', log_file_path)

 def process_recording():
-    global picture_mode, last_thread_id, last_interaction_time
+    global picture_mode, last_thread_id, last_interaction_time, log_file_path
+    logging_module.write_log('process_recording function started.', log_file_path)
     transcription = assemblyai_transcriber.transcribe_audio_file("recorded_audio.wav")
-    print(f"Transcription result: '{transcription}'")
+    logging_module.write_log(f"Transcription result: '{transcription}'", log_file_path)

     if picture_mode:
         vision_module.capture_image_async()
@@ -56,16 +60,18 @@

 def interact_with_assistant(transcription):
-    global last_thread_id, last_interaction_time
+    global last_thread_id, last_interaction_time, log_file_path
+    logging_module.write_log('interact_with_assistant function started.', log_file_path)
     if not last_thread_id or time.time() - last_interaction_time > 90:
         last_thread_id = assistant_manager.create_thread()

     last_interaction_time = time.time()

     message_id = assistant_manager.add_message_to_thread(last_thread_id, transcription)
-    print(f"Message added with ID: {message_id}")
+    logging_module.write_log(f"Message added with ID: {message_id}", log_file_path)
     # Initiate a run on the thread for the assistant to process the message
     run_id = assistant_manager.run_assistant(last_thread_id, assistant_id="asst_3D8tACoidstqhbw5JE2Et2st", instructions=transcription)
+    logging_module.write_log(f"Assistant run initiated with ID: {run_id}", log_file_path)
     print(f"Assistant run initiated with ID: {run_id}")

     # Check if the run is completed and retrieve the processed response
@@ -82,6 +88,8 @@

 def initialize():
+    log_file_path = logging_module.create_log_file()
+    logging_module.write_log('initialize function started.', log_file_path)
     print("System initializing...")
     set_message_handler(handle_detected_words)
     setup_keyword_detection()

Ran GitHub Actions for 1e00e2015a585996bf4b444a35959266156a9bc5:


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/write_logging_code.


🎉 Latest improvements to Sweep:
  • New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
  • Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
  • Use the GitHub issues extension for creating Sweep issues directly from your editor.

💡 To recreate the pull request edit the issue title or description. Something wrong? Let us know.

This is an automated message generated by Sweep AI.