-
Notifications
You must be signed in to change notification settings - Fork 3
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.
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...The user input in the demo follows the following script:
- write a python script to download the csv from this link: https://covid.ourworldindata.org/data/owid-covid-data.csv
- now load the csv into a dataframe and print out the columns and head
- that's a lot of data, can you filter for just new US cases?
- can you plot this
- 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?
- there seem to be some cyclicalities and artifacts in the raw data. Can you plot a 7-day moving average?
- looks good. Can you tell me what day had the most new cases?
- What was the mean and median number of new cases? use the 7-day moving average
- 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. At each step the agent is able to write a script to run in the python tool that solves the current prompt, making use of persistent variables in the tool during successive calls.
- passing in python modules, classes, functions, variables, etc.
- having the python tool run a default prelude script (e.g. for imports, etc)
- oneshot version of the tool with no persistence