Generating exact JSON objects using the the function call feature

Hello,

I’ve been trying to generate an exact JSON schema using the new gpt-4-0613 checkpoint using the function calling feature. I have a function that saves the generated json object to a file as follows

    def form_hierarchy(top_level_element:str, follow_up_elements:List[str]):
        hierarchy = {
            "(top_level_element": top_level_element,
            "follow_up_elements": follow_up_elements
        }
        with open(file_name, "w") as f:  
             json.dump(hierarchy, f)

I want the model to use this function and save the outputs to a file, the current examples and the cookbook examples are confusing at best. some clarity would really be helpful

Thank You!