openai-cookbook icon indicating copy to clipboard operation
openai-cookbook copied to clipboard

[SUPPORT] Generating exact json objects using the function/api calling feature

Open SupreethRao99 opened this issue 2 years ago • 0 comments
trafficstars

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. the keys of the json object are defined, the values are to be generated by GPT

    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, could the current examples be improved by giving examples on how to support such a use case.

Thank you

SupreethRao99 avatar Jun 15 '23 12:06 SupreethRao99