TypeSafe.pm

filter: Statementstmt 100% 29 / 29 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 0.0% 0 / 5 totaltotal 89.1% 41 / 46 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« TypeSafe/Models.pm ↑ Summary
1 package WebService::TypeSafe;
2  
3 3 ▶use 5.020;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use WebService::TypeSafe::Client ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use WebService::TypeSafe::Question ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use WebService::TypeSafe::RetryPolicy ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 our $VERSION = '0.01';
12 3 our @EXPORT_OK = qw(choice noul score retry_policy);
13  
14 5 ▶sub new { shift; return WebService::TypeSafe::Client->new(@_) }
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
15 3 ▶sub choice { return WebService::TypeSafe::Question::Choice->new(@_) }
Subroutine choice: called CC=1 SCAR=0.0
Pod undocumented
16 6 ▶sub noul { return WebService::TypeSafe::Question::Noul->new(@_) }
Subroutine noul: called CC=1 SCAR=0.0
Pod undocumented
17 2 ▶sub score { return WebService::TypeSafe::Question::Score->new(@_) }
Subroutine score: called CC=1 SCAR=0.0
Pod undocumented
18 5 ▶sub retry_policy { return WebService::TypeSafe::RetryPolicy->new(@_) }
Subroutine retry_policy: called CC=1 SCAR=0.0
Pod undocumented
19  
20 3 1;
21  
22 =head1 NAME
23  
24 WebService::TypeSafe - Perl client for TypeSafe AI's System One (Jev) API
25  
26 =head1 SYNOPSIS
27  
28 use WebService::TypeSafe qw(choice noul score);
29  
30 my $client = WebService::TypeSafe->new(
31 api_key => $api_key,
32 );
33 my $result = $client->system_one(
34 state => { message => 'My payment failed. Please help now.' },
35 questions => {
36 urgent => noul(
37 instructions => 'Does `message` convey urgency?',
38 ),
39 department => choice(
40 instructions => 'Which team should handle `message`?',
41 criteria => {
42 billing => 'Payments, invoices, or refunds',
43 technical => 'Bugs, outages, or integrations',
44 other => undef,
45 },
46 ),
47 frustration => score(
48 instructions => 'How frustrated is the customer?',
49 criteria => ['Calm', 'Concerned', 'Very angry'],
50 ),
51 },
52 );
53  
54 say $result->answers->{urgent}->noul;
55 say $result->choices->{department}->choice;
56  
57 =head1 DESCRIPTION
58  
59 This module provides an idiomatic synchronous Perl interface matching the
60 official TypeSafe Python and JavaScript SDKs: typed question constructors,
61 typed response objects, model listing, retries, environment configuration,
62 and structured exceptions.
63  
64 =head1 CONFIGURATION
65  
66 Pass the API key explicitly when constructing the client:
67  
68 my $client = WebService::TypeSafe->new(
69 api_key => $api_key,
70 );
71  
72 The value can come from your application's configuration or secret manager.
73 Do not hard-code or commit the actual key.
74  
75 If C<api_key> is omitted, the client optionally falls back to
76 C<TYPESAFE_API_KEY>:
77  
78 my $client = WebService::TypeSafe->new;
79  
80 Explicit constructor values take precedence over environment variables.
81  
82 =over 4
83  
84 =item * C<api_key> constructor option (primary API)
85  
86 =item * C<TYPESAFE_API_KEY> (optional fallback when C<api_key> is omitted)
87  
88 =item * C<TYPESAFE_DEFAULT_MODEL> (defaults to C<jev-latest>)
89  
90 =item * C<TYPESAFE_BASE_URL> (defaults to C<https://api.typesafe.ai>)
91  
92 =back
93  
94 =head1 AUTHOR
95  
96 Provided by Data Sculpting Inc.
97  
98 Email: C<info@datasculpting.com>
99  
100 Website: L<https://datasculpting.com/>
101  
102 =head1 LICENSE
103  
104 Copyright (c) 2026 Data Sculpting Inc.
105  
106 This library is released under the MIT License.
107  
108 =cut
« TypeSafe/Models.pm ↑ Summary