| 1 | package Langertha::Engine::Scaleway; | ||||||||||||
| 2 | # ABSTRACT: Scaleway Generative APIs | ||||||||||||
| 3 | 12 | our $VERSION = '0.505'; | |||||||||||
| 4 | 12 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 12 | ▶ | use Carp qw( croak ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 12 | extends 'Langertha::Engine::OpenAIBase'; | |||||||||||
| 8 | |||||||||||||
| 9 | # StreamUsage: the Generative APIs OpenAPI schema has | ||||||||||||
| 10 | # ChatCompletionStreamOptions.include_usage (ADR 0038). | ||||||||||||
| 11 | 12 | with 'Langertha::Role::Embedding', 'Langertha::Role::Tools', 'Langertha::Role::StreamUsage'; | |||||||||||
| 12 | |||||||||||||
| 13 | |||||||||||||
| 14 | has '+url' => ( | ||||||||||||
| 15 | lazy => 1, | ||||||||||||
| 16 | 14 | ▶ | default => sub { 'https://api.scaleway.ai/v1' }, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 17 | 12 | ); | |||||||||||
| 18 | |||||||||||||
| 19 | 1 | ▶ | sub _build_api_key { | ||||||||||
|
Subroutine
_build_api_key: called CC=2 SCAR=7.2
| |||||||||||||
| 20 | 1 | my ( $self ) = @_; | |||||||||||
| 21 | return $ENV{LANGERTHA_SCALEWAY_API_KEY} | ||||||||||||
| 22 | 1 | ▶ | || croak "".(ref $self)." requires LANGERTHA_SCALEWAY_API_KEY or api_key set"; | ||||||||||
|
Condition50%1/2
$ENV{'LANGERTHA_SCALEWAY_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_SCALEWAY_API_KEY or api_key set')
MC/DC0%0/1
$ENV{'LANGERTHA_SCALEWAY_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_SCALEWAY_API_KEY or api_key set')
$ENV{'LANGERTHA_SCALEWAY_API_KEY'}
Truth table50%1/2
A
A= $ENV{'LANGERTHA_SCALEWAY_API_KEY'}
| |||||||||||||
| 23 | } | ||||||||||||
| 24 | |||||||||||||
| 25 | # llama-3.1-8b-instruct went EOL on Scaleway's serverless tier (supported-models | ||||||||||||
| 26 | # page, 2026-09-25); llama-3.3-70b-instruct is still served (k307). | ||||||||||||
| 27 | 16 | ▶ | sub default_model { 'llama-3.3-70b-instruct' } | ||||||||||
|
Subroutine
default_model: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 28 | |||||||||||||
| 29 | # Scaleway's embedding model (supported-models list, llm-advisor 2026-09-25; | ||||||||||||
| 30 | # bge-multilingual-gemma2 is also served). The OpenAI role's | ||||||||||||
| 31 | # text-embedding-3-large is not (k291). | ||||||||||||
| 32 | 2 | ▶ | sub default_embedding_model { 'qwen3-embedding-8b' } | ||||||||||
|
Subroutine
default_embedding_model: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 33 | |||||||||||||
| 34 | # Undocumented: the embeddings API docs list dimensions as unsupported (k319). | ||||||||||||
| 35 | 2 | ▶ | sub _embedding_dimensions_field { undef } | ||||||||||
|
Subroutine
_embedding_dimensions_field: called CC=1 SCAR=0.0
| |||||||||||||
| 36 | |||||||||||||
| 37 | # Scaleway's Generative APIs narrow two flags the OpenAI role inventory grants | ||||||||||||
| 38 | # (scaleway.com/en/docs/generative-apis, verified 2026-09-01): | ||||||||||||
| 39 | # * parallel_tool_calls is accepted but INERT — "even if set false this | ||||||||||||
| 40 | # parameter will be ignored and act as if set to true". A silently-ignored | ||||||||||||
| 41 | # control is worse than a rejected one, so clear parallel_tool_use. | ||||||||||||
| 42 | # * response_format json_object is deprecated ("should not be used anymore"); | ||||||||||||
| 43 | # json_schema is the supported structured-output path, so clear json_object | ||||||||||||
| 44 | # and keep json_schema. | ||||||||||||
| 45 | # NOT cleared: tool_choice_any. Scaleway's tool_choice enum is | ||||||||||||
| 46 | # none|auto|required, and Langertha's canonical `any` serializes to the wire | ||||||||||||
| 47 | # `required` (Langertha::ToolChoice::to_openai), which Scaleway accepts. (The | ||||||||||||
| 48 | # k138 matrix flagged tool_choice_any here by reading OpenAI's non-existent | ||||||||||||
| 49 | # literal "any"; the canonical mapping makes the flag correct as-is.) | ||||||||||||
| 50 | 129 | ▶ | around engine_capabilities => sub { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 51 | 129 | my ( $orig, $self, @rest ) = @_; | |||||||||||
| 52 | 129 | my $caps = $self->$orig(@rest); | |||||||||||
| 53 | 129 | delete @{$caps}{ qw( parallel_tool_use response_format_json_object ) }; | |||||||||||
| 54 | 129 | return $caps; | |||||||||||
| 55 | 12 | }; | |||||||||||
| 56 | |||||||||||||
| 57 | # image_input (k266, ADR 0019 k266 Update): Scaleway serves text-only and | ||||||||||||
| 58 | # vision models side by side (llm-advisor, docs only, 2026-09-25). The | ||||||||||||
| 59 | # catch-all first row clears the flag (the text-only default | ||||||||||||
| 60 | # llama-3.3-70b-instruct makes no claim); the vision families re-assert it. | ||||||||||||
| 61 | 129 | ▶ | sub model_capability_corrections { | ||||||||||
|
Subroutine
model_capability_corrections: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 62 | return ( | ||||||||||||
| 63 | 129 | qr/\A/ => { image_input => 0 }, | |||||||||||
| 64 | qr/\A(?:pixtral-|mistral-small-3\.[12]|mistral-large-3|gemma-3-27b|gemma-4|qwen3\.[56]-|holo2|molmo)/ | ||||||||||||
| 65 | => { image_input => 1 }, | ||||||||||||
| 66 | ); | ||||||||||||
| 67 | } | ||||||||||||
| 68 | |||||||||||||
| 69 | 26 | ▶ | sub _build_supported_operations {[qw( | ||||||||||
|
Subroutine
_build_supported_operations: called CC=1 SCAR=0.0
| |||||||||||||
| 70 | createChatCompletion | ||||||||||||
| 71 | createEmbedding | ||||||||||||
| 72 | )]} | ||||||||||||
| 73 | |||||||||||||
| 74 | 12 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 75 | |||||||||||||
| 76 | |||||||||||||
| 77 | 12 | 1; | |||||||||||
| 78 | |||||||||||||
| 79 | __END__ | ||||||||||||