diff --git a/OS/01/core/interpreter/conversations/user.json b/OS/01/core/interpreter/conversations/user.json index 3a96cb7..b52c39e 100644 --- a/OS/01/core/interpreter/conversations/user.json +++ b/OS/01/core/interpreter/conversations/user.json @@ -1 +1 @@ -[{"role": "user", "type": "message", "content": "Help me get my laundry done."}, {"role": "assistant", "type": "message", "content": "To help you with your laundry task, let's plan around it. I'll break it down into manageable steps to make it more approachable and then keep you motivated throughout the process. Here's the plan:\n\n1. **Create a task list:** We'll start by creating a list of tasks for the laundry process. This list will include steps such as sorting your laundry, putting the first load in the washer, transferring to the dryer, and so forth.\n2. **Arrange reminders:** Based on your estimation, we'll schedule reminders for when it's time to check on or switch loads so you don't have to keep track yourself.\n3. **Offer Support:** I'll provide motivational messages and assistance throughout the process to keep you focused and encouraged.\n\nLet's start by creating the initial list of tasks for your laundry. Please tell me how you typically go about doing your laundry (e.g., sorting by colors, how many loads, etc.), and we can customize the task list from there.\n\nLet's start by creating a list of generic laundry tasks which we will then refine based on your specific routine. Here's an initial set of tasks we can consider:\n\n1. Gather all laundry.\n2. Sort laundry by colors and materials.\n3. Load the first batch into the washing machine.\n4. Add detergent.\n5. Start the washing machine.\n6. Transfer washed clothes to the dryer.\n7. Start the dryer.\n8. Fold or hang clothes once dry.\n\n"}, {"role": "assistant", "type": "code", "format": "python", "content": "\n# Creating an initial list of generic laundry tasks\ntasks = [\n \"Gather all laundry.\",\n \"Sort laundry by colors and materials.\",\n \"Load the first batch into the washing machine.\",\n \"Add detergent.\",\n \"Start the washing machine.\",\n \"Transfer washed clothes to the dryer.\",\n \"Start the dryer.\",\n \"Fold or hang clothes once dry.\"\n]\ntasks\n"}, {"role": "computer", "type": "console", "format": "output", "content": "['Gather all laundry.',\n 'Sort laundry by colors and materials.',\n 'Load the first batch into the washing machine.',\n 'Add detergent.',\n 'Start the washing machine.',\n 'Transfer washed clothes to the dryer.',\n 'Start the dryer.',\n 'Fold or hang clothes once dry.']"}] \ No newline at end of file +[{"role": "user", "type": "message", "content": "Help me get my laundry done.\n\n"}, {"role": "assistant", "type": "message", "content": "To help you get your laundry done efficiently, we'll break this task down into smaller, manageable steps and schedule reminders as necessary. Here's a possible breakdown:\n\n1. Gather all dirty laundry items.\n2. Sort laundry into appropriate piles (e.g., whites, colors, delicates).\n3. Check laundry labels for any special washing instructions.\n4. Start the first load of laundry in the washing machine.\n5. Transfer the first load to the dryer when the wash cycle is complete.\n6. Fold or hang clothes immediately after they dry.\n7. Put all laundered items away.\n\nI'll add these steps to your task list and focus on guiding you through each step one at a time. Let's start with the first task: gathering all dirty laundry items. I'll check in with you in 15 minutes to see if you've completed this task.\n\n"}, {"role": "assistant", "type": "code", "format": "python", "content": "\nfrom datetime import datetime, timedelta\n\ntasks = [\n \"Gather all dirty laundry items.\",\n \"Sort laundry into appropriate piles.\",\n \"Check laundry labels for any special instructions.\",\n \"Start the first load of laundry in the washing machine.\",\n \"Transfer the first load to the dryer when wash is complete.\",\n \"Fold or hang clothes after they dry.\",\n \"Put all laundered items away.\"\n]\n\nschedule(datetime.now() + timedelta(minutes=15), \"Have you gathered all the dirty laundry items?\")\ntasks[0]\n"}, {"role": "computer", "type": "console", "format": "output", "content": "'Gather all dirty laundry items.'"}, {"role": "assistant", "type": "message", "content": "The output means that your current task is to gather all dirty laundry items. This is the first step in getting your laundry done. Focus on collecting all the laundry that needs washing from around your home. I've scheduled a reminder to check in with you in 15 minutes to see if you've completed this task. Once you're done with gathering all the laundry items, we'll move on to the next step. Keep up the good work!"}, {"role": "user", "type": "message", "content": "Check in with me in 30 seconds for that."}, {"role": "assistant", "type": "code", "format": "python", "content": "\n# Rescheduling the check-in reminder for gathering laundry to 30 seconds from now\nschedule(datetime.now() + timedelta(seconds=30), \"Have you gathered all the dirty laundry items?\")\n"}, {"role": "computer", "type": "console", "format": "output", "content": ""}, {"role": "assistant", "type": "message", "content": "The absence of text output signifies that the reminder to check in on your task (\"Have you gathered all the dirty laundry items?\") has been successfully scheduled for 30 seconds from now. There's nothing further you need to do until that reminder comes through. Once you've received the reminder, please update me on your progress, and we'll move forward with the next step in completing your laundry. Great job on getting started!"}, {"role": "computer", "type": "console", "format": "output", "content": "Have you gathered all the dirty laundry items?"}, {"role": "assistant", "type": "message", "content": "The output indicates that it's time for the check-in reminder to see if you've completed gathering all the dirty laundry items, as scheduled. If you have completed this task, we will move on to the next step in your laundry process, which is sorting the laundry into appropriate piles. If you haven't finished gathering the laundry yet, please take a moment to do so.\n\nCould you let me know if you've finished gathering all the laundry?"}, {"role": "user", "type": "message", "content": "Did you need to run code? It's okay if not, but please do if you did."}, {"role": "assistant", "type": "message", "content": "Since we are at a check-in point where I need your input to proceed, technically, I don't need to run code right this moment. The next steps revolve around your response. I'll provide guidance based on whether you've completed gathering all the dirty laundry items. If you have, I can then update the task list and advise on sorting the laundry, which involves running code to manage the task progression.\n\nSo, have you finished gathering all the dirty laundry items?"}, {"role": "user", "type": "message", "content": "hi"}, {"role": "assistant", "type": "message", "content": "Hello! It seems we were checking in to see if you've finished gathering all the dirty laundry items for your laundry task. How did it go? Are you ready to move on to the next step, or is there anything else you need assistance with right now?"}, {"role": "user", "type": "message", "content": "Did you need to run code? It's okay if not, but please do if you did."}, {"role": "assistant", "type": "message", "content": "Given your update, let's progress with the task list. The next step after gathering all dirty laundry items is to sort them into appropriate piles. Since you're ready to move on, I will update the task list to reflect the completion of the first task and provide the details of the next task.\n\nLet's run the code to update your task progression.\n\n"}, {"role": "assistant", "type": "code", "format": "python", "content": "\n# Update tasks list by removing the completed task\ntasks = tasks[1:]\n\n# Check which task is next\nnext_task = tasks[0] if tasks else \"No more laundry tasks.\"\n\nnext_task\n"}, {"role": "computer", "type": "console", "format": "output", "content": "'Sort laundry into appropriate piles.'"}, {"role": "assistant", "type": "message", "content": "The output means that your next task is to sort the laundry into appropriate piles. This step is crucial for an efficient laundry process as it helps to ensure that clothes are washed under the right settings, preserving their quality and color. Here's a quick guide on sorting:\n\n1. **Whites:** Keep white shirts, sheets, and other similar items in one pile.\n2. **Colors:** Separate colored clothes, ensuring to differentiate between darks and lights if necessary.\n3. **Delicates:** These are items that need gentle handling. Look for fabrics like silk or items with embellishments.\n4. **Heavy Items:** Jeans and towels often need their own cycle due to their weight and drying times.\n\nOnce you've sorted the laundry into these piles, you'll be ready to start the first load in the washing machine. How much time do you think you'll need for sorting? I can set a reminder for you to check back in once you're done with this task."}, {"role": "user", "type": "message", "content": "20 seconds"}, {"role": "assistant", "type": "code", "format": "python", "content": "\n# Scheduling a reminder to check on the sorting task in 20 seconds\nschedule(datetime.now() + timedelta(seconds=20), \"Have you finished sorting the laundry into appropriate piles?\")\n"}, {"role": "computer", "type": "console", "format": "output", "content": ""}, {"role": "assistant", "type": "message", "content": "Since the reminder has been successfully scheduled for 20 seconds to check if you've finished sorting the laundry into appropriate piles, there's nothing more you need to do at the moment except complete the sorting task. Once the reminder comes through, please let me know if you've finished sorting the laundry, and we can move forward with the next step in your laundry process. Keep up the great work!"}, {"role": "computer", "type": "console", "format": "output", "content": "Have you finished sorting the laundry into appropriate piles?"}, {"role": "assistant", "type": "message", "content": "The output indicates that it's time for our check-in to see if you've completed the task of sorting the laundry into appropriate piles. If you have finished this task, we can move on to the next step, which involves starting a laundry cycle with one of the sorted piles. \n\nPlease let me know if the sorting is complete, and we can proceed with the next step in your laundry process."}, {"role": "user", "type": "message", "content": "Did you need to run code? It's okay if not, but please do if you did."}, {"role": "assistant", "type": "message", "content": "Since we are at a decision point depending on whether you've completed sorting the laundry, the next step doesn't involve running code until I know the status of the task. \n\nIf you've finished sorting the laundry, I'll update our task list and guide you through starting the washing machine with one of the sorted piles. Let's confirm your progress first.\n\nHave you finished sorting the laundry into appropriate piles?"}] \ No newline at end of file diff --git a/OS/01/core/interpreter/main.py b/OS/01/core/interpreter/main.py index 6974a12..c77e172 100644 --- a/OS/01/core/interpreter/main.py +++ b/OS/01/core/interpreter/main.py @@ -36,26 +36,6 @@ def load_conversation(): return [] -def check_for_new_messages(task) -> Tuple[Optional[str], Optional[str]]: - # Has the user sent a message? - if task.done(): - return {"role": "user", "type": "message", "content": task.result()} - - # Has the queue recieved a message? - queued_message = check_queue() - if queued_message: - return queued_message - - return None - - -async def get_new_messages(task) -> Tuple[Optional[str], Optional[str]]: - message = check_for_new_messages(task) - if message: - return message - else: - await asyncio.sleep(0.2) - return await get_new_messages(task) def main(interpreter: OpenInterpreter): @@ -68,10 +48,36 @@ def main(interpreter: OpenInterpreter): while True: # This is the task for waiting for the user to send any message at all. + try: + task.cancel() + try: + await task + except asyncio.CancelledError: + pass + except: + pass task = asyncio.create_task(websocket.receive_text()) if data == None: # Data will have stuff in it if we inturrupted it. - data = await get_new_messages(task) + while data == None: + # Has the user sent a message? + if task.done(): + try: + data = {"role": "user", "type": "message", "content": task.result()} + except Exception as e: + print(e) + task.cancel() + try: + await task + except asyncio.CancelledError: + pass + + # Has the queue recieved a message? + queued_message = check_queue() + if queued_message: + data = queued_message + + await asyncio.sleep(0.2) ### CONVERSATION / DISC MANAGEMENT message = data @@ -82,16 +88,42 @@ def main(interpreter: OpenInterpreter): ### RESPONDING # This is the task for waiting for user inturruptions. + try: + task.cancel() + try: + await task + except asyncio.CancelledError: + pass + except: + pass task = asyncio.create_task(websocket.receive_text()) + recieved_chunks = [] + for chunk in interpreter.chat( messages, stream=True, display=True ): - try: - data = check_for_new_messages(task) - except: - pass - if data: + + recieved_chunks.append(chunk) + + # Has the user sent a message? + if task.done(): + try: + data = {"role": "user", "type": "message", "content": task.result()} + except Exception as e: + print(e) + task.cancel() # The user didn't inturrupt + try: + await task + except asyncio.CancelledError: + pass + save_conversation(interpreter.messages) + break + + # Has the queue recieved a message? + queued_message = check_queue() + if queued_message: + data = queued_message save_conversation(interpreter.messages) break @@ -104,8 +136,48 @@ def main(interpreter: OpenInterpreter): save_conversation(interpreter.messages) data = None - if data == None: - task.cancel() # The user didn't inturrupt + if not any([message["type"] == "code" for message in recieved_chunks]): + for chunk in interpreter.chat( + "Did you need to run code? It's okay if not, but please do if you did.", stream=True, display=True + ): + # Has the user sent a message? + if task.done(): + try: + data = {"role": "user", "type": "message", "content": task.result()} + except Exception as e: + print(e) + task.cancel() # The user didn't inturrupt + try: + await task + except asyncio.CancelledError: + pass + save_conversation(interpreter.messages) + break + + # Has the queue recieved a message? + queued_message = check_queue() + if queued_message: + data = queued_message + save_conversation(interpreter.messages) + break + + # Send out chunks + await websocket.send_json(chunk) + await asyncio.sleep(0.01) # Add a small delay + + # If the interpreter just finished sending a message, save it + if "end" in chunk: + save_conversation(interpreter.messages) + data = None + + if not task.done(): + task.cancel() # User didn't inturrupt + try: + await task + except asyncio.CancelledError: + pass + + diff --git a/OS/01/core/interpreter/start.py b/OS/01/core/interpreter/start.py index a076088..40e0942 100644 --- a/OS/01/core/interpreter/start.py +++ b/OS/01/core/interpreter/start.py @@ -40,7 +40,7 @@ To do this, schedule a reminder based on estimated completion time using the fun You guide the user through the list one task at a time, convincing them to move forward, giving a pep talk if need be. Your job is essentially to answer "what should I (the user) be doing right now?" for every moment of the day. -Remember: You can run Python code. Be very concise. +Remember: You can run Python code. Be very concise. Ensure that you actually run code every time! THIS IS IMPORTANT. You NEED to write code. **Help the user by being very concise in your answers.** Do not break down tasks excessively, just into simple, few minute steps. Don't assume the user lives their life in a certain way— pick very general tasks if you're breaking a task down. """.strip()