Langertha/UsageRecord.pm

filter: Statementstmt 96.5% 28 / 29 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 1 totaltotal 91.4% 32 / 35 CC 1 SCAR 0.2
CC
1
Cov
97%
__ANON__
1.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Langertha/Engine/TranscriptionBase.pm ↑ Summary Langertha/Input.pm »
1 package Langertha::UsageRecord;
2 # ABSTRACT: Tagged ledger entry combining Usage, Cost, and request metadata
3 3 our $VERSION = '0.502';
4 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use Langertha::Usage;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Langertha::Cost;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 has usage => ( is => 'ro', isa => 'Langertha::Usage', required => 1 );
9 3 has cost => ( is => 'ro', isa => 'Langertha::Cost', required => 1 );
10  
11 3 has model => ( is => 'ro', isa => 'Maybe[Str]' );
12 3 has provider => ( is => 'ro', isa => 'Maybe[Str]' );
13 3 has engine => ( is => 'ro', isa => 'Maybe[Str]' );
14 3 has route => ( is => 'ro', isa => 'Maybe[Str]' );
15 3 has endpoint => ( is => 'ro', isa => 'Maybe[Str]' );
16  
17 3 has api_key_id => ( is => 'ro', isa => 'Maybe[Str]' );
18  
19 3 has tool_calls => ( is => 'ro', isa => 'Int', default => 0 );
20 0 ▶has tool_names => ( is => 'ro', isa => 'ArrayRef[Str]', default => sub { [] } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
21  
22 3 has duration_ms => ( is => 'ro', isa => 'Maybe[Num]' );
23 3 has started_at => ( is => 'ro', isa => 'Maybe[Num]' );
24 3 has finished_at => ( is => 'ro', isa => 'Maybe[Num]' );
25  
26 3 has pricing_version => ( is => 'ro', isa => 'Maybe[Str]' );
27  
28 sub to_hash {
29 3 ▶ my ($self) = @_;
Subroutine to_hash: called CC=1 SCAR=0.0
Pod undocumented
30 return {
31 3 provider => $self->provider,
32 engine => $self->engine,
33 model => $self->model,
34 route => $self->route,
35 endpoint => $self->endpoint,
36 api_key_id => $self->api_key_id,
37 duration_ms => $self->duration_ms,
38 started_at => $self->started_at,
39 finished_at => $self->finished_at,
40 input_tokens => $self->usage->input_tokens,
41 output_tokens => $self->usage->output_tokens,
42 total_tokens => $self->usage->total_tokens,
43 tool_calls => $self->tool_calls,
44 tool_names => $self->tool_names,
45 input_cost_usd => $self->cost->input_usd + 0,
46 output_cost_usd => $self->cost->output_usd + 0,
47 total_cost_usd => $self->cost->total_usd + 0,
48 currency => $self->cost->currency,
49 pricing_version => $self->pricing_version,
50 };
51 }
52  
53 3 __PACKAGE__->meta->make_immutable;
54 3 1;
55  
56 __END__
57  
58 =pod
59  
60 =encoding UTF-8
61  
62 =head1 NAME
63  
64 Langertha::UsageRecord - Tagged ledger entry combining Usage, Cost, and request metadata
65  
66 =head1 VERSION
67  
68 version 0.502
69  
70 =head1 SUPPORT
71  
72 =head2 Issues
73  
74 Please report bugs and feature requests on GitHub at
75 L<https://github.com/Getty/langertha/issues>.
76  
77 =head2 IRC
78  
79 Join C<#langertha> on C<irc.perl.org> or message Getty directly.
80  
81 =head1 CONTRIBUTING
82  
83 Contributions are welcome! Please fork the repository and submit a pull request.
84  
85 =head1 AUTHOR
86  
87 Torsten Raudssus <getty@cpan.org>
88  
89 =head1 COPYRIGHT AND LICENSE
90  
91 This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>.
92  
93 This is free software; you can redistribute it and/or modify it under
94 the same terms as the Perl 5 programming language system itself.
95  
96 =cut
« Langertha/Engine/TranscriptionBase.pm ↑ Summary Langertha/Input.pm »