From e12c3aa36cf120a473dfd46e17cf16a2fb8c32e7 Mon Sep 17 00:00:00 2001 From: maglore9900 Date: Fri, 13 Sep 2024 20:25:55 -0400 Subject: [PATCH] timer notification updated --- README.md | 10 +++++++++- modules/agent.py | 11 ++++++++--- modules/journal.py | 5 ++++- modules/timer.py | 36 ++++++++++++++++++++++++++++-------- modules/timer_test.py | 26 ++++++++++++++++++++++++++ requirements.txt | 3 ++- 6 files changed, 77 insertions(+), 14 deletions(-) create mode 100644 modules/timer_test.py diff --git a/README.md b/README.md index 8859695..97be780 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/modules/agent.py b/modules/agent.py index 6d836b0..b3bbb7b 100644 --- a/modules/agent.py +++ b/modules/agent.py @@ -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}") diff --git a/modules/journal.py b/modules/journal.py index 4caef34..b9fadc6 100644 --- a/modules/journal.py +++ b/modules/journal.py @@ -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 diff --git a/modules/timer.py b/modules/timer.py index f1e7c55..099ca59 100644 --- a/modules/timer.py +++ b/modules/timer.py @@ -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) \ No newline at end of file diff --git a/modules/timer_test.py b/modules/timer_test.py new file mode 100644 index 0000000..96d5dd5 --- /dev/null +++ b/modules/timer_test.py @@ -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) diff --git a/requirements.txt b/requirements.txt index 620b4e0..05b7f24 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,4 +13,5 @@ pypdf langsmith unstructured python-docx -python-vlc \ No newline at end of file +python-vlc +plyer \ No newline at end of file