Building a Python Engineer using GPT4

I write a lot of python daily and before having my daughter I used to love writing everything by hand -- after all I'm of the generation that learnt to code on pen and paper. But after having a kid if something gets me 90% of the way there I really appreciate it.

Sometimes I need to write quick scripts, wrangle CSVs, maybe parse JSON, maybe hack together something quick. ChatGPT is great but it can't run and test the code in my environment. It can't do multi-turn conversations with my own data model.

Here's an example of how I've automated my python scripting with 15 lines of code:

from phi.llm.openai import OpenAIChat
from phi.assistant.python import PythonAssistant
from phi.file.local.csv import CsvFile

llm = OpenAIChat(model="gpt-4-1106-preview")

python_engineer_w_files = PythonAssistant(
    llm=llm,
    files=[
        CsvFile(
            path="https://phidata-public.s3.amazonaws.com/demo_data/IMDB-Movie-Data.csv",
            description="Contains information about movies from IMDB.",
        )
    ],
    pip_install=True,
    show_function_calls=True,
)
python_engineer_w_files.print_response("What is the revenue per year?")

python_engineer = PythonAssistant(llm=llm, pip_install=True, show_function_calls=True)
python_engineer.print_response("Show me the top 5 hackernews stories")

Is this risky? Probably, is letting GPT4 pip install a good idea? most likely not.

Read more about the PythonAssistant here

Here's it in action:

Stay up to date

Get notified when I publish something new