| 1 | package Langertha::Engine::AKIOpenAI; | ||||||||||||
| 2 | # ABSTRACT: AKI.IO via OpenAI-compatible API | ||||||||||||
| 3 | 17 | our $VERSION = '0.505'; | |||||||||||
| 4 | 17 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 17 | ▶ | use Carp qw( croak ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 17 | extends 'Langertha::Engine::OpenAIBase'; | |||||||||||
| 8 | |||||||||||||
| 9 | # Native OpenAI tool calling, live-verified 2026-09-01 against | ||||||||||||
| 10 | # /openai/v1/chat/completions: a native `tools` array is accepted and answered | ||||||||||||
| 11 | # with a native `tool_calls` block, arguments intact — verified on | ||||||||||||
| 12 | # llama3-chat-8b, one model AKI's own table rates only "Basic Support". | ||||||||||||
| 13 | # So no Role::HermesTools and no tool_wire_format override: the `openai` default | ||||||||||||
| 14 | # of Langertha::Role::Tools is the wire reality. -- karr k102 | ||||||||||||
| 15 | 17 | with 'Langertha::Role::Tools'; | |||||||||||
| 16 | |||||||||||||
| 17 | # AKI.IO ships the model's chain-of-thought under the bare `reasoning` key on | ||||||||||||
| 18 | # the OpenAI-compatible message. That spelling is now read by the shared | ||||||||||||
| 19 | # Role::OpenAICompatible::chat_response (reasoning_content, else bare | ||||||||||||
| 20 | # `reasoning`), so no AKI-scoped lift is needed here. -- karr k127, k129 | ||||||||||||
| 21 | |||||||||||||
| 22 | |||||||||||||
| 23 | # AKI.IO's OpenAI-compatibility docs are internally inconsistent about the base | ||||||||||||
| 24 | # path: prose mentions /v1, but every working example (curl, Python SDK, | ||||||||||||
| 25 | # machine-readable config, /models discovery) uses /openai/v1. We follow the | ||||||||||||
| 26 | # working examples. See https://aki.io/docs/compatibility/openai-api-compatibility/ | ||||||||||||
| 27 | has '+url' => ( | ||||||||||||
| 28 | lazy => 1, | ||||||||||||
| 29 | 6 | ▶ | default => sub { 'https://aki.io/openai/v1' }, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 30 | 17 | ); | |||||||||||
| 31 | |||||||||||||
| 32 | 1 | ▶ | sub _build_api_key { | ||||||||||
|
Subroutine
_build_api_key: called CC=2 SCAR=7.2
| |||||||||||||
| 33 | 1 | my ( $self ) = @_; | |||||||||||
| 34 | return $ENV{LANGERTHA_AKI_API_KEY} | ||||||||||||
| 35 | 1 | ▶ | || croak "".(ref $self)." requires LANGERTHA_AKI_API_KEY or api_key set"; | ||||||||||
|
Condition50%1/2
$ENV{'LANGERTHA_AKI_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_AKI_API_KEY or api_key set')
MC/DC0%0/1
$ENV{'LANGERTHA_AKI_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_AKI_API_KEY or api_key set')
$ENV{'LANGERTHA_AKI_API_KEY'}
Truth table50%1/2
A
A= $ENV{'LANGERTHA_AKI_API_KEY'}
| |||||||||||||
| 36 | } | ||||||||||||
| 37 | |||||||||||||
| 38 | |||||||||||||
| 39 | # gpt-oss-120b replaces the EOL llama3-chat-8b (AKI.IO end-of-life 2026-09-30) | ||||||||||||
| 40 | # as the default. AKI.IO exposes MiniMax M3 only on its native endpoint, so a | ||||||||||||
| 41 | # current non-MiniMax model AKI's own table rates "Supported" is the shim | ||||||||||||
| 42 | # default. Verified live 2026-09-10: the /openai/v1 shim answers gpt-oss-120b | ||||||||||||
| 43 | # and echoes it back as $response->model (unknown ids are rejected loudly here, | ||||||||||||
| 44 | # not silently substituted). -- karr k132 | ||||||||||||
| 45 | 19 | ▶ | sub default_model { 'gpt-oss-120b' } | ||||||||||
|
Subroutine
default_model: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 46 | |||||||||||||
| 47 | |||||||||||||
| 48 | 1 | ▶ | sub api_key_env { 'LANGERTHA_AKI_API_KEY' } | ||||||||||
|
Subroutine
api_key_env: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 49 | |||||||||||||
| 50 | 19 | ▶ | sub _build_supported_operations {[qw( createChatCompletion )]} | ||||||||||
|
Subroutine
_build_supported_operations: called CC=1 SCAR=0.0
| |||||||||||||
| 51 | |||||||||||||
| 52 | # AKI.IO's OpenAI-compatibility page documents no parallel_tool_calls (nor | ||||||||||||
| 53 | # tools). One live probe (2026-09-25, gpt-oss-120b, two independent tools, | ||||||||||||
| 54 | # parallel_tool_calls=false) answered 200 with one tool call: the field is | ||||||||||||
| 55 | # accepted, but one call cannot show it is honored. Clear parallel_tool_use | ||||||||||||
| 56 | # until the docs or more evidence say otherwise (karr k242). | ||||||||||||
| 57 | 122 | ▶ | around engine_capabilities => sub { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 58 | 122 | my ( $orig, $self, @rest ) = @_; | |||||||||||
| 59 | 122 | my $caps = $self->$orig(@rest); | |||||||||||
| 60 | 122 | delete $caps->{parallel_tool_use}; | |||||||||||
| 61 | 122 | return $caps; | |||||||||||
| 62 | 17 | }; | |||||||||||
| 63 | |||||||||||||
| 64 | # image_input (k266/k271, ADR 0019 k266 Update): AKI.IO documents no image | ||||||||||||
| 65 | # input on this face and /models carries no modality field, so the catch-all | ||||||||||||
| 66 | # row clears the flag (the default gpt-oss-120b makes no claim). Live probe | ||||||||||||
| 67 | # 2026-09-25 (k271): an 8x8 solid-red base64 PNG sent as an image_url part to | ||||||||||||
| 68 | # qwen3.6-chat-35b answered "Red", its reasoning describing "a solid, uniform | ||||||||||||
| 69 | # block of color" (t/data/akiopenai_qwen36_image_response.json). Follow-up | ||||||||||||
| 70 | # probe 2026-09-25 (k272), same image and prompt, max_tokens 2048: | ||||||||||||
| 71 | # gemma4-chat-26b and qwen3.8-27b both answered "Red", each reasoning about a | ||||||||||||
| 72 | # uniform red field (t/data/akiopenai_{gemma4,qwen38}_image_response.json). | ||||||||||||
| 73 | # Each row claims the probed model's family, as k271 did for qwen3.6-35b: | ||||||||||||
| 74 | # gemma4-26b is claimed with gemma4-chat-26b but was not called itself. | ||||||||||||
| 75 | # Every other id (gpt-oss, llama3, apertus, mistral4, deepseek, glm) stays | ||||||||||||
| 76 | # unclaimed: not probed as of 2026-09-25. | ||||||||||||
| 77 | 122 | ▶ | sub model_capability_corrections { | ||||||||||
|
Subroutine
model_capability_corrections: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 78 | return ( | ||||||||||||
| 79 | 122 | qr/\A/ => { image_input => 0 }, | |||||||||||
| 80 | qr/\Aqwen3\.6(?!\d)/ => { image_input => 1 }, | ||||||||||||
| 81 | qr/\Aqwen3\.8(?!\d)/ => { image_input => 1 }, | ||||||||||||
| 82 | qr/\Agemma4(?!\d)/ => { image_input => 1 }, | ||||||||||||
| 83 | ); | ||||||||||||
| 84 | } | ||||||||||||
| 85 | |||||||||||||
| 86 | 17 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 87 | |||||||||||||
| 88 | |||||||||||||
| 89 | 17 | 1; | |||||||||||
| 90 | |||||||||||||
| 91 | __END__ | ||||||||||||