Structured outputs ensure LLM responses follow specific formats, making them easier to use in your applications. For more advanced structured data requirements, you may also want to check out our Tool Calling documentation.
Variables must be in quotes, except for enum variables:
Jinja2
Copy
Ask AI
{ "type": "object", "properties": { "sentiment": { "type": "string", "enum": {name: "sentiment_options", type: "enum_variable"}, "description": "The sentiment of the {{ content_type }}" }, "topics": { "type": "array", "items": { "type": "string" }, "description": "List of topics mentioned in the {{ document_type }}" } }}
When running the prompt, provide your variables:
Copy
Ask AI
response = pl.run( prompt_name="content_analyzer", input_variables={ "text": "I really enjoyed the new restaurant downtown. The food was amazing and the service was excellent.", "sentiment_options": ["positive", "neutral", "negative"], "document_type": "review", "content_type": "customer feedback" },)