| 1 | package Langertha::Engine::Replicate; | ||||||||||||
| 2 | # ABSTRACT: Replicate API | ||||||||||||
| 3 | 9 | our $VERSION = '0.505'; | |||||||||||
| 4 | 9 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 9 | ▶ | use Carp qw( croak ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 9 | extends 'Langertha::Engine::OpenAIBase'; | |||||||||||
| 8 | |||||||||||||
| 9 | 9 | with 'Langertha::Role::Tools'; | |||||||||||
| 10 | |||||||||||||
| 11 | |||||||||||||
| 12 | has '+url' => ( | ||||||||||||
| 13 | lazy => 1, | ||||||||||||
| 14 | 2 | ▶ | default => sub { 'https://api.replicate.com/v1' }, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | 9 | ); | |||||||||||
| 16 | |||||||||||||
| 17 | 1 | ▶ | sub _build_api_key { | ||||||||||
|
Subroutine
_build_api_key: called CC=2 SCAR=7.2
| |||||||||||||
| 18 | 1 | my ( $self ) = @_; | |||||||||||
| 19 | return $ENV{LANGERTHA_REPLICATE_API_KEY} | ||||||||||||
| 20 | 1 | ▶ | || croak "".(ref $self)." requires LANGERTHA_REPLICATE_API_KEY or api_key set"; | ||||||||||
|
Condition50%1/2
$ENV{'LANGERTHA_REPLICATE_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_REPLICATE_API_KEY or api_key set')
MC/DC0%0/1
$ENV{'LANGERTHA_REPLICATE_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_REPLICATE_API_KEY or api_key set')
$ENV{'LANGERTHA_REPLICATE_API_KEY'}
Truth table50%1/2
A
A= $ENV{'LANGERTHA_REPLICATE_API_KEY'}
| |||||||||||||
| 21 | } | ||||||||||||
| 22 | |||||||||||||
| 23 | 1 | ▶ | sub default_model { croak "".(ref $_[0])." requires model to be set" } | ||||||||||
|
Subroutine
default_model: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 24 | |||||||||||||
| 25 | 13 | ▶ | sub _build_supported_operations {[qw( | ||||||||||
|
Subroutine
_build_supported_operations: called CC=1 SCAR=0.0
| |||||||||||||
| 26 | createChatCompletion | ||||||||||||
| 27 | )]} | ||||||||||||
| 28 | |||||||||||||
| 29 | # Replicate's OpenAPI (api.replicate.com/openapi.json) has no chat/completions | ||||||||||||
| 30 | # path, so nothing documents parallel_tool_calls: clear parallel_tool_use | ||||||||||||
| 31 | # (karr k242, docs only; the endpoint question itself is karr k243). | ||||||||||||
| 32 | 79 | ▶ | around engine_capabilities => sub { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 33 | 79 | my ( $orig, $self, @rest ) = @_; | |||||||||||
| 34 | 79 | my $caps = $self->$orig(@rest); | |||||||||||
| 35 | 79 | delete $caps->{parallel_tool_use}; | |||||||||||
| 36 | # image_input (k266, ADR 0019): a gateway: the model behind it is unknown to the client, so no claim. | ||||||||||||
| 37 | 79 | delete $caps->{image_input}; | |||||||||||
| 38 | 79 | return $caps; | |||||||||||
| 39 | 9 | }; | |||||||||||
| 40 | |||||||||||||
| 41 | 9 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 42 | |||||||||||||
| 43 | |||||||||||||
| 44 | 9 | 1; | |||||||||||
| 45 | |||||||||||||
| 46 | __END__ | ||||||||||||