NAME

Langertha::Role::ResponseFormat - Role for an engine where you can specify structured output

VERSION

version 0.500

decode_loose_json

my $data = $engine->decode_loose_json($text);

Tolerant JSON decoder for structured-output responses where providers sometimes wrap the payload in code fences or surrounding prose. Tries:

1. Decode the whole text as JSON.
2. Strip ```json ... ``` code fences and decode the inner block.
3. Decode the first balanced {...} substring.

Returns the decoded value (typically a HashRef) on success, or undef if all strategies fail. Override in an engine subclass when a provider needs a custom strategy (e.g. always-prose-wrapped output).

response_format

A HashRef specifying the structured output format for the response. The exact structure depends on the engine. For OpenAI-compatible engines this is typically { type = 'json_object' }> or a JSON Schema definition. Optional.

SEE ALSO

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/langertha/issues.

IRC

Join #langertha on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <getty@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.