You wouldn't need to, that's the point here. You let the LLM work on generating semantically valid responses and use a tool like this to restrict it to syntactically correct ones.
Here's an example jsonschema (a bit handwritten so maybe some errors but it should be clear enough). Let the LLM deal with coming up with a name and backstory that work, making sure the description and type of the weapon make sense (gpt4 suggested a close range carrot dagger for example), and let this work as your type structure.
{
"type": "object",
"title": "character",
"properties": {
"backstory": {
"type": "string"
},
"weapons": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"weapon_type": {
"type": "string",
"enum": ["ranged", "close", "magic"]
},
"range": {
"minimum": 0,
"maximum": 150
},
"damage": {
"type": "number"
}
},
"required": [
"name",
"description",
"range",
"damage"
]
}
},
"name": {
"type": "string"
}
},
"required": [
"backstory",
"weapons",
"name"
]
}
> Then what? What do you mean by "random string"?Nonsense. Like "Colorless green ideas sleep furiously" the famous sentence that's grammatically correct but utter nonsense.
> Plus, if you already have the grammar that can cover the anthropomorphic vegetable world it's only a bit more work to use it to parse such natural language requests, anyway.
I really do not think this is the case. Parsing and understanding arbitrary requests about something like this?