blib/lib/Langertha/Engine/Anthropic.pm

filter: Statementstmt 88.2% 15 / 17 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 85.7% 6 / 7 Podpod 50.0% 1 / 2 totaltotal 75.8% 22 / 29 CC 2 SCAR 8.1
CC
2
Cov
79%
_build_api_key
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
« blib/lib/Langertha/Role/CachedContent.pm ↑ Summary blib/lib/Langertha/Plugin.pm »
1 package Langertha::Engine::Anthropic;
2 # ABSTRACT: Anthropic API
3 60 our $VERSION = '0.505';
4 60 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 60 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 60 extends 'Langertha::Engine::AnthropicBase';
8  
9  
10 has '+url' => (
11 lazy => 1,
12 110 ▶ default => sub { 'https://api.anthropic.com' },
Subroutine __ANON__: called CC=1 SCAR=0.0
13 60 );
14  
15 0 ▶sub _build_api_key {
Subroutine _build_api_key: not called CC=2 SCAR=17.9
16 0 my ( $self ) = @_;
17 return $ENV{LANGERTHA_ANTHROPIC_API_KEY}
18 0 ▶ || croak "".(ref $self)." requires LANGERTHA_ANTHROPIC_API_KEY or api_key set";
Condition0%0/2
$ENV{'LANGERTHA_ANTHROPIC_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_ANTHROPIC_API_KEY or api_key set')
l!l
00
MC/DC0%0/1
$ENV{'LANGERTHA_ANTHROPIC_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_ANTHROPIC_API_KEY or api_key set')
$ENV{'LANGERTHA_ANTHROPIC_API_KEY'}
Truth table0%0/2
A
A= $ENV{'LANGERTHA_ANTHROPIC_API_KEY'}
Aresult
11
00
19 }
20  
21 25 ▶sub default_model { 'claude-sonnet-5' }
Subroutine default_model: called CC=1 SCAR=0.0
Pod documented
22  
23 # The first-party Claude Messages API has native structured output
24 # (output_config.format, GA — ADR 0005 amendment), so response_format is emitted
25 # natively here rather than through the legacy synthesized-tool rewrite that the
26 # /anthropic shim engines still use.
27 216 ▶sub _native_structured_output { 1 }
Subroutine _native_structured_output: called CC=1 SCAR=0.0
28  
29 # Per-model wire corrections (k138 / ADR 0002 amendment). The tool /
30 # structured-output / sampling wire reality on the Claude API is per-MODEL, not
31 # per-engine, so it lives here rather than in `around engine_capabilities`.
32 581 ▶sub model_capability_corrections {
Subroutine model_capability_corrections: called CC=1 SCAR=0.0
Pod undocumented
33 return (
34 # k135 point 1: temperature / top_p / top_k are deprecated on the Messages
35 # API and return a 400 with a non-default value on a GROWING set of models.
36 # The ticket named Opus 4.7/4.8; the verified set (Anthropic thinking/effort
37 # reference, read 2026-09) is broader — every model below rejects them,
38 # while Opus 4.6 / Sonnet 4.6 / Haiku 4.5 and older still accept them.
39 # Clearing the capability makes AnthropicCompatible drop temperature from
40 # the wire for these models (attribute or per-request alike).
41 581 qr/\Aclaude-opus-4-7/ => { temperature => 0 },
42 qr/\Aclaude-opus-4-8/ => { temperature => 0 },
43 qr/\Aclaude-opus-5/ => { temperature => 0 },
44 qr/\Aclaude-sonnet-5/ => { temperature => 0 },
45 qr/\Aclaude-fable-5/ => { temperature => 0 }, # fable-5 and fable-5-1
46 qr/\Aclaude-mythos-5/ => { temperature => 0 }, # mythos-5 and mythos-5-1
47 # k133 point 2: forced tool use (tool_choice type `any` / `tool`) returns a
48 # 400 on Fable 5.1 and Mythos 5.1 only (their 5.0 siblings still allow it).
49 # Clearing the forced-tool caps makes chat_f's auto-rewrite (ADR 0005) route
50 # a forced named tool through native structured output (output_config.format)
51 # instead of emitting a tool_choice the model rejects. tool_choice_auto /
52 # tool_choice_none stay — only `any` and `tool` 400.
53 qr/\Aclaude-fable-5-1/ => { tool_choice_named => 0, tool_choice_any => 0 },
54 qr/\Aclaude-mythos-5-1/ => { tool_choice_named => 0, tool_choice_any => 0 },
55 # image_input (k266, ADR 0019 k266 Update): every Claude 3+ model on the
56 # first-party Messages API takes image blocks (llm-advisor, docs only,
57 # 2026-09-25), so the family keeps the role-derived flag; only the
58 # text-only pre-3 generation clears it.
59 qr/\Aclaude-(?:2|instant)/ => { image_input => 0 },
60 );
61 }
62  
63 60 __PACKAGE__->meta->make_immutable;
64  
65  
66 60 1;
67  
68 __END__
« blib/lib/Langertha/Role/CachedContent.pm ↑ Summary blib/lib/Langertha/Plugin.pm »