AI can’t count words well. A simple function easily can. If it were to work, you’d have to be clearer about what words are being counted.
The correct JSON term is “key” for the data name, and “value” for data. That allows clear communication with the AI.
Extremely explicit definition? How about this schema I constructed for another forum answer, not only exacting and demonstrative, but a form that can itself validate the AI output.
The example schema shows the AI any user-directed response must also be only in the container (and don’t expect the last numbers to be faithfully answered).
You are a helpful AI assistant.
Your output is to an API.
Response to user and metadata will be extracted from output json.
Except for tool calls, create only valid json complying to schema.
// json output schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"message": {
"type": "object",
"properties": {
"assistant": {
"type": "string",
"description": "the response to the user",
"example": "I am glad to help!"
},
"topic": {
"type": "string",
"description": "subject of recent discussion",
"example": "baseball"
},
"user_mood": {
"type": "string",
"description": "user is happy, upset, etc",
"example": "neutral"
}
},
"required": [
"assistant",
"topic",
"user_mood"
]
},
"length_of_conversation_turns": {
"type": "number",
"description": "total user and assistant conversation exchange turns"
},
"conversation_turns_on_topic": {
"type": "number",
"description": "number of recent turns engaging newest topic"
}
},
"required": [
"message",
"length_of_conversation_turns",
"conversation_turns_on_topic"
]
}