What's wrong with the responseFormat parameter I a...
# ask-stanley-ai
a
What's wrong with the responseFormat parameter I am giving to the llm.generateText call? This is the responseFormat: { type: "object", required: ["items"], properties: { items: { type: "array", required: ["itemId", "itemDescription", "quantity", "rate", "estimatedamount"], properties: { itemId: {type: "string"}, itemDescription: {type: "string"}, quantity: {type: "float"}, rate: {type: "float"}, estimatedamount: {type: "float"}, } }, shippingAddress: { type: "object", required: ["addr1", "addr2", "city", "state", "zip", "country"], properties: { attention: {type: "string"}, addr1: {type: "string"}, addr2: {type: "string"}, addr3: {type: "string"}, city: {type: "string"}, state: {type: "string"}, zip: {type: "string"}, country: {type: "string"}, phone: {type: "string"} } }, subtotals: { type: "object", required: ["estimatedTax", "total"], properties: { itemsTotal: {type: "float"}, pretaxSubtotal: {type: "float"}, estimatedTax: {type: "float"}, total: {type: "float"}, savings: {type: "float"} } } } }
c
AI generated answer (using internal Slack threads):
Based on the provided JSON responseFormat, there are a few potential issues that could be causing problems with the llm.generateText call: 1. The
required
field in the
items
array and
shippingAddress
object is not valid. The
required
field is not valid inside an array or an object, it should be at the same level as
properties
. 2. The
type
for
quantity
,
rate
, and
estimatedamount
in the
items
array and for
itemsTotal
,
pretaxSubtotal
,
estimatedTax
,
total
, and
savings
in the
subtotals
object is set to
float
. However, JSON Schema does not support the
float
type. You should use
number
instead. 3. The
properties
field inside the
items
array is not valid. The
properties
field should be inside an object, not an array. Here is the corrected responseFormat:
Copy code
json
{
    "type": "object",
    "required": ["items"],
    "properties": {
        "items": {
            "type": "array",
            "items": {
                "type": "object",
                "required": ["itemId", "itemDescription", "quantity", "rate", "estimatedamount"],
                "properties": {
                    "itemId": {"type": "string"},
                    "itemDescription": {"type": "string"},
                    "quantity": {"type": "number"},
                    "rate": {"type": "number"},
                    "estimatedamount": {"type": "number"}
                }
            }
        },
        "shippingAddress": {
            "type": "object",
            "required": ["addr1", "addr2", "city", "state", "zip", "country"],
            "properties": {
                "attention": {"type": "string"},
                "addr1": {"type": "string"},
                "addr2": {"type": "string"},
                "addr3": {"type": "string"},
                "city": {"type": "string"},
                "state": {"type": "string"},
                "zip": {"type": "string"},
                "country": {"type": "string"},
                "phone": {"type": "string"}
            }
        },
        "subtotals": {
            "type": "object",
            "required": ["estimatedTax", "total"],
            "properties": {
                "itemsTotal": {"type": "number"},
                "pretaxSubtotal": {"type": "number"},
                "estimatedTax": {"type": "number"},
                "total": {"type": "number"},
                "savings": {"type": "number"}
            }
        }
    }
}
****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.823852599
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.811218321
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.807739377
Please provide your feedback on this answer.
Thank you for your feedback
a
That fixed it! It works perfectly now.