Langertha/Role/StaticModels.pm

filter: Statementstmt 100% 10 / 10 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod 100% 1 / 1 totaltotal 100% 15 / 15 CC 2 SCAR 5.1
CC
2
Cov
100%
list_models
2.0
BEGIN
1.0
CRAP 1.7
« Langertha/Stream.pm ↑ Summary Langertha/Engine/Groq.pm »
1 package Langertha::Role::StaticModels;
2 # ABSTRACT: Role for engines with a hardcoded model list
3 7 our $VERSION = '0.502';
4 7 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6  
7 7 has static_models => (
8 is => 'ro',
9 isa => 'ArrayRef[HashRef]',
10 lazy_build => 1,
11 );
12  
13  
14 sub list_models {
15 6 ▶ my ($self, %opts) = @_;
Subroutine list_models: called CC=2 SCAR=6.9
Pod documented
16 6 my $models = $self->static_models;
17 6 ▶ return $opts{full} ? $models : [map { $_->{id} } @$models];
Branch: 1 branch
BranchTrueFalseTotal
$opts{'full'} ? : 3 3 6
18 }
19  
20  
21  
22 7 1;
23  
24 __END__
25  
26 =pod
27  
28 =encoding UTF-8
29  
30 =head1 NAME
31  
32 Langertha::Role::StaticModels - Role for engines with a hardcoded model list
33  
34 =head1 VERSION
35  
36 version 0.502
37  
38 =head1 SYNOPSIS
39  
40 package My::Engine;
41 use Moose;
42  
43 extends 'Langertha::Engine::OpenAIBase';
44  
45 with 'Langertha::Role::StaticModels';
46  
47 sub _build_static_models {[
48 { id => 'model-a' },
49 { id => 'model-b' },
50 ]}
51  
52 __PACKAGE__->meta->make_immutable;
53  
54 =head1 DESCRIPTION
55  
56 Provides a C<list_models> implementation that returns a hardcoded model
57 list without making any HTTP requests. Useful for engines whose API does
58 not offer a C</models> endpoint (e.g. MiniMax).
59  
60 The consuming class must implement C<_build_static_models> returning an
61 ArrayRef of HashRefs, each with at least an C<id> key.
62  
63 =head2 static_models
64  
65 ArrayRef of model HashRefs (each with at least an C<id> key). Built by
66 C<_build_static_models> which the consuming engine must implement.
67  
68 =head2 list_models
69  
70 my $ids = $engine->list_models;
71 my $full = $engine->list_models(full => 1);
72  
73 Returns the static model list. By default returns an ArrayRef of model
74 ID strings. Pass C<full =E<gt> 1> for the full model HashRefs.
75  
76 =head1 SEE ALSO
77  
78 =over
79  
80 =item * L<Langertha::Role::Models> - Model selection and caching
81  
82 =item * L<Langertha::Engine::MiniMax> - Uses this role
83  
84 =back
85  
86 =head1 SUPPORT
87  
88 =head2 Issues
89  
90 Please report bugs and feature requests on GitHub at
91 L<https://github.com/Getty/langertha/issues>.
92  
93 =head2 IRC
94  
95 Join C<#langertha> on C<irc.perl.org> or message Getty directly.
96  
97 =head1 CONTRIBUTING
98  
99 Contributions are welcome! Please fork the repository and submit a pull request.
100  
101 =head1 AUTHOR
102  
103 Torsten Raudssus <getty@cpan.org>
104  
105 =head1 COPYRIGHT AND LICENSE
106  
107 This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>.
108  
109 This is free software; you can redistribute it and/or modify it under
110 the same terms as the Perl 5 programming language system itself.
111  
112 =cut
« Langertha/Stream.pm ↑ Summary Langertha/Engine/Groq.pm »