| 1 | package Langertha::Role::ImageInput; | ||
| 2 | # ABSTRACT: Role for an engine whose wire can carry image input | ||
| 3 | 178 | our $VERSION = '0.503'; | |
| 4 | 178 | ▶ | use Moose::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | |||
| 7 | |||
| 8 | 178 | 1; | |
| 9 | |||
| 10 | __END__ | ||
| 11 | |||
| 12 | =pod | ||
| 13 | |||
| 14 | =encoding UTF-8 | ||
| 15 | |||
| 16 | =head1 NAME | ||
| 17 | |||
| 18 | Langertha::Role::ImageInput - Role for an engine whose wire can carry image input | ||
| 19 | |||
| 20 | =head1 VERSION | ||
| 21 | |||
| 22 | version 0.503 | ||
| 23 | |||
| 24 | =head1 SYNOPSIS | ||
| 25 | |||
| 26 | use Langertha::Content::Image; | ||
| 27 | |||
| 28 | if ( $engine->supports('image_input') ) { | ||
| 29 | my $img = Langertha::Content::Image->from_url('https://example.com/cat.jpg'); | ||
| 30 | my $r = $engine->simple_chat({ | ||
| 31 | role => 'user', content => [ 'What is in this image?', $img ], | ||
| 32 | }); | ||
| 33 | } | ||
| 34 | |||
| 35 | =head1 DESCRIPTION | ||
| 36 | |||
| 37 | A capability role (ADR 0016): an engine composes it when its wire can carry | ||
| 38 | L<Langertha::Content::Image> parts, i.e. its | ||
| 39 | L<Langertha::Role::Chat/content_format> serializes an image into a shape the | ||
| 40 | endpoint accepts. Composing it contributes the C<image_input> flag to | ||
| 41 | L<Langertha::Role::Capabilities/engine_capabilities>. | ||
| 42 | |||
| 43 | C<image_input> is B<model-scoped> and means B<the model sees the image>, not | ||
| 44 | merely that the wire accepts the part (ADR 0019, k266 Update). Most providers | ||
| 45 | serve text-only and vision models side by side, so an engine that composes | ||
| 46 | this role refines the flag per model: | ||
| 47 | |||
| 48 | =over | ||
| 49 | |||
| 50 | =item * all-vision families (OpenAI, first-party Anthropic, Gemini, Hetzner) | ||
| 51 | keep the flag and clear it for the listed text-only models | ||
| 52 | (C<model_capability_corrections>); | ||
| 53 | |||
| 54 | =item * other cloud engines clear it for every model and re-assert it only for | ||
| 55 | the documented vision models -- including the C</anthropic> shims of MiniMax | ||
| 56 | and Moonshot, which carry the same rows as their OpenAI faces; | ||
| 57 | |||
| 58 | =item * gateways, self-hosted servers, AKIAnthropic and LMStudioAnthropic clear | ||
| 59 | it for every model: the model behind them is unknown to the client, or its | ||
| 60 | vision is unverified on that face, so the engine makes no static claim. | ||
| 61 | |||
| 62 | =back | ||
| 63 | |||
| 64 | The static answer can be replaced by what the provider says about its own | ||
| 65 | models: L<Langertha::Role::Capabilities/probe_model_capabilities_f> reads the | ||
| 66 | metadata endpoint of OpenRouter, Mistral, Ollama, OllamaOpenAI, LMStudio, | ||
| 67 | LMStudioOpenAI, LMStudioAnthropic, LlamaCpp and TSystems and stores C<image_input> per model on the engine | ||
| 68 | instance (ADR 0032). Nothing probes implicitly. | ||
| 69 | |||
| 70 | The flag is advisory. Nothing blocks or strips an image when it is false; an | ||
| 71 | image sent to an engine without the claim goes out on the wire as usual and the | ||
| 72 | provider decides. | ||
| 73 | |||
| 74 | One reader chooses a representation by it: in the tool loop, | ||
| 75 | L<Langertha::Role::Tools/format_tool_results> sends an image a I<tool> | ||
| 76 | returned as an image part on the C<responses>, Gemini 3 and C<anthropic> wires | ||
| 77 | only when the flag is true, and as a text placeholder otherwise (see | ||
| 78 | L<Langertha::ToolResult/DESCRIPTION>). A PDF a tool returned follows the same | ||
| 79 | flag on OpenAI Responses and Gemini 3, which read PDFs through the model's | ||
| 80 | vision. So a claim for a model that does not | ||
| 81 | see images is no longer harmless there: the provider may reject the tool-loop | ||
| 82 | turn, or (as AKI.IO's C</anthropic> shim does) accept it while the model never | ||
| 83 | sees the image. | ||
| 84 | |||
| 85 | This role has no methods or attributes of its own. | ||
| 86 | |||
| 87 | =head1 SEE ALSO | ||
| 88 | |||
| 89 | =over | ||
| 90 | |||
| 91 | =item * L<Langertha::Content::Image> - Provider-agnostic image input | ||
| 92 | |||
| 93 | =item * L<Langertha::Role::Capabilities> - The capability registry | ||
| 94 | |||
| 95 | =back | ||
| 96 | |||
| 97 | =head1 SUPPORT | ||
| 98 | |||
| 99 | =head2 Issues | ||
| 100 | |||
| 101 | Please report bugs and feature requests on GitHub at | ||
| 102 | L<https://github.com/Getty/langertha/issues>. | ||
| 103 | |||
| 104 | =head2 IRC | ||
| 105 | |||
| 106 | Join C<#langertha> on C<irc.perl.org> or message Getty directly. | ||
| 107 | |||
| 108 | =head1 CONTRIBUTING | ||
| 109 | |||
| 110 | Contributions are welcome! Please fork the repository and submit a pull request. | ||
| 111 | |||
| 112 | =head1 AUTHOR | ||
| 113 | |||
| 114 | Torsten Raudssus <getty@cpan.org> | ||
| 115 | |||
| 116 | =head1 COPYRIGHT AND LICENSE | ||
| 117 | |||
| 118 | This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>. | ||
| 119 | |||
| 120 | This is free software; you can redistribute it and/or modify it under | ||
| 121 | the same terms as the Perl 5 programming language system itself. | ||
| 122 | |||
| 123 | =cut | ||