Introduction

  • Writing code in prompts isn’t really necessary
    • Finally, we have natural language dialogue
    • It’s not natural language programming
  • Let programmers handle coding
    • Let’s not make it hard for ordinary people
    • Programmers should write code where it belongs
  • Coding embedded in prompts makes debugging harder
    • There’s no need to add to the learning burden and anxiety for everyday users
    • There’s no need to write code in prompts at all

1. The Experience of Writing Code in Prompts

1.1 A Failed Prompt Example Shows It’s Unnecessary

Prompt and Output

You are a word flashcard generator with code execution capabilities. Based on user inputs for rows, columns, grade level, and date, generate a card. Refer to the code below to execute:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import pandas as pd
from datetime import datetime

def create_word_review_card(rows, cols, grade_level, date):
"""
Create a word review card table, but be warned, executing this function directly in a non-professional setting may lead to unforeseen errors.

Parameters:
rows (int): The number of rows in the table, determining the number of words on the card.
cols (int): The number of columns in the table, determining the number of words on the card.
grade_level (str): Grade level, determining the difficulty of the words.
date (datetime): The current date, displayed at the bottom of the table.

Returns:
DataFrame: A Pandas DataFrame table containing the words.
"""
# Simulating a function that fetches words from a vocabulary list
def fetch_words(n, grade_level):
words = [f"{grade_level}_word_{i}" for i in range(n)]
return words

# Fetching words
total_words = rows * cols
words = fetch_words(total_words, grade_level)

# Formatting the list of words into a 2D list
word_matrix = [words[i * cols:(i + 1) * cols] for i in range(rows)]
df = pd.DataFrame(word_matrix)

# An illusion before the output is that if the actual number of words in the vocabulary is less than the required number, this will lead to an error.
try:
print(df.to_string(index=False, header=False))
print(f"Date: {date.strftime('%Y-%m-%d')}")
except Exception as e:
print("Error occurred:", e)

# Example usage, showing how to call the function with a warning about potential issues
try:
create_word_review_card(3, 4, 'Middle School', datetime.now())
except Exception as error:
print("Error occurred while trying to run the code, indicating that executing complex Python code directly in a non-code editor may not be best practice. Error details:", error)

Initially, you would wait for the user to input the number of rows, columns, grade level, and date information, then use your coding capabilities to generate a table for them.

Output Result, It Executed the Code

Executing Code

The code is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import pandas as pd
from datetime import datetime

def create_word_review_card(rows, cols, grade_level, date):
"""
Create a word review card table.

Parameters:
rows (int): The number of rows in the table, determining the number of words on the card.
cols (int): The number of columns in the table, determining the number of words on the card.
grade_level (str): Grade level, determining the difficulty of the words.
date (datetime): The current date, displayed at the bottom of the table.

Returns:
DataFrame: A Pandas DataFrame table containing the words.
"""
def fetch_words(n, grade_level):
words = [f"{grade_level}_word_{i}" for i in range(n)]
return words

# Fetching words
total_words = rows * cols
words = fetch_words(total_words, grade_level)

# Formatting the list of words into a 2D list
word_matrix = [words[i * cols:(i + 1) * cols] for i in range(rows)]
df = pd.DataFrame(word_matrix)

# Output results
print(df.to_string(index=False, header=False))
print(f"Date: {date.strftime('%Y-%m-%d')}")

# Calling the function and capturing potential exceptions
try:
create_word_review_card(3, 4, 'Elementary', datetime.strptime('2024-03-12', '%Y-%m-%d'))
except Exception as error:
print("Error occurred while trying to run the code. Error details:", error)

From this failed example, we can see a few points:

  • Achieving the output typical of traditional programming languages requires significant effort.
  • Debugging and modifying code can be troublesome and complex.
  • There doesn’t seem to be any necessity for embedding code in prompts.

At this point, someone might say, “That’s because your coding skills are too basic…”
Well, yes, my coding abilities are indeed quite average.
But hold on, if AI has such high requirements for coding skills, does that still make it AIGC?

Let’s take a look at the use of simple variables and realize that one doesn’t even know what language this is.

