diff --git a/OS/01/core/interpreter/__pycache__/main.cpython-311.pyc b/OS/01/core/interpreter/__pycache__/main.cpython-311.pyc index bd87b15..168a6cd 100644 Binary files a/OS/01/core/interpreter/__pycache__/main.cpython-311.pyc and b/OS/01/core/interpreter/__pycache__/main.cpython-311.pyc differ diff --git a/OS/01/core/interpreter/conversations/user.json b/OS/01/core/interpreter/conversations/user.json index e69de29..2aa66fc 100644 --- a/OS/01/core/interpreter/conversations/user.json +++ b/OS/01/core/interpreter/conversations/user.json @@ -0,0 +1 @@ +[{"role": "user", "type": "message", "content": "hey"}, {"role": "assistant", "type": "message", "content": "Hello! How can I assist you today?"}, {"role": "user", "type": "message", "content": "help me get my laundry done"}, {"role": "assistant", "type": "message", "content": "Sure, I'll be glad to help you get through your laundry task! Let's break it down together:\n\n1. Gathering all your dirty clothes.\n2. Sorting your clothes by color and type.\n3. Washing your clothes based on sort.\n4. Drying your clothes once the washing part is complete.\n5. Folding and organizing the clothes.\n\nDoes this breakdown make sense? Would you like me to set reminders for these tasks, one by one, to guide you through the process?"}, {"role": "user", "type": "message", "content": "Yeah."}, {"role": "assistant", "type": "message", "content": "Sure, I am going to start you with your first task, which is gathering all your dirty clothes. How much time do you think you will need for this?"}, {"role": "user", "type": "message", "content": "idk you please estimate"}, {"role": "assistant", "type": "message", "content": "I suggest we allocate 15 minutes for gathering all your dirty clothes. This should provide enough time for you to check all areas where dirty laundry could be: bedrooms, bathroom, gym bag, etc.\n\nLet's schedule this. Next, I will check back with you in 15 minutes to see if the task is completed. \n\nLet's get started! Remember, all the work you're about to do is going to leave you with a closet full of clean clothes to wear. That's something to look forward to!\n\n"}, {"role": "assistant", "type": "code", "format": "python", "content": "\nimport datetime\nfrom computer import clock\n\n# Get current time\nnow = datetime.datetime.now()\n# Add 15 minutes to it for the deadline\ndeadline = now + datetime.timedelta(minutes=15)\n# Schedule a check back\nclock.schedule(deadline, \"Have you gathered all the dirty clothes?\")\n"}, {"role": "computer", "type": "console", "format": "output", "content": "---------------------------------------------------------------------------\nModuleNotFoundError Traceback (most recent call last)\nCell In[2], line 4\n 2 import datetime\n 3 print('##active_line2##')\n----> 4 from computer import clock\n 5 print('##active_line3##')\n 6 pass\n\nModuleNotFoundError: No module named 'computer'"}, {"role": "assistant", "type": "message", "content": "It seems like thecomputer module is not available in your working environment. It seems to be a hypothetical module mentioned in the prompt, but not available for use. To get around this and implement the scheduling, I could instead propose a rough structure of aschedule function for you below. This code will not run here, but can be inserted into a working Python script and execute correctly:\n\n"}, {"role": "assistant", "type": "code", "format": "python", "content": "\nimport threading\nimport time\nfrom datetime import datetime, timedelta\n\n# Function to print reminder\ndef remind(message):\n print(message)\n\n# Function to schedule a reminder\ndef schedule(deadline, message):\n # Calculate delay in seconds\n delay = (deadline - datetime.now()).total_seconds()\n # Start timer\n threading.Timer(delay, remind, args=(message,)).start()\n\nnow = datetime.now()\ndeadline = now + timedelta(minutes=15) # Sets deadline as 15 minutes from now\nschedule(deadline, \"Have you gathered all the dirty clothes?\")\n"}, {"role": "computer", "type": "console", "format": "output", "content": ""}] \ No newline at end of file diff --git a/OS/01/core/interpreter/main.py b/OS/01/core/interpreter/main.py index 8e8247c..d9d982c 100644 --- a/OS/01/core/interpreter/main.py +++ b/OS/01/core/interpreter/main.py @@ -74,14 +74,17 @@ def main(interpreter): pass ### CONVERSATION / DISC MANAGEMENT - user_message = {"role": "user", "type": "message", "content": data} + if type(data) == str: # This means it's from the frontend / user. + data = {"role": "user", "type": "message", "content": data} messages = load_conversation() - messages.append(user_message) + messages.append(data) save_conversation(messages) ### RESPONDING # This is the task for waiting for user inturruptions. + if task: + task.cancel() task = asyncio.create_task(websocket.receive_text()) for chunk in interpreter.chat( @@ -92,11 +95,13 @@ def main(interpreter): queued_message = check_queue() if queued_message: data = queued_message + save_conversation(interpreter.messages) break # Check for new user messages if task.done(): data = task.result() # Get the new message + save_conversation(interpreter.messages) break # Break the loop and start processing the new message # Send out chunks diff --git a/OS/01/core/interpreter/start.py b/OS/01/core/interpreter/start.py index 323f42f..79c3f34 100644 --- a/OS/01/core/interpreter/start.py +++ b/OS/01/core/interpreter/start.py @@ -6,6 +6,7 @@ from main import main from interpreter import interpreter import os import glob +import json ### SYSTEM MESSAGE @@ -48,12 +49,11 @@ interpreter.custom_instructions = system_message ### TOOLS -for file in glob.glob('/tools/*.py'): +for file in glob.glob('interpreter/tools/*.py'): with open(file, 'r') as f: for chunk in interpreter.computer.run("python", f.read()): print(chunk) - ### LLM SETTINGS # Local settings @@ -74,6 +74,11 @@ interpreter.offline = True interpreter.id = 206 # Used to identify itself to other interpreters. This should be changed programatically so it's unique. +### RESET conversations/user.json +with open('interpreter/conversations/user.json', 'w') as file: + json.dump({}, file) + + ### SERVE INTERPRETER AT "/" main(interpreter) \ No newline at end of file