OpenInterpreter / open-interpreter

A natural language interface for computers
http://openinterpreter.com/
GNU Affero General Public License v3.0
57.02k stars 4.9k forks source link

Code execution never comes back #1525

Open guiramos opened 3 weeks ago

guiramos commented 3 weeks ago

Describe the bug

I am trying to have my python project execute code dynamically via OI and every time it tries to run some shell script as described below, it never comes back. It gets stuck inside the method for line in interpreter.computer.run(language, code, stream=True):

This is the description generated.

  1. First, I'll use SSH to connect to the server and run the disk usage command: Code: ssh -i /root/blabla.pem root@192.168.1.53 "df -h"

Filesystem Size Used Avail Use% Mounted on tmpfs 778M 2.0M 776M 1% /run /dev/sda2 440G 37G 380G 9% / tmpfs 3.8G 0 3.8G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 778M 4.0K 778M 1% /run/user/1000

I think it gets stuck inside this loop because self.done never gets set.

        while True:
            if not self.output_queue.empty():
                yield self.output_queue.get()
            else:
                time.sleep(0.1)
            try:
                output = self.output_queue.get(timeout=0.3)  # Waits for 0.3 seconds
                yield output
            except queue.Empty:
                if self.done.is_set():
                    # Try to yank 3 more times from it... maybe there's something in there...
                    # (I don't know if this actually helps. Maybe we just need to yank 1 more time)
                    for _ in range(3):
                        if not self.output_queue.empty():
                            yield self.output_queue.get()
                        time.sleep(0.2)
                    break

I am using version open-interpreter = "^0.4.3"

Can you please advise?

Reproduce

I am something like this:

for chunk in interpreter.chat( f"{task_description}\n\n", stream=True, display=False ):

print out the chunks

Expected behavior

I would expect it to return, get out of the method.

Screenshots

No response

Open Interpreter version

0.4.3

Python version

3.11.5

Operating System name and version

mac 14

Additional context

No response