I’m trying to create questions and multiple choice answers from text content using the OpenAI API in c#. I’m using a Tool to format the output but it keeps changing the json structure for the question and answers from something like:
"questions": [
[
"How does expressing gratitude and appreciation impact your well-being and life according to the content?",
"It makes you feel more energetic and fuller of life",
"It makes you more anxious",
"It has no effect on your well-being",
"It makes you feel tired and drained",
"It makes you feel more energetic and fuller of life. Being grateful and expressing gratitude leads to better self-care and a sense of well-being."
]
]
To something like this:
"questions": [
{
"question": "What is emphasized as a crucial factor in achieving elite athletic status according to the text?",
"answers": [
"Physical strength and agility",
"Envy and jealousy",
"Development of personal traits",
"Comparing oneself to others"
]
]
The tool definition is unchanged between runs and I'm using "QuestionGeneration" in my tool-choice:
var tool = new List<Tool>
{
new Function(
"QuestionGeneration",
"Generate a question from text",
new JsonObject
{
["type"] = "object",
["properties"] = new JsonObject
{
["questions"] = new JsonObject
{
["type"] = "array",
["description"] = "An array of each individual question",
["items"] = new JsonObject
{
["question"] = new JsonObject
{
["type"] = "string",
["description"] = "The question derived from the provided text"
},
["answers"] = new JsonObject
{
["type"] = "array",
["description"] = "An array of possible answers that could answer the question",
["items"] = new JsonObject
{
["name"] = "answers",
["type"] = "string",
["description"] = "One of the possible answers to the question."
}
},
["correctAnswer"] = new JsonObject
{
["type"] = "number",
["description"] = "the index number identifying which of the items in the answers array is correct"
},
["question_type_int"] = new JsonObject
{
["type"] = "string",
["description"] = "The type of question that was created.",
["enum"] = new JsonArray { "multiple choice", "true or false", "yes or no", "fill in the blank", "multiple selection", "numeric" }
},
["feedback"] = new JsonObject
{
["type"] = "string",
["description"] = "a statement telling why the answer was correct"
},
["competency"] = new JsonObject
{
["type"] = "string",
["description"] = "the category or summary of the type of question that was generated"
}
}
}
},
["required"] = new JsonArray { "questions", "question", "answers", "correctAnswer", "feedback" }
})
};
So, what is wrong with my tool definition and how can I fix it so it returns a consistent format?