A CLI to convert Python functions to OpenAI Assistant Tool Specs

A simple CLI script that reads your current directory, and generates a OpenAI accepted JSON based on your function definitions:

5 Likes

Fun idea - I think it could be even better if it (also?) worked on comment code (like the standard “parameters” format because for the LLM to best understand the use of the functions and the parameters the more description there is in the parameters and function description the better.

Oh like taking comments from the function into account? Or like the PyDoc for a function? That could be a good idea, but youd need some way to read the AST and determine which comments should automatically append to the description. I’m not sure if Python’s built in inspect module can do that

I have written a similar introspection code: GitHub - zby/ToolDefGenerator: Generates a structure suitable for the tools argument in a client.chat.completions.create call - but I think everyone uses pydantic for that - so I switched to writing something similar but with pedantic (the technical solution is to use functions with one parameter which is a pydantic class). With pydantic you can have nested structures - that is quite powerful.