Open Interpreter’s ChatGPT-Like Interface: The Future of Natural Language Code Execution

There’s an ever-increasing need for practical, adaptable, and user-friendly tools in the dynamic world of software development and programming. Developers are looking for solutions that allow them to operate effortlessly in their local development setups without being hampered by the confines of online hosted platforms. This article delves into a revolutionary answer to these demands – Open Interpreter.

While the Code Interpreter from OpenAI, based on the GPT-4 architecture, is undeniably transformative, it has limitations. Being a hosted solution, OpenAI’s offering runs in a distant, regulated environment, restricting developers from harnessing the full capabilities of their local configurations. Among the challenges faced are no access to the internet, a confined list of pre-loaded packages, a cap on uploads at 100 MB, and a runtime restriction of 120 seconds. Moreover, if the session terminates, any produced files or links vanish, creating obstacles for extended assignments.

With Open Interpreter, developers can fully utilize their computer’s resources, side-stepping the limitations of online services.

Understanding Open Interpreter

At its core, Open Interpreter is a bridge between human language and computer code. Instead of manually writing out every line of code, users can describe their intentions in natural language, and Open Interpreter translates that into executable code. This offers an entirely new programming approach, simplifying and streamlining the process.

Features of Open Interpreter

  1. Code Interpretation from Natural Language: The primary selling point is that this feature allows users to describe a task in English, and the tool will convert it into executable code. It significantly reduces barriers to programming for non-developers.
  2. ChatGPT-Like Interface: With a user-friendly, chatbot-like interface, users can have interactive programming sessions, making the coding experience more intuitive.
  3. Data Handling Capabilities: Beyond simple code interpretation, Open Interpreter is a powerhouse for data-related tasks. It provides a comprehensive toolset for data professionals, from data visualization to in-depth analysis.
  4. Open-Source Nature: Open Interpreter is a gift to the developer community. As an open-source project, developers can contribute to its growth, refining its features and expanding its capabilities.
  5. Local Execution: In an age where data privacy is paramount, Open Interpreter allows for local code execution, ensuring that sensitive data remains on the user’s machine.

What can I do with Open Interpreter?

  1. Educational Purposes: This can revolutionize teaching programming and other computer-related tasks. Students can communicate with their machines more intuitively, eliminating the steep learning curve associated with traditional programming.
  2. Data Science & Analysis: As it can plot, clean, and analyze large datasets, researchers and data scientists can streamline their workflow using natural language to manipulate and visualize their data.
  3. Automation: For individuals who aren’t traditionally programmers, Open Interpreter might offer a more accessible avenue for automating tasks on their computers, from simple file manipulations to more complex functions like web scraping.
  4. Content Creation: The ability to create and edit photos, videos, and PDFs using natural language commands could revolutionize how content creators work. Imagine telling your computer how to edit a video or photo without manually going through the process.
  5. Integration with Other Tools: Mention of it working with Code Llama or GPT-4 by using an OpenAI API key suggests that it can be integrated with other tools, increasing its utility.
  6. Accessibility: For people with disabilities, communicating with a computer using natural language could make computing more accessible, especially if paired with voice recognition software.
  7. Security: As with any powerful tool, there are potential risks. Running code or commands without understanding the implications can lead to unintended consequences. Users should be educated about the risks, especially when executing commands that can modify their system or data.
  8. Open Source Community: The rapid growth in stars on GitHub indicates a strong community interest. This suggests that developers worldwide might contribute to its development, making the tool even more robust and versatile.

How do you install and use the Open Interpreter?

At this moment, you have to install it inside a Python environment.

  1. First, you have to install Python; in my case, I have Python 3.11.2 installed.
  2. In this step, it’s not necessary, but I recommend you install the Visual Studio Code. Press shift+control+p and create a Python virtual environment.
  3. I created the “requirements.txt file” with the ChatGPT Code Interpreter libraries.
Python
pandas
numpy
scipy
xarray
#Machine Learning:
scikit-learn
xgboost
keras
torch
#Natural Language Processing:
nltk
spacy
textblob
gensim
#Data Visualization:
matplotlib
seaborn
plotly
bokeh
#Web Scraping and Network:
requests
urllib3
aiohttp
beautifulsoup4
#Deep Learning:
keras
torch
theano
#Image Processing:
pillow
imageio
opencv-python
scikit-image
#Audio Processing:
librosa
pyaudio
soundfile
#File Format:
openpyxl
xlrd
pyPDF2
python-docx
#Database:
sqlalchemy
psycopg2
mysql-connector-python
#Web Development:
flask
django
tornado
quart
#Others:
pytest
joblib
pytz
pyyaml

