Langertha
view release on metacpan or search on metacpan
lib/Langertha/Role/Capabilities.pm view on Meta::CPAN
package Langertha::Role::Capabilities;
# ABSTRACT: Engine-capability registry derived from composed roles
our $VERSION = '0.502';
use Moose::Role;
# Role-name => list of capability flag names that role contributes.
# Plus implicit:
# chat -> simple_chat works (Role::Chat is composed)
# streaming -> chat_stream_request is wired up (Role::Streaming)
# tools_native -> Role::Tools (the named flags below come too)
# tools_hermes -> Role::HermesTools
# ... see %ROLE_TO_CAPS below.
my %ROLE_TO_CAPS = (
'Langertha::Role::Chat' => [qw( chat )],
'Langertha::Role::Streaming' => [qw( streaming )],
'Langertha::Role::Tools' => [qw(
tools_native tool_choice_auto tool_choice_any tool_choice_none tool_choice_named
)],
'Langertha::Role::HermesTools' => [qw( tools_hermes )],
'Langertha::Role::ResponseFormat' => [qw(
response_format_json_object response_format_json_schema
)],
'Langertha::Role::Embedding' => [qw( embedding )],
'Langertha::Role::Transcription' => [qw( transcription )],
'Langertha::Role::ImageGeneration' => [qw( image_generation )],
'Langertha::Role::Temperature' => [qw( temperature )],
'Langertha::Role::Seed' => [qw( seed )],
'Langertha::Role::ContextSize' => [qw( context_size )],
'Langertha::Role::ResponseSize' => [qw( response_size )],
'Langertha::Role::SystemPrompt' => [qw( system_prompt )],
'Langertha::Role::ParallelToolUse' => [qw( parallel_tool_use )],
);
sub engine_capabilities {
my ($self) = @_;
my %caps;
for my $role ( keys %ROLE_TO_CAPS ) {
next unless $self->does($role);
$caps{$_} = 1 for @{ $ROLE_TO_CAPS{$role} };
}
return \%caps;
}
sub supports {
my ( $self, $cap ) = @_;
return !!$self->engine_capabilities->{$cap};
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Langertha::Role::Capabilities - Engine-capability registry derived from composed roles
=head1 VERSION
version 0.502
=head1 SYNOPSIS
if ( $engine->supports('tool_choice_named') ) { ... }
my $caps = $engine->engine_capabilities;
for my $cap ( sort keys %$caps ) {
say "$cap" if $caps->{$cap};
}
( run in 0.506 second using v1.01-cache-2.11-cpan-5735350b133 )