Hi Nikita,
I saw a similar issue before and successfully addressed it by adding a concrete example output to my prompt (the API already repeats the JSON Schema [unless you
explicitly omit this]).
JSON Schema:
{
"type": "object",
"properties": {
"hashtags": {
"type": "array",
"maxItems": 3,
"items": {
"type": "string",
"pattern": "^#[^\\s#]+$"
}
}
},
"required": ["hashtags"],
"additionalProperties": false
}
Example output:
{
"hashtags": [
"#pottery",
"#dyi"
]
}
My prompt:
const result = await session.prompt(
`Suggest hashtags for this post:
${post}
Example response:
{
"hashtags": [
"#pottery",
"#dyi"
]
}`,
{
responseConstraint: schema,
}
);