What if you added a type annotation to filename as Path?
But GPT4 doesn't run on my laptop using ~4GB of RAM.