Claude 3 - Crash after code execution
Describe the bug
I am running open interpreter with the new claude 3 model on a google colab.. Here are the parameters.
interpreter.llm.model = "claude-3-opus-20240229" interpreter.llm.context_window = 200000 interpreter.llm.max_tokens = 4000
The model runs fine until it starts executing code. For instance it writes some code to simulate an unbiased coinflip, it executes it, the result of the code (i.e. the output of the python function) actually gets printed out, but then the whole program just blocks and does not continue.
If run the same thing but with gpt-4 it works flawlessly.
Reproduce
- open a google colab
- Set the following parameter:
interpreter.llm.model = "claude-3-opus-20240229" interpreter.llm.context_window = 200000 interpreter.llm.max_tokens = 4000
-
interpreter.chat()
-
type "Run a simulation of 1000 unbiased coinflips and report the result."
Expected behavior
Run code, and then report the result to the user who can then pass new comands.
Screenshots
No response
Open Interpreter version
0.2.0
Python version
3.10.12
Operating System name and version
google colab
Additional context
No response
Similar issue:
{"type":"error","error":{"type":"invalid_request_error","message":"messages: all messages must have non-empty content
except for the optional final assistant message"}}
Yeah, when Claude3 works with open-interpreter it's amazing, but errors like the following are all too frequent. I can't tell exactly what's going on, but in the middle of the stacktrace, there's:
litellm.llms.anthropic.AnthropicError:
{"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}
This is strange, because open-interpreter has successfully started generating output with Claude's help.
Further down the trace, there's this:
litellm.exceptions.BadRequestError: AnthropicException -
{"type":"error","error":{"type":"invalid_request_error","message":"messages: all messages must have
non-empty content except for the optional final assistant message"}}
Anyway, here's a full example stack trace, hopefully it's of some use.
```error [0307/154004.466361:ERROR:trust_store_mac.cc(750)] Error parsing certificate: ERROR: Failed parsing extensions33409 bytes written to file /Users/***/Library/Application Support/Open Interpreter/3561784246.png
Python Version: 3.11.0
Pip Version: 24.0
Open-interpreter Version: cmd:Interpreter, pkg: 0.2.0
OS Version and Architecture: macOS-14.3-arm64-arm-64bit
CPU Info: arm
RAM Info: 16.00 GB, used: 8.39, free: 0.32
# Interpreter Info
Vision: False
Model: claude-3-sonnet-20240229
Function calling: None
Context window: None
Max tokens: None
Auto run: True
API base: None
Offline: False
Curl output: Not local
# Messages
System Message: You are Open Interpreter, a world-class programmer that can complete any goal by
executing code. First, write a plan. Always recap the plan between each code block (you have extreme short-term memory loss, so you need to recap the plan between each message block to retain it). When you execute code, it will be executed on the user's machine. The user has given you full and complete permission to execute any code necessary to complete the task. Execute the code. If you want to send data between programming languages, save the data to a txt or json. You can access the internet. Run any code to achieve the goal, and if at first you don't succeed, try again and again. You can install new packages. When a user refers to a filename, they're likely referring to an existing file in the directory you're currently executing code in. Write messages to the user in Markdown. In general, try to make plans with as few steps as possible. As for actually executing code to carry out that plan, for stateful languages (like python, javascript, shell, but NOT for html which starts from 0 every time) it's critical not to try to do everything in one code block. You should try something, print information about it, then continue from there in tiny, informed steps. You will never get it on the first try, and attempting it in one go will often lead to errors you cant see. You are capable of any task.
{'role': 'user', 'type': 'message', 'content': "let's build a notetaking app"}
{'role': 'assistant', 'type': 'message', 'content': "Here's a plan to build a simple note-taking app using HTML, Bulma CSS, and JavaScript:\n\n1. Plan: Create a user interface with an input field to enter notes, a button to add notes, and a container to display existing notes.\n\n2. Set up HTML structure: Create a centered box with Bulma CSS class... create a new list item with the note text, and append it to the unordered list.\n - Clear the input field after adding a note.\n\n5. Load existing notes (optional): Retrieve previously saved notes from localStorage (or any other storage mechanism) and add them to the unordered list on page load."}
{'role': 'user', 'type': 'message', 'content': "let's do it!"}
{'role': 'assistant', 'type': 'code', 'format': 'html', 'content': '\n\n< lang="en">\n
\n \n \n
Same issue here, I get back this from the verbose log as well:
status_code: 401 Logging Details: logger_fn - None | callable(logger_fn) - False Logging Details LiteLLM-Failure Call self.failure_callback: []
Same issue, I've "solved" it by using OpenRouter instead of anthropic for the claude3 api calls. 'all messages must have non-empty content except for the optional final assistant message'
@cory2005 Can you elaborate on how you did this?
@JeremyAlain not sure about the OP, I was able to use interpreter --model openrouter/anthropic/claude-3-opus
The openrouter solution is working for me, but in colab it still crashes randomly for unknown reasons...
I had the same issue and from what I can tell (by printing out the params that are passed to the llm), the API key is defaulting to the OpenAI key instead of anthropic. Hence the 401 status code.
I still ran into the all messages must have non-empty content except for the optional final assistant message error next but haven't gotten through it yet.
From what I could tell by looking around quickly there isn't an intelligent selection of API key from env based on the model type. Though I could have missed something.
I also tried using a profile file but ran into an issue there.
ANYWAYS.....
I worked around the 401 status code issue by explicitly passing the anthropic API key i.e.
interpreter --model claude-3-opus-20240229 -ak "$ANTHROPIC_API_KEY"
Ok so profiles does work, I just wasn't passing the file extension for a non-default profile i.e. interpreter --profile claude.yaml works but not interpreter --profile claude
Is anyone still experiencing an issue with Claude 3?
There's a lot of good workarounds in this thread and we'll use them to come up with a reliable solution. If you are still experiencing issues that aren't resolved from this thread, please tag me @wardnath @jrmeland @ktynski @JeremyAlain @vaibhavard @jonathanhawleypeters @AAbushady @cory2005
Still experiencing the issue despite trying solutions mentioned here @MikeBirdTech
I also tried the proposed workarounds and found that they did not work. The assistant could generate plans just fine, and even execute the first plan, but the program always crashes immediately after executing the first plan. The stack trace basically matches the exemplars given early in the conversation. Specifically, they always contain these messages, in the given relative order:
{"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}{"type":"error","error":{"type":"invalid_request_error","message":"messages.2: all messages must have non-empty content except for the optional final assistant message"}}
I am manually specifying the --model and --api-key parameters to interpreter, which I have double checked for correctness. I am able to use the Anthropic client SDKs, so I know that the API key is correct.