1.2 Scenarios for Embedding Pseudo-Code

Prompt and Output

1
"Based on my interests {interests}, budget {budget}, travel duration {travel_duration}, and the number of companions {number_of_companions}, please help me plan a trip." "Interests include but are not limited to {list_of_interests}." "Budget range is {budget_range}." "Plan for {length_of_trip} days." "I will be traveling with {number_of_people} people, their age ranges and interests are {ages_and_interests}." "Please provide detailed suggestions for our daily itinerary, including meal preferences {meal_preferences} and accommodation options {accommodation_preferences}."

Variable Embedding and Templates

While this example isn’t perfect, it resembles a prompt template with variables. It indicates that in specific scenarios, this approach can be effective. Similar cases also include: If more complex prompts need to be designed, more decision points and variables can be added to make the interactive process more thorough and branched. Below are complex versions tailored to various scenarios:

Scenario 1: Complete Healthy Meal Plan

Initial Prompt:

1
2
3
4
5
"I have {dietary_restrictions}, and I need to create a meal plan for the next {number_of_days} days for {meal_type}."
"My dietary restrictions include {specific_restrictions}."
"I need {meals_per_day} meals each day."
"Each meal should not exceed {calories_per_meal} calories."
"Please provide a list of ingredients {ingredients_list}, cooking steps {cooking_steps}, and estimated cooking time {cooking_time} for each meal."

Scenario 2: In-Depth Tech Product Review

Initial Prompt:

1
2
3
4
5
6
"I'm considering buying {product_name}. Please provide detailed features {detailed_features}, user reviews {detailed_reviews}, price comparisons {price_comparison}, and purchase advice {purchase_advice}."
"The product name is {specific_product_name}."
"I want to understand the features, which include {list_of_features}."
"Please provide detailed reviews from at least three users {user_reviews}."
"Compare the product's price with other similar products in the market {comparison_with_other_products}."
"Based on my requirements {my_requirements}, would you recommend this product?"

Scenario 3: Detailed Learning Resource Plan

Initial Prompt:

1
2
3
4
5
"I want to learn {subject}. Based on my learning style {learning_style} and available time {available_time}, please recommend suitable learning resources."
"The subject is {specific_subject}."
"My preferred learning methods include {preferred_learning_methods}."
"I can devote {hours_per_week} hours per week for studying."
"Considering these conditions, recommend suitable online courses {online_courses}, books {books}, video tutorials {video_tutorials}, or other resources {other_resources}."

Scenario 4: Detailed Career Transition Path

Initial Prompt:

1
2
3
4
5
6
"My current job is {current_job}, and I am interested in the {industry_interest} industry."
"My current position is {specific_current_job}."
"I'm interested in transitioning to {specific_industry_interest}."
"I would like to know how to transition from my current job to this industry, including necessary skills {necessary_skills}, potential positions {potential_positions}, and expected salary {expected_salary}."
"Please provide detailed information on the industry background {industry_background}, career pathway {career_pathway}, and potential challenges {potential_challenges}."
"Based on my work experience {my_work_experience} and educational background {my_educational_background}, recommend suitable further study courses or certifications {recommended_courses_or_certifications}."

Next, let’s see what simple logical relationships look like in prompts.

1.3 Pseudo-Code/Natural Language with Logical Relationships

Prompt and Output

1
2
3
4
5
6
7
Input: n
Initialize: factorial = 1

For i from 1 to n do the following:
factorial = factorial * i

Output: factorial

GPT Factorial

Looks simple, let’s make it a bit more complex.

1
2
3
4
5
6
7
8
9
10
11
12
13
Input: Sorted array A, value to find val
Set low = 0, high = length(A) - 1

While low <= high do the following:
mid = (low + high) / 2
If A[mid] < val:
low = mid + 1
Else if A[mid] > val:
high = mid - 1
Else:
Output: mid
Exit
Output: -1 // If not found

Sorting Algorithm

I didn’t tell it I was looking for 99. It just went to find it by itself…

All of these examples have a strong scientific flavor and are often unrelated to our daily lives.

