Retrieving python code generated by assistant

Hi! i’m building an assistant that writes python scripts. what would be the best way to retrieve those scripts once the assistant is done writing them?
When using playground I asked the assistant to save the script as a .py file and his response was usually a file path to which this file was saved. would it be the same with the API? would it be possible in that case to use annotations to retrieve the file? Is there a better way to do this?

1 Like

You’ll have to convince the AI to output working annotation links to the file.

Reading images and files generated by Code Interpreter

Code Interpreter in the API also outputs files…

then use files endpoint on the file link.

You can also see now what was emitted in steps for what the AI wrote to perform a sandbox task.

1 Like

It will be interesting to learn to see if you are able to steer the GPT-4 API to output .py file consistently and allow download through files.

Worked quite well actually. I asked it to write a python file then save it. it did. Turns out giving it a specific name for the file also works and steers it even more strongly towards saving the file. Also gave it specific names for the functions it should write and that worked as well.