. The Claude.ai consumer-facing interface just shipped a major new feature, which they’re calling “the analysis tool”. (View Highlight)
It’s their answer to OpenAI’s ChatGPT Code Interpreter mode: Claude can now chose to solve models by writing some code, executing that code and then continuing the conversation using the results from that execution. (View Highlight)
ChatGPT Code Interpreter (and the under-documented Google Gemini equivalent) both work the same way: they write Python code which then runs in a secure sandbox on OpenAI or Google’s servers. (View Highlight)
Claude does things differently. It uses JavaScript rather than Python, and it executes that JavaScript directly in your browser - in a locked down Web Worker that communicates back to the main page by intercepting messages sent to console.log(). (View Highlight)
It’s implemented as a tool called repl, and you can prompt Claude like this to reveal some of the custom instructions that are used to drive it: (View Highlight)
Analyzing user-uploaded files, particularly when these files are large and contain more data than you could reasonably handle within the span of your output limit (which is around 6,000 words). (View Highlight)
The analysis tool has access to a fs.readFile() function that can read data from files you have shared with your Claude conversation. It also has access to the Lodash utility library and Papa Parse for parsing CSV content. The instructions say: (View Highlight)
You can import available libraries such as lodash and papaparse in the analysis tool. However, note that the analysis tool is NOT a Node.js environment. Imports in the analysis tool work the same way they do in React. Instead of trying to get an import from the window, import using React style import syntax. E.g., you can write import Papa from 'papaparse'; (View Highlight)
I’m not sure why it says “libraries such as …” there when as far as I can tell Lodash and papaparse are the only libraries it can load - unlike Claude Artifacts it can’t pull in other packages from its CDN. (View Highlight)
Code that you write in the analysis tool is NOT in a shared environment with the Artifact. This means:
• To reuse code from the analysis tool in an Artifact, you must rewrite the code in its entirety in the Artifact.
• You cannot add an object to the window and expect to be able to read it in the Artifact. Instead, use the window.fs.readFile api to read the CSV in the Artifact after first reading it in the analysis tool. (View Highlight)
A further limitation of the analysis tool is that any files you upload to it are currently added to the Claude context. This means there’s a size limit, and also means that only text formats work right now - you can’t upload a binary (as I found when I tried uploading sqlite.wasm to see if I could get it to use SQLite). (View Highlight)