python-docx
pdfkit
wkhtmltopdf
pandoc 
pdfplumber  
reportlab
open-interpreter

Type pip install -r requirements.txt to install the most used Python libraries.

PowerShell
pip install -r requirements.txt

After that, install the Open Interpreter.

PowerShell
pip install open-interpreter

After installation, run interpreter:

PowerShell
interpreter -y

Now, you are free to use and test the Code Interpreter. If you want more detailed information, go to the GitHub oficial page.

Insert the prompt:

create a csv file with a year from 2000 to 2023 and total of sales amount column with ramdom numbers

Note that a file called sales_data.csv was automatically created in the folder.

Now type this prompt: create a line visual to show this sales_data.csv and plot on the screen.

You can do whatever you want. You also can create a code to use Open Interpreter, like the example below.

Python
import interpreter

interpreter.chat("Plot AAPL and META's normalized stock prices") # Executes a single command
interpreter.chat() # Starts an interactive chat

Type py teste.py to execute this code.

Python
PS D:\interpreter> & d:/interpreter/.venv/Scripts/Activate.ps1
(.venv) PS D:\interpreter> py teste.py

▌ Model set to GPT-4
Tip: To run locally, use interpreter --local

Open Interpreter will require approval before running code. Use interpreter -y to bypass this.

