OpenInterpreter / open-interpreter

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

Claude Sonnet won't write complete code #1374

Open MikeBirdTech opened 1 month ago

MikeBirdTech commented 1 month ago

Describe the bug

When using a custom profile with claude-3-5-sonnet-20240620, the code generated is never complete and always results in an error. This usually occurs after a : or a number but not always. I updated the profile to use openai/gpt-4o and it was able to write code correctly, even when asked to make the code more robust to test for length limits.

Reproduce

Create a profile with:

from interpreter import interpreter

# LLM settings
interpreter.llm.model = "claude-3-5-sonnet-20240620"
interpreter.llm.supports_functions = False
interpreter.llm.execution_instructions = False
interpreter.llm.max_tokens = 4096
interpreter.llm.context_window = 10000

# Computer settings
interpreter.computer.import_computer_api = False

# Misc settings
interpreter.auto_run = False
interpreter.offline = False

# Custom Instructions
interpreter.custom_instructions=f"""
..."""

Run interpreter --profile <name of profile.py>

Ask it to do something that requires code, for example "Summarize this pdf: "

Expected behavior

Writes complete code

Screenshots

Screenshot 2024-07-31 at 10 12 37 AM Screenshot 2024-07-31 at 10 13 05 AM

Open Interpreter version

Open Interpreter 0.3.4 Local III

Python version

Python 3.11.7

Operating System name and version

MacOS

Additional context

No response

AllanJJJ commented 1 month ago

I met similar issue. It seems that the last line of the code output will be discard. image

Notnaton commented 1 month ago

Using verbose does it send a stop token?

MikeBirdTech commented 1 month ago

Interesting development. I set interpreter.llm.supports_functions to True.

Now it writes code like execute("bash", "ls ~/Desktop | wc -l") and then exits immediately. Doesn't run the code

MikeBirdTech commented 1 month ago

Using verbose does it send a stop token?

In my last couple tests, yes

"Chunk in terminal_interface: {'role': 'assistant', 'type': 'code', 'format': 'bash', 'end': True}"