Skip to content

Python Interpreter Tool

David-Andrew Samson edited this page May 1, 2023 · 9 revisions

Archytas provides a (currently a work in progress) python tool that allows the LLM to write/run scripts in a persistent environment.

Usage

from archytas.tools import PythonTool


tools = [PythonTool]
agent = ReActAgent(tools=tools, verbose=True)

# query agent
response = agent.query('write me a script that prints out the first 100 prime numbers')
print(response)
#etc...

Demo

Watch the video
click to watch original video on youtube

The user input in the demo follows the following script:

  1. write a python script to download the csv from this link: https://covid.ourworldindata.org/data/owid-covid-data.csv
  2. now load the csv into a dataframe and print out the columns and head
  3. that's a lot of data, can you filter for just new US cases?
  4. can you plot this
  5. in the plot, there are too many dates on the x-axis, so they all just overlap into one big black blob. Can you fix that?
  6. there seem to be some cyclicalities and artifacts in the raw data. Can you plot a 7-day moving average?
  7. looks good. Can you tell me what day had the most new cases?
  8. What was the mean and median number of new cases? use the 7-day moving average
  9. Can you plot a histogram of the new daily cases (from the 7-day average) and mark the mean and median

The only special libraries that are in the environment are pandas, and matplotlib

TODO

persistent vs oneshot

Clone this wiki locally