Press CTRL-C to exit.

  To plot AAPL and META's normalized stock prices, we will need to follow these steps:

   1 Install necessary packages. We will need pandas, yfinance, and matplotlib for Python.
   2 Download the stock prices for AAPL and META using yfinance.
   3 Normalize the stock prices.
   4 Plot the normalized stock prices.

  Let's start with the first step, which is installing the necessary packages.

  import pkg_resources                                                                                                                                                          
                                                                                                                                                                                
  REQUIRED_PACKAGES = ['pandas', 'yfinance', 'matplotlib']                                                                                                                      
                                                                                                                                                                                
  for package in REQUIRED_PACKAGES:                                                                                                                                             
      try:                                                                                                                                                                      
          dist = pkg_resources.get_distribution(package)                                                                                                                        
          print('{} ({}) is installed'.format(dist.key, dist.version))                                                                                                          
      except pkg_resources.DistributionNotFound:                                                                                                                                
          print('{} is NOT installed'.format(package))                                                                                                                          

  import pkg_resources                                                                                                                                                          
                                                                                                                                                                                
  REQUIRED_PACKAGES = ['pandas', 'yfinance', 'matplotlib']                                                                                                                      
                                                                                                                                                                                
  for package in REQUIRED_PACKAGES:                                                                                                                                             
          dist = pkg_resources.get_distribution(package)                                                                                                                        
          print('{} ({}) is installed'.format(dist.key, dist.version))                                                                                                          
      except pkg_resources.DistributionNotFound:                                                                                                                                
          print('{} is NOT installed'.format(package))                                                                                                                          


  pandas (2.1.0) is installed
  yfinance (0.2.28) is installed
  matplotlib (3.8.0) is installed

  Great! All the necessary packages are already installed.

  Now, let's move on to the next step: downloading the stock prices for AAPL (Apple Inc.) and META (Meta Platforms Inc., formerly Facebook Inc.) using the yfinance package.    
  We will download the last 5 years of daily closing prices.

  import yfinance as yf                                                                                                                                                         
                                                                                                                                                                                
  # Define the ticker symbols                                                                                                                                                   
  symbols = ['AAPL', 'META']                                                                                                                                                    
                                                                                                                                                                                
  # Download the stock data                                                                                                                                                     
  stock_data = yf.download(symbols, start='2017-01-01', end='2022-12-31')['Close']                                                                                              
                                                                                                                                                                                
  # Print the first few rows of the data                                                                                                                                        
  stock_data.head()                                                                                                                                                             

  import yfinance as yf                                                                                                                                                         
                                                                                                                                                                                
  # Define the ticker symbols                                                                                                                                                   
  symbols = ['AAPL', 'META']                                                                                                                                                    
                                                                                                                                                                                
  stock_data = yf.download(symbols, start='2017-01-01', end='2022-12-31')['Close']                                                                                              
                                                                                                                                                                                
  # Print the first few rows of the data                                                                                                                                        
  stock_data.head()                                                                                                                                                             

  [                       0%%                      ]
  [*********************100%%**********************]  2 of 2 completed
  AAPL        META
  Date
  2017-01-03  29.037500  116.860001
  2017-01-04  29.004999  118.690002
  2017-01-05  29.152500  120.669998
  2017-01-06  29.477501  123.410004
  2017-01-09  29.747499  124.900002

  We have successfully downloaded the stock prices for AAPL and META.

  The next step is to normalize these stock prices. Normalizing the stock prices allows us to compare the two stocks on the same scale. We will normalize the prices such that  
  the first price is 1 and all subsequent prices are relative to the first price.

  normalized_data = stock_data / stock_data.iloc[0]                                                                                                                             
                                                                                                                                                                                
  # Print the first few rows of the normalized data                                                                                                                             
  normalized_data.head()                                                                                                                                                        

  normalized_data = stock_data / stock_data.iloc[0]                                                                                                                             
                                                                                                                                                                                
  # Print the first few rows of the normalized data                                                                                                                             
  normalized_data.head()                                                                                                                                                        

  AAPL      META
  Date
  2017-01-03  1.000000  1.000000
  2017-01-04  0.998881  1.015660
  2017-01-05  1.003960  1.032603
  2017-01-06  1.015153  1.056050


  The stock prices for AAPL and META have been successfully normalized.

  Now, let's move on to the final step: plotting the normalized stock prices. We will use the matplotlib package for this.

  import matplotlib.pyplot as plt                                                                                                                                               
                                                                                                                                                                                
  # Create a new figure                                                                                                                                                         
  plt.figure(figsize=(14, 7))                                                                                                                                                   
                                                                                                                                                                                
  # Plot the normalized stock prices                                                                                                                                            
  for symbol in symbols:                                                                                                                                                        
      plt.plot(normalized_data.index, normalized_data[symbol], label=symbol)                                                                                                    
                                                                                                                                                                                
  # Add a title and labels                                                                                                                                                      
  plt.title('Normalized Stock Prices: AAPL vs META')                                                                                                                            
  plt.xlabel('Date')                                                                                                                                                            
  plt.ylabel('Normalized Price')                                                                                                                                                
  plt.legend()                                                                                                                                                                  
                                                                                                                                                                                
  # Save the plot as an image                                                                                                                                                   
  plt.savefig('normalized_stock_prices.png')                                                                                                                                    
                                                                                                                                                                                
  # Close the plot                                                                                                                                                              
  plt.close()                                                                                                                                                                   

  import matplotlib.pyplot as plt                                                                                                                                               
                                                                                                                                                                                
  # Create a new figure                                                                                                                                                         
  plt.figure(figsize=(14, 7))                                                                                                                                                   
                                                                                                                                                                                
  # Plot the normalized stock prices                                                                                                                                            
  for symbol in symbols:                                                                                                                                                        
      plt.plot(normalized_data.index, normalized_data[symbol], label=symbol)                                                                                                    
                                                                                                                                                                                
  # Add a title and labels                                                                                                                                                      
  plt.title('Normalized Stock Prices: AAPL vs META')                                                                                                                            
  plt.xlabel('Date')                                                                                                                                                            
  plt.ylabel('Normalized Price')                                                                                                                                                
  plt.legend()                                                                                                                                                                  
                                                                                                                                                                                
  # Save the plot as an image                                                                                                                                                   
  plt.savefig('normalized_stock_prices.png')                                                                                                                                    
                                                                                                                                                                                
  # Close the plot                                                                                                                                                              
  plt.close()█                                                                                                                                                                  

  <Figure size 1400x700 with 0 Axes>
  [<matplotlib.lines.Line2D object at 0x0000024DE75D0B90>]
  [<matplotlib.lines.Line2D object at 0x0000024DE7604990>]
  Text(0.5, 1.0, 'Normalized Stock Prices: AAPL vs META')
  Text(0.5, 0, 'Date')
  Text(0, 0.5, 'Normalized Price')
  <matplotlib.legend.Legend object at 0x0000024DE75DAB50>

Let’s try asking for a search on the internet: What are the last 10 BBC news headlines?

