-
-
Notifications
You must be signed in to change notification settings - Fork 150
Agents JSON format
When creating agents, you can specify a JSON format that models are asked to comply to in their response. Note that models do so with more or less success: while OpenAI has a formal way to specify a JSON format, Anthropic does not. In that case, Witsy will automatically add specific instructions to try to get the model to comply.
Witsy supports a simplified way to describe a JSON format although you can also paste a more formal JSON specification.
Let's analyze an example to understand the simple syntax:
{
"name": "string",
"age": "number",
"address": [ "string" ],
"contact": {
"emergency": "boolean",
"name": "string",
"phone": "string"
}
}As you can the simple syntax supports string, number and boolean. Objects can be nested (like contact) or in lists (address).
Note that in the case of Anthropic, this exact text will be sent to the model. In that case Anthropic will often output numbers as "age": "30" instead of "age": 30. To do so, you can substitute "number" and "boolean" with a dummy value (30 and false). Most of the time this will get Anthropic models to behave properly.
You can also paste a form JSON schema such as:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"name": {
"type": "string",
"minLength": 2,
"maxLength": 50
},
"age": {
"type": "integer",
"minimum": 0,
"maximum": 120
},
"email": {
"type": "string",
"pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true,
"minItems": 1,
"maxItems": 10,
"contains": {
"enum": [
"user",
"admin",
"guest"
]
}
},
"coordinates": {
"type": "array",
"prefixItems": [
{
"type": "number",
"minimum": -90,
"maximum": 90
},
{
"type": "number",
"minimum": -180,
"maximum": 180
}
],
"items": false
},
"score": {
"type": "number",
"multipleOf": 0.5,
"minimum": 0,
"maximum": 100
}
},
"required": [
"name",
"email"
],
"additionalProperties": false,
"minProperties": 2,
"maxProperties": 10
}Note that Witsy will not support extended attributes such as minimum, maximum and so forth.