blib/lib/Langertha/Engine/AnthropicBase.pm

filter: Statementstmt 100% 24 / 24 Branchbran 100% 4 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 94.8% 37 / 39 CC 4 SCAR 6.9
CC
4
Cov
97%
__ANON__
3.0
__ANON__
2.0
BEGIN
1.0
CRAP 2.0
« blib/lib/Langertha/Spec/OpenAI.pm ↑ Summary blib/lib/Langertha/Role/Models.pm »
1 package Langertha::Engine::AnthropicBase;
2 # ABSTRACT: Base class for Anthropic-compatible engines
3 68 our $VERSION = '0.505';
4 68 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 68 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 68 extends 'Langertha::Engine::Remote';
8  
9 68 with 'Langertha::Role::Models',
10 # Role::Chat::content_format defaults to 'openai'; AnthropicCompatible (composed last) supplies 'anthropic'.
11 'Langertha::Role::Chat' => { -excludes => ['content_format'] },
12 'Langertha::Role::Temperature',
13 # Role::ReasoningEffort::_build_reasoning_wire_format defaults to 'openai'; AnthropicCompatible supplies 'anthropic'.
14 'Langertha::Role::ReasoningEffort' => { -excludes => ['_build_reasoning_wire_format'] },
15 # Role::PromptCache::_build_cache_wire_format defaults to 'openai'; AnthropicCompatible supplies 'anthropic'.
16 'Langertha::Role::PromptCache' => { -excludes => ['_build_cache_wire_format'] },
17 'Langertha::Role::ResponseSize',
18 'Langertha::Role::SystemPrompt',
19 'Langertha::Role::ResponseFormat',
20 'Langertha::Role::Streaming',
21 'Langertha::Role::ImageInput',
22 'Langertha::Role::ToolResultImages',
23 'Langertha::Role::ToolResultPDF',
24 # Role::Tools::_build_tool_wire_format defaults to 'openai'; AnthropicCompatible supplies 'anthropic'.
25 'Langertha::Role::Tools' => { -excludes => ['_build_tool_wire_format'] },
26 'Langertha::Role::AnthropicCompatible';
27  
28 # The Anthropic family has the cache_control enable breakpoint but no OpenAI-style
29 # routing key. Clear the key flag so only the enable flag is advertised (ADR 0002).
30 # Partner direction: Langertha::Engine::OpenAIBase runs the symmetric
31 # correction and deletes prompt_cache, keeping prompt_cache_key. The pair is
32 # canon in L<ADR 0015|docs/adr/0015-role-composition-patterns.md>.
33 1582 ▶around engine_capabilities => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
34 1582 my ( $orig, $self, @rest ) = @_;
35 1582 my $caps = $self->$orig(@rest);
36 1582 delete $caps->{prompt_cache_key};
37 # tool_result_pdf (ADR 0039, k380): the PDF document block in a tool_result
38 # rides exactly where the endpoint takes Anthropic's source blocks there
39 # (k364), so the flag derives from that predicate and cannot disagree with
40 # what format_tool_results sends. Not image_input-gated: the dialect reads
41 # a PDF's text without vision (k371).
42 1582 ▶ delete $caps->{tool_result_pdf} unless $self->_tool_result_source_blocks_on_wire;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_tool_result_source_blocks_on_wire 834 748 1582
43 1582 return $caps;
44 68 };
45  
46 # Back-compat: the documented `effort => 'high'` constructor keeps working as an
47 # alias of the new normalized `reasoning_effort`. Both attributes stay readable;
48 # only the wire placement changed (top-level `effort` -> output_config.effort +
49 # thinking:{type:adaptive}, via Langertha::Reasoning).
50 658 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
51 658 my ( $orig, $class, @args ) = @_;
52 658 my $args = $class->$orig(@args);
53 656 ▶ if ( exists $args->{effort} && !exists $args->{reasoning_effort} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{"effort"} and not exists $args->{"reasoning_effort"}) 8 648 656
Condition66%2/3
exists $args->{"effort"} and not exists $args->{"reasoning_effort"}
!ll&&!rl&&r
64808
MC/DC50%1/2
exists $args->{"effort"} and not exists $args->{"reasoning_effort"}
exists $args->{"effort"} not exists $args->{"reasoning_effort"}
Truth table66%2/3
A and not(B)
A= exists $args->{"effort"}B= not exists $args->{"reasoning_effort"}
ABresult
0X0
100
111
54 8 $args->{reasoning_effort} = $args->{effort};
55 }
56 656 return $args;
57 68 };
58  
59  
60 1 ▶sub default_model { croak "".(ref $_[0])." requires model to be set" }
Subroutine default_model: called CC=1 SCAR=0.0
Pod documented
61  
62  
63 68 __PACKAGE__->meta->make_immutable;
64  
65  
66 68 1;
67  
68 __END__
« blib/lib/Langertha/Spec/OpenAI.pm ↑ Summary blib/lib/Langertha/Role/Models.pm »