blib/lib/Langertha/Role/ContextSize.pm

filter: Statementstmt 80.0% 8 / 10 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod 100% 1 / 1 totaltotal 70.5% 12 / 17 CC 3 SCAR 14.2
CC
3
Cov
64%
get_context_size
5.2
BEGIN
1.0
CRAP 4.1
« blib/lib/Langertha/Engine/HuggingFace.pm ↑ Summary blib/lib/Langertha/Chat.pm »
1 package Langertha::Role::ContextSize;
2 # ABSTRACT: Role for an engine where you can specify the context size (in tokens)
3 54 our $VERSION = '0.503';
4 54 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 54 has context_size => (
7 isa => 'Int',
8 is => 'ro',
9 predicate => 'has_context_size',
10 );
11  
12  
13 2 ▶sub get_context_size {
Subroutine get_context_size: called CC=3 SCAR=16.5
Pod documented
14 2 my ( $self ) = @_;
15 2 ▶ return $self->context_size if $self->has_context_size;
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_context_size 2 0 2
16 0 ▶ return $self->default_context_size if $self->can('default_context_size');
Branch: 1 branch
BranchTrueFalseTotal
if $self->can("default_context_size") 0 0 0
17 0 return;
18 }
19  
20  
21  
22 54 1;
23  
24 __END__
25  
26 =pod
27  
28 =encoding UTF-8
29  
30 =head1 NAME
31  
32 Langertha::Role::ContextSize - Role for an engine where you can specify the context size (in tokens)
33  
34 =head1 VERSION
35  
36 version 0.503
37  
38 =head2 context_size
39  
40 The maximum context size in tokens to use for requests. Optional. When not set,
41 the engine uses its own C<default_context_size> if available, or omits the
42 parameter from the request.
43  
44 =head2 get_context_size
45  
46 my $size = $engine->get_context_size;
47  
48 Returns the effective context size: the explicit C<context_size> if set,
49 otherwise the engine's C<default_context_size>, otherwise C<undef>.
50  
51 =head1 SEE ALSO
52  
53 =over
54  
55 =item * L<Langertha::Role::ResponseSize> - Limit response token count
56  
57 =item * L<Langertha::Engine::Ollama> - Engine that composes this role
58  
59 =back
60  
61 =head1 SUPPORT
62  
63 =head2 Issues
64  
65 Please report bugs and feature requests on GitHub at
66 L<https://github.com/Getty/langertha/issues>.
67  
68 =head2 IRC
69  
70 Join C<#langertha> on C<irc.perl.org> or message Getty directly.
71  
72 =head1 CONTRIBUTING
73  
74 Contributions are welcome! Please fork the repository and submit a pull request.
75  
76 =head1 AUTHOR
77  
78 Torsten Raudssus <getty@cpan.org>
79  
80 =head1 COPYRIGHT AND LICENSE
81  
82 This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>.
83  
84 This is free software; you can redistribute it and/or modify it under
85 the same terms as the Perl 5 programming language system itself.
86  
87 =cut
« blib/lib/Langertha/Engine/HuggingFace.pm ↑ Summary blib/lib/Langertha/Chat.pm »