How to build TEST/QUIZ app integration

Hi I have question. Maybe someone will be able to help configure the API or suggest how the API query should look like. I own an application for solving tests from different professions, dental hygienists, assistants, technicians etc.

I would like to build a feature in my app where I provide the text of an article or book and based on the text openai (or other model) builds me 5 closed questions that have 4 answers of which one is correct. Output should be in JSON.

Does anyone know how such an integration with the API should look like?

Here is a sample prompt you can use in the playground, just changed the texts written under the topic:

You are a quiz master.

Based on the topic written below, write 5 questions and generate 4 choices and indicate the correct answer. Output must be in JSON format using the schema provided.

# Topic
The Higgs boson, sometimes called the Higgs particle,[9][10] is an elementary particle in the Standard Model of particle physics produced by the quantum excitation of the Higgs field,[11][12] one of the fields in particle physics theory.[12] In the Standard Model, the Higgs particle is a massive scalar boson with zero spin, even (positive) parity, no electric charge, and no colour charge that couples to (interacts with) mass.[13] It is also very unstable, decaying into other particles almost immediately upon generation.

The Higgs field is a scalar field with two neutral and two electrically charged components that form a complex doublet of the weak isospin SU(2) symmetry. Its "Sombrero potential" leads it to take a nonzero value everywhere (including otherwise empty space), which breaks the weak isospin symmetry of the electroweak interaction and, via the Higgs mechanism, gives a rest mass to all massive elementary particles of the Standard Model, including the Higgs boson itself.

Both the field and the boson are named after physicist Peter Higgs, who in 1964, along with five other scientists in three teams, proposed the Higgs mechanism, a way for some particles to acquire mass. (All fundamental particles known at the time[c] should be massless at very high energies, but fully explaining how some particles gain mass at lower energies had been extremely difficult.) If these ideas were correct, a particle known as a scalar boson should also exist (with certain properties). This particle was called the Higgs boson and could be used to test whether the Higgs field was the correct explanation.

# JSON schema
{
        "questions": {
          "type": "array",
          "items": {
			"type": "object",
            "properties": {
              "question": {
                "description": "The question"
              },
              "choices": {
                "type": "array",
                "description": "Multiple-choices",
                "items": {
                   "type": "string"
                }
              },
              "answer": {
                  "type": "integer",
                  "description": "Index of correct answer from choices"
              }
            },
}
        }
}

Sample output:

{
	"questions": [
		{
			"question": "Who is the physicist after whom the Higgs field and the Higgs boson are named?",
			"choices": ["Albert Einstein", "Peter Higgs", "Marie Curie", "Isaac Newton"],
			"answer": 1
		},
		{
			"question": "What is the spin of the Higgs boson?",
			"choices": ["1/2", "1", "0", "2"],
			"answer": 2
		},
		{
			"question": "What interaction does the Higgs particle couple to?",
			"choices": ["Electric charge", "Momentum", "Mass", "Colour charge"],
			"answer": 2
		},
		{
			"question": "In the Standard Model, the Higgs field leads to the breaking of which symmetry?",
			"choices": ["Weak isospin symmetry", "Lorentz symmetry", "Electromagnetic symmetry", "Parity symmetry"],
			"answer": 0
		},
		{
			"question": "When was the Higgs mechanism proposed by Peter Higgs and other scientists?",
			"choices": ["1932", "1955", "1964", "1978"],
			"answer": 2
		}
	]
}
1 Like