From a13a8b00fc307035da8fc65a8d9c320e946a402a Mon Sep 17 00:00:00 2001 From: killian <63927363+KillianLucas@users.noreply.github.com> Date: Sun, 28 Jan 2024 00:54:31 -0800 Subject: [PATCH] Fixes --- .../__pycache__/main.cpython-311.pyc | Bin 4728 -> 4977 bytes .../core/interpreter/conversations/user.json | 1 + OS/01/core/interpreter/main.py | 9 +++++++-- OS/01/core/interpreter/start.py | 9 +++++++-- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/OS/01/core/interpreter/__pycache__/main.cpython-311.pyc b/OS/01/core/interpreter/__pycache__/main.cpython-311.pyc index bd87b157939be24af95199a7d09729c27902adbf..168a6cd5352916978877370dddf25395d0b4a9c1 100644 GIT binary patch delta 866 zcmZ`%O=uHA6rS0??k2n0jol{E)^=lm6A$gdKN?$X4OZ}wg7||_G-Mb0yA6}AhqCeF z#Y(NIBUrU!E>?2EWYx_H{f+>bVrYy6lQlUPn*1u8 zg-$buQb@@1E}!?|O|O3Je+CGgwm%#$|1UoTE`xNJ$!nze0RHJounl=XC5pPd2~GH1 zSYwGGvg#HGV;fn)>HK{Lz!mTmiwa_rxh?7#l0|5l~66wLw9t?`&7gCS5 zJ9N|qd7VlSU7@ZP`=tO*$VZ!ms{jRds+1uxK^88)&oPUw_^o^nHsMC);&40BSz$8{ zLd`T1lIgT%n}|-lBBYXb%9^flsqv&!;nQfsc2Iz3qznOFp3KbJ5fMLB4z|{>`PBHF zJyr1%oQ2ZJB0eJ$JpQWm!6n?`JItJf_>%8~wIu>g&&3z!7v~?H{iqrR)hHWXFQs>8 zA$W#-Ij$P)DF&mZVD!f6vaH`u+)S**i*mRmhYNDJD(_zzFUs8|xw{~D*F1!*2B6Yf z*7SScJKkmGu98!#c+A&=ud9X-Qj8i1;dQlbFYDh|ZjR*QRlPGmRqE<5>amg@E9fy? zQ1$S3w(W83LG1p(>cCE@Zz|$O=qo0)3+?@M7AzSVijgQo|A8xpfi!x}%_JvmG=x8E zkwYVpH=al}K=r5WvV#B0c#ox9sE?ZXZdG1$;1ZWV(iJ@2|BUnIf_j!Uv*~=J; z#7d+Q;+-5>f|Cf#UI5#rb(fVn9hv&dHH{+Pb%RN{dsA;&W4rixbmR!7{g4lQT;5 zvTtz%b)^;+6r}>mVosnIg~^Nf3>aM|U*Q{KwFYu^;Wa=n1O4wInN4Qb5@E;mFZC%ArKV-S&;ZaK+vqV*K(4-8;A`T5qftY_NJ zv7O*D`HeskFj(y-CkcitTY~({4D@`F6_8cT3?vd16pBEhdy6GEF*C2oVe%b8O%o?Z zR)wXU9~eM1F7hKY1DnJZR`Cx^AXQ&|CR+;WGulqh6ta?W0GhXwp~w+PfzAHKVUwGm aQks)$SL8Z*ztBWQZ$?Ig4-D8zur>gxp{r*A 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