timer notification updated

This commit is contained in:
maglore9900 2024-09-13 20:25:55 -04:00
parent d195d63580
commit e12c3aa36c
6 changed files with 77 additions and 14 deletions

View File

@ -4,7 +4,15 @@ this is a personal project to create a voice directed digital assistant based on
written in python, using langchain, langgraph, etc.
it currently will respond as an LLM like usual, but can also control spotify
written to work on Windows. Agent and logic will run on linux but tools are currently windows only.
it currently will respond as an LLM like usual, but also has the following capabilities:
- can also control spotify
- can open applications on windows
- can change the focused window
- set timer
- coming soon: journalling in markdown with save target for obsidian
this is a fun work in progress. if you want to use it and or develop for it be my guest. would love to have more tools designed.

View File

@ -152,9 +152,14 @@ class Agent:
print(f"state: {state}")
tool_action = state['agent_out'][0]
command = (lambda x: x.get('command') or x.get('self'))(tool_action.tool_input)
if not command:
raise ValueError("No valid command found in tool_input")
subprocess.run(["python", "modules/timer.py", command])
try:
if not command:
raise ValueError("No valid command found in tool_input")
subprocess.run(["python", "timer.py", command])
# process = subprocess.Popen(["python", "modules/timer.py", command], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
except Exception as e:
print(f"An error occurred with timer: {e}")
except Exception as e:
print(f"An error occurred: {e}")

View File

@ -44,6 +44,8 @@ class Journal:
Ensure that the tone remains neutral, and avoid using 'I' or 'my' in the notes.
The format MUST be in markdown
Only use the information provided by the query. If you dont have information for a section dont try to make it up.
"""
self.chat_template = ChatPromptTemplate.from_messages(
@ -62,6 +64,7 @@ class Journal:
def journal(self, text):
message = self.chat_template.format_messages(text=text)
response = self.journal_llm.invoke(message)
return response
print(response)
# return response

View File

@ -1,18 +1,38 @@
import time
import argparse
import agent
# import agent
spk = agent.Agent().spk
# spk = agent.Agent().spk
def timer(seconds):
print(f"Timer started for {seconds} seconds.")
time.sleep(seconds)
print("Time's up!")
spk.glitch_stream_output("Time's up!")
# def timer(seconds):
# print(f"Timer started for {seconds} seconds.")
# time.sleep(seconds)
# print("Time's up!")
# spk.glitch_stream_output("Time's up!")
# if __name__ == "__main__":
# parser = argparse.ArgumentParser(description="Simple Timer Script")
# parser.add_argument("seconds", type=int, help="Number of seconds to set the timer for")
# args = parser.parse_args()
# timer(args.seconds)
# import time
from plyer import notification
def start_timer(seconds):
print(f"Timer started for {seconds} seconds...")
time.sleep(seconds) # Sleep for the desired time
notification.notify(
title="Timer Finished",
message="Your time is up!",
timeout=5 # Notification will disappear after 10 seconds
)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Simple Timer Script")
parser.add_argument("seconds", type=int, help="Number of seconds to set the timer for")
args = parser.parse_args()
timer(args.seconds)
start_timer(args.seconds)

26
modules/timer_test.py Normal file
View File

@ -0,0 +1,26 @@
# import time
# from win10toast import ToastNotifier
# def start_timer(seconds):
# print(f"Timer started for {seconds} seconds...")
# time.sleep(seconds)
# toaster = ToastNotifier()
# toaster.show_toast("Timer Finished", "Your time is up!", duration=10)
# # Example: Set a timer for 60 seconds
# start_timer(5)
import time
from plyer import notification
def start_timer(seconds):
print(f"Timer started for {seconds} seconds...")
time.sleep(seconds) # Sleep for the desired time
notification.notify(
title="Timer Finished",
message="Your time is up!",
timeout=10 # Notification will disappear after 10 seconds
)
# Example: Set a timer for 60 seconds
start_timer(5)

View File

@ -13,4 +13,5 @@ pypdf
langsmith
unstructured
python-docx
python-vlc
python-vlc
plyer