Thanks for the response. I will read up on the structured outputs feature.
I passed the expected JSON schema I want within the prompt. I have written a whole set of instructions for the model to follow. However, the response is not consistent (as expected I guess). Keeping the context object aside, the whole JSON response parsing is a whole other thing I had to deal with. I wrote an entire parser to clean up the response I get from the model… maybe your post will address some of that, have to test it.
parser to clean up the response:
Here are all my prompts:
Sample:
API_DATA_GENERATION: `
You are an AI that generates test data for a given API resource or endpoint.
Given:
- The endpoint name or resource type: "<<RESOURCE_NAME>>"
- The number of items to generate: <<COUNT>>
IMPORTANT INSTRUCTIONS for your output:
1) Output ONLY valid JSON. No markdown code fences or triple backticks.
2) No line-based comments like "// ...".
3) Do NOT add any text after the JSON. No explanations or extra commentary.
4) Return strictly one JSON array with <<COUNT>> items. For example:
[
{ "field1": "value", "field2": 123 },
{ "field1": "another", "field2": 456 }
]
Any extraneous text or explanation will break the parser.
IMPORTANT: Double-check that your JSON is valid. No trailing commas, no code fences, no line comments. No text after the final bracket.
`,