Structured Output
Learn how to query resources using the Wetrocloud API
Structured Output Response
Structured output is a feature that allows large language models (LLMs) to generate responses in a specific format with your resources. Structured output is best for extracting structured data to fit your application’s needs. It returns data formatted with the json_schema
and json_schema_rules
you provide.
To use the structured output feature you need to provide the following parameters:
Parameter | Type | Description |
---|---|---|
collection_id | String | The unique ID of the collection to query. |
request_query | String | The search term or query text. |
json_schema | String | The desired structure for the JSON response. |
json_schema_rules | String | Custom rules to guide the response’s adherence to the specified JSON schema. |
json_schema
The json_schema
parameter defines the structure of the response you want the system to return. This parameter helps ensure the output matches your application’s requirements.
Example JSON Schema
Example JSON Schema (List)
If you want a list of items and not just a single item, you can specify the json schema by putting the entire object in a list
json_schema_rules
The json_schema_rules
parameter allows you to define custom rules for how the schema is applied. Another way to think about this is that it is a set of instructions for the LLM to follow when generating the response. This can also be in form of a more detailed prompt This can include constraints on the data, additional formatting, or validation logic.
Example Requests
Example Response
Field | Description |
---|---|
response | JSON object structured as per the provided schema. |
tokens | Number of tokens used for processing. |
success | Indicates whether the query was successful. |