File size: 2,339 Bytes
5c6d744
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""English customer-support examples using the official TypeSafe Python SDK."""

import argparse
import os

from typesafe_sdk import Choice, Noul, RetryPolicy, Score, TypeSafeClient


def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--base-url", default="http://127.0.0.1:30013")
    parser.add_argument("--model", default="APUS-OpenJev-v1-9B")
    parser.add_argument("--effort", choices=["low", "high"], default="high")
    args = parser.parse_args()
    with TypeSafeClient(
        base_url=args.base_url,
        api_key=os.environ["JEV_API_KEY"],
        model=args.model,
        retry=RetryPolicy(max_retries=0),
    ) as client:
        print(client.models.list().model_dump_json(indent=2))
        result = client.system_one(
            state={
                "customer_message": "My order arrived damaged yesterday. I would like a refund.",
                "policy": "A damaged item reported within 30 days is eligible for a refund.",
            },
            questions={
                "support_queue": Choice(
                    instructions="Choose the team that should handle this ticket.",
                    criteria={
                        "returns": "Damaged items, returns, and refunds",
                        "billing": "Invoice or payment issues",
                        "shipping": "Tracking and delivery updates",
                    },
                ),
                "refund_eligible": Noul(
                    instructions="Does the stated policy make this customer eligible for a refund?"
                ),
                "urgency": Score(
                    instructions="Rate the urgency of this support ticket.",
                    criteria=[
                        "Routine question",
                        "Customer needs timely assistance",
                        "Immediate safety or security risk",
                    ],
                ),
            },
            extra_body={"effort": args.effort},
        )
        print(result.model_dump_json(indent=2))
        print("Effort:", result.raw_http_response.headers.get("x-openjev-effort"))
        print(
            "Configured execution layers:",
            result.raw_http_response.headers.get("x-openjev-executed-layers"),
        )


if __name__ == "__main__":
    main()