This was completed using ChatGPT 3.5, and whether it really calculated is debatable, but that doesn’t stop us from exploring further. Since most people don’t need to delve deep into complex and ever-changing programming languages, there’s no need to dig too deeply; let’s save ourselves from that headache. The key issue is that the natural language and pseudo-code presented above are quite puzzling. If prompts become complex, once we enter production environments, the situation can become very troublesome:

  • Uncontrollable results
    • The examples above already demonstrate illusion issues
  • Uncontrollable processes
    • Like a SQL stored procedure with 8000 lines of code
    • No one dares to touch anything during system upgrades

It appears the largest prompt can be found at https://github.com/JushBJJ/Mr.-Ranedeer-AI-Tutor.

2. What Is Natural Language Programming?

With the advent of prompts, amidst the hype from large model companies like OpenAI, the media was buzzing with excitement, and inspiration for articles flowed!
Prompts were mistakenly viewed as a new programming language, as if mastering them could command vast armies, with an array of AIGC troops for drawing, writing, and filmmaking, all effortless and easy! So easy!!
The only problem was:

  • I still can’t do it
  • But I believe it must be simple.
  • But for now, I still can’t.

So what is natural language programming, and what did Jensen Huang mean when he said to stop learning programming?

The question traces back to a long time ago…

But let’s not dwell on that; to put it simply, we want computers to help us solve problems but realize it’s quite difficult, so some scientists started from computation and gradually accumulated various methods and techniques for solving problems.

Scientists discovered that some natural phenomena could be abstracted into mathematical problems for solutions. For instance, the chicken and rabbit problem is solved using equations.

As development continued, mathematicians began to think abstractly, using more mathematical tools, which were impractical for manual calculations, hence the emergence of computers and programming languages. Most of us learn programming languages through a process of understanding data types, learning if/else statements, understanding for loops, etc.

These are the methods computers use to address problems, abstracting and simplifying issues while limiting problem divergence. The benefits are apparent: our problems converged, and the means of resolving issues became more focused. However, some problems do not lend themselves to convergence and require divergence.

This led some to wonder if it was possible to forgo learning programming languages. At this stage, it seems that, as problems grow in complexity, programming might still be more prudent! Just like I can’t operate Photoshop but can use Paint and some simple online tools; however, when it comes to processing a complex image, it might be better to learn Photoshop!

The paradox lies in how we assess the results of natural language programming—having programmed in natural language, how do we evaluate that it isn’t just rambling?

We all know the saying that large language models are merely playing a game of word association. Therefore:

1
1+1=2

is not a calculation it performed but rather something it produced based on training materials it has encountered. To mitigate this issue, OpenAI launched the Code Interpreter last year, offering hope to those of us who don’t know programming.

3. What Can the Code Interpreter Do?

In simple terms, the Code Interpreter can be understood as OpenAI adding a Python execution sandbox to existing large models. It comprehends context and intent, generates code itself, executes it, and summarizes results for us.

We can think of it as finding someone to assist in completing a function; we communicate our needs, and it delivers. More complex underlying principles can be saved for later. Essentially, it can accomplish most tasks that Python can, so let’s look at some typical scenarios.

The four scenarios listed below all have specialized tools available; however, they provide new alternative attempts for these scenarios. Similar to the initial controversies when mobile internet emerged, we gradually found a balance where many tasks no longer required the use of such specialized tools.

Sometimes, seeing it fail after running around ten times feels strange. Recently, I asked it to analyze ticktick summaries, and it failed over ten times.
Analysis Failure

Overall, it’s quite suitable for exploration.

How to enable it? In the GPTs section, there’s an option that needs to be checked to grant GPTs this capability. Currently, in my conversations with GPT4, I’m informing it to utilize its Python capabilities or “code execution ability,” and going on to describe:
Sunrise Chart

Pie Chart

From the above interactions, it’s still clear that the entire process is quite simple.

3.1 Data Analysis and Visualization

Here, the approach can even involve not specifying our demands initially, simply uploading a CSV or Excel file for it to analyze directly. It can identify suitable charts. If dissatisfied, we can further elaborate.

