Bearprompt logo Bearprompt
Back to Jev
jev-latest Noul
How to run jev-latest

Point questions at fields in state

Description

TypeSafe’s structured-state example: two Nouls that name paths with backticks.

Copy

from typesafe_sdk import Choice, Noul, Score, TypeSafeClient

with TypeSafeClient(model="jev-latest") as client:
    result = client.system_one(
        state={
    "ticket": {
        "subject": "Duplicate charge",
        "messages": [
            {
                "from": "customer",
                "text": "I was charged twice for order A-104. Please refund the duplicate."
            },
            {
                "from": "support",
                "text": "We are checking the charges."
            }
        ]
    },
    "order": {
        "id": "A-104",
        "charges": [
            {
                "amount_usd": 49,
                "status": "captured"
            },
            {
                "amount_usd": 49,
                "status": "captured"
            }
        ]
    },
    "refund_policy": "Duplicate charges are eligible for a refund."
},
        questions={
            "refund_requested": Noul(
                instructions="Does `ticket.messages[0].text` request a refund?",
            ),
            "policy_supports_refund": Noul(
                instructions="Does `refund_policy` support the refund requested in `ticket.messages[0].text`, given `order.charges`?",
            )
        },
    )

Worked example

Illustrative for this sample state, not a live run

Sample state

{
  "ticket": {
    "subject": "Duplicate charge",
    "messages": [
      {
        "from": "customer",
        "text": "I was charged twice for order A-104. Please refund the duplicate."
      },
      {
        "from": "support",
        "text": "We are checking the charges."
      }
    ]
  },
  "order": {
    "id": "A-104",
    "charges": [
      {
        "amount_usd": 49,
        "status": "captured"
      },
      {
        "amount_usd": 49,
        "status": "captured"
      }
    ]
  },
  "refund_policy": "Duplicate charges are eligible for a refund."
}
Noul refund_requested

Does `ticket.messages[0].text` request a refund?

The vendor docs do not publish a sample answer for this question.

Noul policy_supports_refund

Does `refund_policy` support the refund requested in `ticket.messages[0].text`, given `order.charges`?

The vendor docs do not publish a sample answer for this question.

What you might do next

Name the part of state each question should judge with a dotted path in backticks.

Tags

noulpolicy
Loading...