Python
(.venv) PS D:\interpreter> interpreter -y
> What are the last 10 BBC news headlines?

  To get the last 10 BBC news headlines, we can use web scraping techniques. Python has several libraries for this purpose, such as BeautifulSoup and requests. Here is the     
  plan:

   1 Install necessary Python packages (requests and BeautifulSoup) if they are not already installed.
   2 Fetch the BBC News homepage HTML using requests.
   3 Parse the HTML using BeautifulSoup to find the news headlines.
   4 Extract and return the last 10 news headlines.

  Let's start with the first step, which is to check if the necessary Python packages are installed. If not, we will install them.



  import pkg_resources                                                                                                                                                          
                                                                                                                                                                                
  REQUIRED_PACKAGES = ['beautifulsoup4', 'requests']                                                                                                                            
                                                                                                                                                                                
  for package in REQUIRED_PACKAGES:                                                                                                                                             
      try:                                                                                                                                                                      
          dist = pkg_resources.get_distribution(package)                                                                                                                        
          print('{} ({}) is installed'.format(dist.key, dist.version))                                                                                                          
      except pkg_resources.DistributionNotFound:                                                                                                                                
          print('{} is NOT installed'.format(package))                                                                                                                          


  beautifulsoup4 (4.12.2) is installed
  requests (2.31.0) is installed


  Great! Both 'beautifulsoup4' and 'requests' packages are already installed.

  Now, let's move to the next step of the plan: Fetch the BBC News homepage HTML using requests. We will send a GET request to the BBC News homepage URL and print the status   
  of the response to ensure we are able to connect to the page.

  import requests                                                                                                                                                               
                                                                                                                                                                                
  url = 'https://www.bbc.co.uk/news'                                                                                                                                            
  response = requests.get(url)                                                                                                                                                  
                                                                                                                                                                                
  print('Status code:', response.status_code)                                                                                                                                   

  Status code: 200


  The status code 200 indicates that we successfully fetched the HTML of the BBC News homepage.

  Now, let's move to the next step of the plan: Parse the HTML using BeautifulSoup to find the news headlines. We will parse the HTML and find the elements that contain the    
  news headlines. For this, we need to know the structure of the BBC News homepage. The headlines are usually contained in HTML elements with specific class names. We will     
  try to find these elements and print some of them to verify that we are correctly extracting the headlines.

  from bs4 import BeautifulSoup                                                                                                                                                 
                                                                                                                                                                                
  soup = BeautifulSoup(response.text, 'html.parser')                                                                                                                            
                                                                                                                                                                                
  # BBC News headlines are usually in h3 elements with class 'gs-c-promo-heading__title'                                                                                        
                                                                                                                                                                                
  # Print the first 5 headlines to verify                                                                                                                                       
  for headline in headlines[:5]:                                                                                                                                                
      print(headline.text.strip())                                                                                                                                              

  Russell Brand accused of rape and sexual assault
  Russell Brand accused of rape and sexual assault
  A barren wasteland with a lingering smell of death
  Diamonds and diplomacy: How a US envoy fell from grace
  'Everything has just been completely ripped away'


  We have successfully extracted the news headlines from the BBC News homepage. The headlines printed above are a sample of the headlines we found.

  Now, let's move to the final step of the plan: Extract and return the last 10 news headlines. We will extract the text from the last 10 headline elements and return them.    

  # Get the last 10 headlines                                                                                                                                                   
  last_10_headlines = [headline.text.strip() for headline in headlines[-10:]]                                                                                                   
                                                                                                                                                                                
  last_10_headlines                                                                                                                                                             


  ['How old is too old to lead?', 'The companies staying fully remote', "A 'beach towel revolt' sweeping Greece", 'Sexton breaks record as eight-try Ireland beat Tonga',       
  'Wales struggle past Portugal at World Cup', 'Brighton beat Man Utd as fans boo Ten Hag', 'Barcelona crush Betis to go top', 'Sainz on Singapore pole as angry Verstappen     
  struggles', "'We have a good vibe' - Ten Hag avoids Sancho questioning", 'Newcastle beat Brentford to ease pressure on Howe']

  Here are the last 10 BBC news headlines:

    1 'How old is too old to lead?'
    2 'The companies staying fully remote'
    3 "A 'beach towel revolt' sweeping Greece"
    4 'Sexton breaks record as eight-try Ireland beat Tonga'
    5 'Wales struggle past Portugal at World Cup'
    6 'Brighton beat Man Utd as fans boo Ten Hag'
    7 'Barcelona crush Betis to go top'
    8 'Sainz on Singapore pole as angry Verstappen struggles'
    9 "'We have a good vibe' - Ten Hag avoids Sancho questioning"
   10 'Newcastle beat Brentford to ease pressure on Howe'

Can you create a PDF file with these 10 BBC news headlines to finish the test?

Python
> can you crate a pdf file with this 10 BBC news headlines?

  Sure, we can create a PDF file with these headlines. We will use the Python library reportlab for this purpose. Here is the plan:

   1 Install the necessary Python package (reportlab) if it is not already installed.
   2 Create a PDF file using reportlab and add the headlines to it.
   3 Save the PDF file.

  Let's start with the first step, which is to check if the necessary Python package is installed. If not, we will install it.


  REQUIRED_PACKAGES = ['reportlab']                                                                                                                                             
                                                                                                                                                                                
  for package in REQUIRED_PACKAGES:                                                                                                                                             
      try:                                                                                                                                                                      
          dist = pkg_resources.get_distribution(package)                                                                                                                        
          print('{} ({}) is installed'.format(dist.key, dist.version))                                                                                                          
      except pkg_resources.DistributionNotFound:                                                                                                                                
          print('{} is NOT installed'.format(package))                                                                                                                          


  reportlab (4.0.4) is installed


  Great! The 'reportlab' package is already installed.

  Now, let's move to the next step of the plan: Create a PDF file using reportlab and add the headlines to it. We will create a new PDF file, add each headline as a separate   
  paragraph, and then save the PDF file.



  from reportlab.lib.pagesizes import letter                                                                                                                                    
  from reportlab.pdfgen import canvas                                                                                                                                           
  from reportlab.lib.units import inch                                                                                                                                          
                                                                                                                                                                                
  # Create a new PDF file                                                                                                                                                       
  c = canvas.Canvas('BBC_headlines.pdf', pagesize=letter)                                                                                                                       
                                                                                                                                                                                
  # Set the font and size                                                                                                                                                       
  c.setFont('Helvetica', 12)                                                                                                                                                    
                                                                                                                                                                                
  # Add each headline as a separate paragraph                                                                                                                                   
  y = 750  # Start from the top of the page                                                                                                                                     
  for i, headline in enumerate(last_10_headlines, 1):                                                                                                                           
      c.drawString(50, y, f'{i}. {headline}')                                                                                                                                   
      y -= 25  # Move down for the next headline                                                                                                                                
                                                                                                                                                                                
  # Save the PDF file                                                                                                                                                           
  c.save()                                                                                                                                                                      

  The PDF file 'BBC_headlines.pdf' with the last 10 BBC news headlines has been created successfully. You can find it in the current working directory (D:\interpreter).        

It’s fantastic. Can you imagine how many things you can do with this?

They also have a Google Colab version with many examples of use.

I created a GitHub repository with this project. If you want, you can click here to download or clone in this hyperlink: https://github.com/LawrenceTeixeira/OpenInterpreter.git

Follow bellow the official Open Interpreter website.

https://openinterpreter.com/

Open Interpreter 🖥️ ChatGPT Code Interpreter You Can Run LOCALLY!

How Does Open Interpreter Stand Out?

While numerous code interpreters are available, Open Interpreter sets itself apart in its approach to bridging human language and computer code. The emphasis on natural language processing combined with the power of local execution ensures that it’s both accessible to newcomers and powerful enough for seasoned developers.

Conclusion

Open Interpreter stands as a monumental advancement in local development platforms. Its superior features equip developers to operate productively and with adaptability, unfettered by the confines of online services. With Open Interpreter by your side, step into the next era of software development and discover unparalleled avenues in your local development odyssey. It is more than just a tool; it’s a step forward in the evolution of programming. Combining the powers of natural language processing, AI, and code interpretation paves the way for a more inclusive and streamlined coding environment. As the world embraces digital solutions, tools like Open Interpreter make technology accessible to everyone.

That’s it for today!

Sources:

The Open Interpreter Project

KillianLucas/open-interpreter: OpenAI’s Code Interpreter in your terminal, running locally (github.com)

https://beebom.com/how-run-open-interpreter-run-chatgpt-code-interpreter-locally/

https://openaimaster.com/what-is-open-interpreter/