blib/lib/Langertha/Engine/OpenAIBase.pm

filter: Statementstmt 95.6% 22 / 23 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 100% 1 / 1 totaltotal 93.5% 29 / 31 CC 1 SCAR 0.4
CC
1
Cov
96%
_build_openapi_operations
1.1
_build_openapi_operations
1.1
BEGIN
1.0
CRAP 1.0
« blib/lib/Langertha/Request/HTTP.pm ↑ Summary blib/lib/Langertha/UsageRecord.pm »
1 package Langertha::Engine::OpenAIBase;
2 # ABSTRACT: Base class for OpenAI-compatible engines
3 165 our $VERSION = '0.505';
4 165 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 165 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 165 ▶use Module::Runtime qw( use_module );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 165 extends 'Langertha::Engine::Remote';
9  
10 165 with map { 'Langertha::Role::'.$_ } qw(
11 OpenAICompatible
12 OpenAPI
13 Models
14 Temperature
15 ReasoningEffort
16 PromptCache
17 ResponseSize
18 SystemPrompt
19 ResponseFormat
20 Streaming
21 Chat
22 ImageInput
23 );
24  
25 1515 ▶sub _build_openapi_operations {
Subroutine _build_openapi_operations: called CC=1 SCAR=1.2
26 0 ▶ return use_module('Langertha::Spec::OpenAI')->data;
Subroutine _build_openapi_operations: not called CC=1 SCAR=1.2
27 }
28  
29 # The OpenAI family caches automatically — there is no request-side enable
30 # breakpoint, only the prompt_cache_key routing hint. Clear the Anthropic-style
31 # enable flag here so the whole family advertises only the key (ADR 0002).
32 # Partner direction: Langertha::Engine::AnthropicBase runs the symmetric
33 # correction and deletes prompt_cache_key, keeping prompt_cache. The pair is
34 # canon in L<ADR 0015|docs/adr/0015-role-composition-patterns.md>.
35 7069 ▶around engine_capabilities => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
36 7069 my ( $orig, $self, @rest ) = @_;
37 7069 my $caps = $self->$orig(@rest);
38 7069 delete $caps->{prompt_cache};
39 7069 return $caps;
40 165 };
41  
42  
43 # The tools + structured-output response_format conflict is a property of the
44 # serving STACK, not of the gpt-oss model: Groq and Cerebras enforce it
45 # stack-wide (each via its own model_capability_exclusions override), while
46 # AKI's gpt-oss-120b serves tools + a json_schema response_format at HTTP 200
47 # (live-verified 2026-09-19, karr #184). So it is NOT gated here on the shared
48 # OpenAI base — doing so was a false-positive on the AKIOpenAI / TSystems
49 # defaults and aggregator routes. This base composes no exclusion rule and
50 # inherits the Langertha::Role::Chat no-op; the per-model
51 # model_capability_exclusions seam stays and Groq/Cerebras carry the rule
52 # (ADR 0024).
53  
54 1 ▶sub default_model { croak "".(ref $_[0])." requires model to be set" }
Subroutine default_model: called CC=1 SCAR=0.0
Pod documented
55  
56  
57 165 __PACKAGE__->meta->make_immutable;
58  
59  
60 165 1;
61  
62 __END__
« blib/lib/Langertha/Request/HTTP.pm ↑ Summary blib/lib/Langertha/UsageRecord.pm »