yihong0618 和朋友们的频道 头像

消息来源频道

yihong0618 和朋友们的频道

@hyi0618

频道8,612 位成员公开可见0 人在线

yihong0618 和朋友们的频道

成员规模8,612 位成员
在线情况0 人在线
消息总数10,129 条消息
浏览量总数3,281,861 次浏览

在这个频道里搜索消息……

t.me/hyi0618

TIL:
Link: https://github.com/simonw/til/blob/main/llms/code-interpreter-expansions.md
📌 Expanding ChatGPT Code Interpreter with Python packages, Deno and Lua
The ChatGPT Code Interpreter alpha remains incredibly interesting. I wrote about how I was using it for Python and a few weeks ago. Today I found a neat pattern for expanding its capabilities with custom binaries.
Update: Code Interpreter often claims that it can't run binaries uploaded like this, but it looks like it still works if you.
If you don't yet have access to the alpha, the key thing to know is that it provides ChatGPT with access to a Python interpreter. It doesn't have network access - it can't make outbound HTTP requests, or download packages - but it can do all sorts of interesting things by running code.
✏️ Uploading files
One of the neatest features of Code Interpreter mode is that you can upload files to it.
This opens up a world of possibilities. For example, you can upload CSV files, or Excel files, or even SQLite databases and have it use Python and various baked-in libraries to process them - including rendering charts against data from them using matplotlib.
✏️ Installing extra Python packages
Today I found out you can upload Python wheels, too! If there's a package that you want to use you can grab the .whl files for it from PyPI, upload them to ChatGPT and it will install them into its own environment for the duration of that chat session.
If a library has dependencies you have to upload those, too.
To get my sqlite-utils library working I had to download and then upload the following files:
⦁ click_default_group_wheel-1.2.2-py3-none-any.whl
⦁ sqlite_fts4-1.0.3-py3-none-any.whl
⦁ sqlite_utils-3.30-py3-none-any.whl
It didn't need tabulate, click or python-dateutil since those were already included in the environment.
✏️ Installing Deno
One of the neat things about the Deno server-side JavaScript runtime is that it's packaged as a single binary.
Could uploading that binary be enough to grant ChatGPT the ability to run JavaScript?
To my surprise, the answer is yes!
I grabbed this file:
⦁ deno-x86_64-unknown-linux-gnu.zip
And uploaded it to ChatGPT. Then I told it:
Extract deno and make the binary executable and check its version
This totally worked! Here's the code it generated and executed:
import zipfile
import os
import subprocess
# Define the file paths
deno_zip_path = '/mnt/data/deno-x86_64-unknown-linux-gnu.zip'
deno_extract_path = '/mnt/data/deno-extracted'
# Extract the Deno ZIP archive
with zipfile.ZipFile(deno_zip_path, 'r') as zip_ref:
zip_ref.extractall(deno_extract_path)
# Get the path of the Deno binary
deno_binary_path = os.path.join(deno_extract_path, 'deno')
# Make the Deno binary executable
os.chmod(deno_binary_path, 0o755)
# Get the version of the Deno binary
try:
deno_version_output = subprocess.check_output([deno_binary_path, '--version'], universal_newlines=True)
except Exception as e:
deno_version_output = str(e)
deno_version_output
Which output the following:
deno 1.33.1 (release, x86_64-unknown-linux-gnu)
v8 11.4.183.1
typescript 5.0.3
Now I can tell it to run JavaScript code using Deno like this:
Write a hello world Deno program and execute it
It