| 1 | package Langertha::Role::ImageGeneration; | ||||||||||
| 2 | # ABSTRACT: Role for engines that support image generation | ||||||||||
| 3 | 25 | our $VERSION = '0.502'; | |||||||||
| 4 | 25 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 25 | ▶ | use Carp qw( croak ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | |||||||||||
| 8 | 25 | requires 'image_request'; | |||||||||
| 9 | 25 | requires 'simple_image'; | |||||||||
| 10 | |||||||||||
| 11 | 25 | has image_model => ( | |||||||||
| 12 | is => 'ro', | ||||||||||
| 13 | isa => 'Maybe[Str]', | ||||||||||
| 14 | lazy_build => 1, | ||||||||||
| 15 | ); | ||||||||||
| 16 | sub _build_image_model { | ||||||||||
| 17 | 2 | ▶ | my ( $self ) = @_; | ||||||||
|
Subroutine
_build_image_model: called CC=3 SCAR=12.5
| |||||||||||
| 18 | 2 | ▶ | croak "".(ref $self)." can't handle models!" unless $self->does('Langertha::Role::Models'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 2 | ▶ | return $self->default_image_model if $self->can('default_image_model'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 0 | return $self->model; | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | |||||||||||
| 24 | |||||||||||
| 25 | 25 | 1; | |||||||||
| 26 | |||||||||||
| 27 | __END__ | ||||||||||
| 28 | |||||||||||
| 29 | =pod | ||||||||||
| 30 | |||||||||||
| 31 | =encoding UTF-8 | ||||||||||
| 32 | |||||||||||
| 33 | =head1 NAME | ||||||||||
| 34 | |||||||||||
| 35 | Langertha::Role::ImageGeneration - Role for engines that support image generation | ||||||||||
| 36 | |||||||||||
| 37 | =head1 VERSION | ||||||||||
| 38 | |||||||||||
| 39 | version 0.502 | ||||||||||
| 40 | |||||||||||
| 41 | =head1 DESCRIPTION | ||||||||||
| 42 | |||||||||||
| 43 | Engines that can generate images consume this role. It requires | ||||||||||
| 44 | C<image_request> and C<simple_image> methods, and provides an | ||||||||||
| 45 | C<image_model> attribute. | ||||||||||
| 46 | |||||||||||
| 47 | =head2 image_model | ||||||||||
| 48 | |||||||||||
| 49 | The model name to use for image generation requests. Lazily defaults to | ||||||||||
| 50 | C<default_image_model> if the engine provides it, otherwise falls back | ||||||||||
| 51 | to the general C<model> attribute from L<Langertha::Role::Models>. | ||||||||||
| 52 | |||||||||||
| 53 | =head1 SEE ALSO | ||||||||||
| 54 | |||||||||||
| 55 | =over | ||||||||||
| 56 | |||||||||||
| 57 | =item * L<Langertha::ImageGen> - Wrapper class for image generation with plugin support | ||||||||||
| 58 | |||||||||||
| 59 | =item * L<Langertha::Role::Models> - Model selection role | ||||||||||
| 60 | |||||||||||
| 61 | =item * L<Langertha::Plugin::Langfuse> - Observability plugin (hooks into image gen) | ||||||||||
| 62 | |||||||||||
| 63 | =back | ||||||||||
| 64 | |||||||||||
| 65 | =head1 SUPPORT | ||||||||||
| 66 | |||||||||||
| 67 | =head2 Issues | ||||||||||
| 68 | |||||||||||
| 69 | Please report bugs and feature requests on GitHub at | ||||||||||
| 70 | L<https://github.com/Getty/langertha/issues>. | ||||||||||
| 71 | |||||||||||
| 72 | =head2 IRC | ||||||||||
| 73 | |||||||||||
| 74 | Join C<#langertha> on C<irc.perl.org> or message Getty directly. | ||||||||||
| 75 | |||||||||||
| 76 | =head1 CONTRIBUTING | ||||||||||
| 77 | |||||||||||
| 78 | Contributions are welcome! Please fork the repository and submit a pull request. | ||||||||||
| 79 | |||||||||||
| 80 | =head1 AUTHOR | ||||||||||
| 81 | |||||||||||
| 82 | Torsten Raudssus <getty@cpan.org> | ||||||||||
| 83 | |||||||||||
| 84 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 85 | |||||||||||
| 86 | This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>. | ||||||||||
| 87 | |||||||||||
| 88 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 89 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 90 | |||||||||||
| 91 | =cut | ||||||||||