openai-cookbook
openai-cookbook copied to clipboard
[SUPPORT] Generating exact json objects using the function/api calling feature
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