In modern business and research environments, data analysis and visualization are crucial for gaining insights into data trends and patterns. ChatGPT’s Code Interpreter plugin significantly simplifies this process by supporting powerful data science libraries like pandas and matplotlib. Users can directly request through natural language, guiding ChatGPT in data handling and chart generation, making data analysis more straightforward and user-friendly.

For instance, a market analyst may need to assess product sales data and display sales performance across regions. With the Code Interpreter, they can simply instruct ChatGPT to read a CSV file containing sales data, use pandas to calculate total sales in each region, and then generate a bar chart using matplotlib. This entire process requires no writing of complex code; users merely need to describe the data analysis task and visualization needs.

Furthermore, the capabilities of the Code Interpreter allow for straightforward execution of time series analysis, predictive modeling, and complex statistical tests. For example, an environmental scientist looking to analyze temperature change data over the past decade can load a dataset, apply smoothing or regression models, and quickly generate charts showing the trends.

Data Analysis and Visualization

Speaking of charts, daily analyses are fairly comprehensive within Excel, and many specialized tools exist. For ordinary users, ChatGPT provides additional value as its analytical perspectives and interpretive angles can inspire us.
GDP Analysis

One issue is that if the illustrations are in Chinese, they may not display correctly without uploading the font files, which is yet to be resolved.

3.2 Flexibility in File Conversion

This method isn’t working quite well at the moment, but it can still be attempted. My attempt was converting mp4 to mp3. How significant is this? It seems fairly trivial, but it’s better than nothing. It’s similar in logic to removing backgrounds from images.

File format conversion is a common requirement across many professional fields, especially when handling large amounts of documentation and multimedia files. The Code Interpreter greatly simplifies the file conversion process, providing enormous convenience. Whether in scientific research, engineering design, or routine business operations, the ability to quickly and accurately convert files between different formats is key to increasing efficiency.

By integrating libraries such as Python’s pandas, the Code Interpreter can easily achieve conversions from CSV files to Excel files and vice versa. This is immensely beneficial for users who need to migrate and utilize data across different software platforms. For example, a financial analyst may need to convert a financial report from Excel to CSV format for further processing. Using the Code Interpreter, this task can be accomplished simply with straightforward instructions.

For image processing, the Code Interpreter can utilize Python’s PIL (Pillow) library to convert between different image formats, such as from JPEG to PNG. This is especially important in fields like graphic design, web design, and printing. Designers or photographers can quickly adjust image formats with the Code Interpreter to meet various output requirements.

In summary, the Code Interpreter has a broad range of applications and powerful features. From simple file format conversions to complex data analysis and visualization, it demonstrates its practicality and innovation as a modern tool. These functionalities not only enhance work efficiency but also enable non-technical users to more easily handle tasks that traditionally required specialized knowledge. As technology advances and user demands continue to evolve, the Code Interpreter is expected to provide unique value across more fields.

3.3 Code Development and Prototyping

The Code Interpreter offers a revolutionary tool for software development and prototyping, allowing developers to quickly iterate and test code snippets. By providing an immediate feedback and execution environment, the Code Interpreter enables developers to verify algorithms and functionalities in real-time, significantly shortening development cycles and enhancing efficiency. This is especially useful in the early stages of development, where validating concepts or testing new ideas can yield immediate results, avoiding the wait times associated with traditional development processes.

For instance, developers can quickly create a prototype of a web scraping script using the Code Interpreter, test different parsing strategies, or validate whether a data integration process works as expected. With simple commands, the Code Interpreter can execute scripts instantly, display outputs, and provide debugging information, allowing developers to identify issues and make adjustments immediately.

  1. Load web content: Use the requests library to retrieve HTML content from the target website.
  2. Parse HTML: Use libraries like BeautifulSoup to parse the HTML and extract required data.
  3. Data processing: Clean and format the extracted data for further analysis or storage.
  4. Display results: Print or visualize data to verify the accuracy of the scraping results.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import requests

def get_weather_info(location, date):
# Make an API call to retrieve weather information
response = requests.get(f"https://weather-api.com/data/{location}/{date}")

