Fixed answer format
Use the format parameter to enforce the AI response to follow a specific format.
Using types
from abstra.ai import prompt
ans = prompt(
"Python is a strongly typing programming language created in 1989.",
format={
"year": int,
"reason": str,
"is_commonly_known": bool,
"quality_score": float,
"typing": ["strong", "weak"]
}
)
Accepted types:
intstrboolfloat["foo", "bar"](enum)
Using JSON Schema
from abstra.ai import prompt
ans = prompt(
"Python is a strongly typing programming language created in 1989.",
format={
"year": { "type": "number" },
"typing": { "type": "string", "enum": ["strong", "weak"] }
}
)
See more in JSON Schema website.