OpenInterpreter / open-interpreter

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

KeyError: 'finish_reason' #283

Closed happysalada closed 1 year ago

happysalada commented 1 year ago

Describe the bug

when trying to type a command it returns the following errors

▌ Model set to GPT-4

Open Interpreter will require approval before running code. Use interpreter -y to bypass
this.

Press CTRL-C to exit.

> list files and directories
Traceback (most recent call last):
  File
"/nix/store/wwsxw24np4183sszb4nlql9v1i7xyl2h-open-interpreter-0.1.3/lib/python3.10/site-
packages/interpreter/interpreter.py", line 287, in chat
    self.respond()
  File
"/nix/store/wwsxw24np4183sszb4nlql9v1i7xyl2h-open-interpreter-0.1.3/lib/python3.10/site-
packages/interpreter/interpreter.py", line 724, in respond
    if chunk["choices"][0]["finish_reason"] or llama_function_call_finished:
KeyError: 'finish_reason'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File
"/nix/store/wwsxw24np4183sszb4nlql9v1i7xyl2h-open-interpreter-0.1.3/bin/.interpreter-wra
pped", line 9, in <module>
    sys.exit(cli())
  File
"/nix/store/wwsxw24np4183sszb4nlql9v1i7xyl2h-open-interpreter-0.1.3/lib/python3.10/site-
packages/interpreter/interpreter.py", line 131, in cli
    cli(self)
  File
"/nix/store/wwsxw24np4183sszb4nlql9v1i7xyl2h-open-interpreter-0.1.3/lib/python3.10/site-
packages/interpreter/cli.py", line 207, in cli
    interpreter.chat()
  File
"/nix/store/wwsxw24np4183sszb4nlql9v1i7xyl2h-open-interpreter-0.1.3/lib/python3.10/site-
packages/interpreter/interpreter.py", line 292, in chat
    self.end_active_block()
  File
"/nix/store/wwsxw24np4183sszb4nlql9v1i7xyl2h-open-interpreter-0.1.3/lib/python3.10/site-
packages/interpreter/interpreter.py", line 440, in end_active_block
    self.active_block.end()
  File
"/nix/store/wwsxw24np4183sszb4nlql9v1i7xyl2h-open-interpreter-0.1.3/lib/python3.10/site-
packages/interpreter/message_block.py", line 22, in end
    self.refresh(cursor=False)
  File
"/nix/store/wwsxw24np4183sszb4nlql9v1i7xyl2h-open-interpreter-0.1.3/lib/python3.10/site-
packages/interpreter/message_block.py", line 28, in refresh
    content = textify_markdown_code_blocks(self.content)
  File
"/nix/store/wwsxw24np4183sszb4nlql9v1i7xyl2h-open-interpreter-0.1.3/lib/python3.10/site-
packages/interpreter/message_block.py", line 45, in textify_markdown_code_blocks
    lines = text.split('\n')
AttributeError: 'NoneType' object has no attribute 'split'

Reproduce

  1. interpreter
  2. type list files and directories
  3. make sure the OPENAI_API_KEY env var is set

Expected behavior

no exceptions are encountered

Screenshots

No response

Open Interpreter version

0.1.3

Python version

3.10.12

Operating System name and version

nixos

Additional context

I am trying to package this for nixos, I would be happy to do anything to help. Thank you for making this!

ishaan-jaff commented 1 year ago

@happysalada what version of litellm are you using ?

can you try pip install litellm==0.1.590 and retry

I want to ensure this is not caused by a litellm bug

happysalada commented 1 year ago

indeed that version fixed it, thank you!

imcsq commented 1 year ago

@ishaan-jaff Sorry, I enncounter the same problem as well. However, after using "pip install litellm==0.1.590", the problem still exists. Can you give me any advice and help?

Python version: 3.10.2, litellm version: 0.1.590, open-interpreter veresion: 0.1.3. I have tried both GPT-3.5-Turbo and GPT-4. The issue happens sometimes in both setups. But I have to say that it did not happen all the time and interpreter successfully ran some codes given by GPT3.5/4.

I/O history: ... O:
Great! We have successfully imported the necessary libraries, pandas and openpyxl.
Now, let's move on to the next step of the plan, which is to read the Excel file and select the "X" sheet.

file_path = '...(omit).xlsx'
df = pd.read_excel(file_path, sheet_name='X')

Would you like to run this code? (y/n)

I: y

O:
file_path = '...(omit).xlsx'
df = pd.read_excel(file_path, sheet_name='X')

Traceback (most recent call last): File "/home/ubuntu/miniconda3/envs/oienv1/bin/interpreter", line 8, in sys.exit(cli()) File "/home/ubuntu/miniconda3/envs/oienv1/lib/python3.10/site-packages/interpreter/interpreter.py", line 131, in cli cli(self) File "/home/ubuntu/miniconda3/envs/oienv1/lib/python3.10/site-packages/interpreter/cli.py", line 207, in cli interpreter.chat() File "/home/ubuntu/miniconda3/envs/oienv1/lib/python3.10/site-packages/interpreter/interpreter.py", line 287, in chat self.respond() File "/home/ubuntu/miniconda3/envs/oienv1/lib/python3.10/site-packages/interpreter/interpreter.py", line 812, in respond self.respond() File "/home/ubuntu/miniconda3/envs/oienv1/lib/python3.10/site-packages/interpreter/interpreter.py", line 812, in respond self.respond() File "/home/ubuntu/miniconda3/envs/oienv1/lib/python3.10/site-packages/interpreter/interpreter.py", line 723, in respond if chunk["choices"][0]["finish_reason"] or llama_function_call_finished: KeyError: 'finish_reason'