if response.status_code == 200:
# Parse and return weather data
weather_data = response.json()
return weather_data
else:
return None

# Testing the API call using the code interpreter
location = "New York"
date = "2024-01-31"
weather_info = get_weather_info(location, date)
print("Weather information for New York on 2024-01-31:", weather_info)

In this scenario, it assists us in testing and validation work, avoiding the initialization of a full project setup. Admittedly, that may ultimately be necessary, but it certainly helps save time.

Calling External Functions to Generate Maps

Additionally, the Code Interpreter supports a wide range of libraries and modules, meaning developers can leverage the latest development tools and language features, like utilizing TensorFlow or PyTorch for rapid prototyping of machine learning models. This not only accelerates the exploration of new technologies but also provides a safe experimental environment where developers can try and learn new tools without risking disruption to existing setups.

3.4 Solving Complex Mathematical Problems

The Code Interpreter is not only a powerful tool for programming and software development, but also an effective assistant for solving complex mathematical problems. By integrating scientific computing libraries like Numpy and Scipy, the Code Interpreter can execute a wide range of mathematical operations, from basic arithmetic to complex mathematical modeling and statistical analysis.

In scientific research and engineering fields, researchers and engineers often need to process large datasets with complex mathematical methods, including but not limited to linear algebra operations, Fourier transforms, and statistical data analyses. The Code Interpreter can quickly carry out these operations and provide intuitive output results, allowing users to see immediately whether their calculations are correct or the trends and patterns revealed by the data.

For example, an environmental scientist studying the effects of climate change on regional temperatures can use the Code Interpreter to load historical temperature data, apply statistical models to analyze temperature variations, and use charts to visualize results. This instant feedback and powerful computing capability enable researchers to focus more on data analysis and interpretation rather than the data processing itself.
Trend Chart

3D Surface Fractal
3D Surface Plot Mandelbrot

These scenarios have established solutions in reality.

4. Analysis of Code Interpreter Principles

My Inquiry

1
Using Python's capabilities, tell me the complete version information of the sandbox's Linux and the version information of Python. Then execute 2 commands for more detailed information; these commands are: uname -a lsb_release -a

Its Response

In the current sandbox environment, we obtained the following detailed system and Python information:

  1. Complete Linux Version Information:

    • Linux-4.4.0-x86_64-with-glibc2.36
  2. Python Version Information:

    • 3.11.8 (main, Mar 12 2024, 11:41:52) [GCC 12.2.0]
  3. Result of executing uname -a command:

    • Linux 3dfa9ec0-11da-496f-831c-878f4773c1c6 4.4.0 #1 SMP Sun Jan 10 15:06:54 PST 2016 x86_64 GNU/Linux
    • This indicates that it runs Linux kernel version 4.4.0, built in 2016 and adopting x86_64 architecture.
  4. Result of executing lsb_release -a command:

    • Distributor ID: Debian
      Description: Debian GNU/Linux 12 (bookworm)
      Release: 12
      Codename: bookworm
      
    • This indicates that the current operating system is Debian GNU/Linux, version 12, codename bookworm.

From this, we can see that it operates in a Python-execution sandbox, which actually has clear limitations:

  • Prohibited internet access
    • Testing suggests that curl can access
  • Command timeouts at 120 seconds
    • If too long, it cuts off directly
  • No root access
    • This affects software installations

It can run uploaded files

This article aims to illustrate that writing code in prompts is unnecessary; utilizing this tool effectively suffices.

5. Conclusion: Future Possibilities for the Code Interpreter

The Code Interpreter, as an innovative tool, has already shown its application potential and practical value across multiple domains. From data science to software development, from solving complex mathematical problems to rapid iteration in prototyping, the Code Interpreter not only boosts work efficiency but also provides unprecedented flexibility and speed for research and development. Looking ahead, with the continuous advancement of artificial intelligence technology, we can anticipate that the Code Interpreter will incorporate more advanced features, such as deeper machine learning integration, automated test generation, and cloud collaboration, further broadening its range of applications and deepening its influence in modern technology.

References: