I was extracting customer details from onboarding messages. The result needed a name, an age, and a country code before it could be passed to the account service.
The schema looked strict enough:
const PersonJsonSchema = {
type: "object",
required: ["name", "age", "country"],
properties: {
name: { type: "string", minLength: 3 },
age: { type: "number", minimum: 18, maximum: 120 },
country: { type: "string", pattern: "^[A-Z]{2}$" },
},
};
Then a test message containing a 12-year-old came back as:
{ "name": "Jo", "age": 12, "country": "IN" }
It was valid JSON. It had every required field. Every field had the right basic type. It still should not have reached the account service.
My first fix was another instruction in the prompt
I added a sentence telling the model that age must be between 18 and 120, names must have at least three characters, and country codes must be two uppercase letters.
That improved the happy path. It did not give
Discussion
Leave the first comment
Be the first to leave a mark on this discussion.