| 1 | package App::Greple::xlate::llm::gpt5; | ||
| 2 | |||
| 3 | 44 | our $VERSION = "2.03"; | |
| 4 | |||
| 5 | =encoding utf-8 | ||
| 6 | |||
| 7 | =head1 NAME | ||
| 8 | |||
| 9 | App::Greple::xlate::llm::gpt5 - GPT-5.6 Terra translation engine (llm backend) for greple xlate module | ||
| 10 | |||
| 11 | =head1 SYNOPSIS | ||
| 12 | |||
| 13 | greple -Mxlate --xlate-engine=gpt5 --xlate=ja file.txt | ||
| 14 | |||
| 15 | =head1 DESCRIPTION | ||
| 16 | |||
| 17 | This module provides GPT-5.6 Terra translation support for the | ||
| 18 | App::Greple::xlate module, calling the model through the C<llm> | ||
| 19 | command line tool (L<https://llm.datasette.io/>) instead of the | ||
| 20 | older C<gpty> command. The engine name, translation prompt, and | ||
| 21 | cache files (C<*.xlate-gpt5-*.json>) are fully compatible with the | ||
| 22 | gpty backend engine L<App::Greple::xlate::gpty::gpt5>. | ||
| 23 | |||
| 24 | The C<llm> command must be installed and must know the C<gpt-5.6-terra> | ||
| 25 | model (check with C<llm models | grep gpt-5.6-terra>). If the call fails, this module | ||
| 26 | inspects the environment and reports what is missing. | ||
| 27 | |||
| 28 | This engine is context-aware: when re-translating changed blocks it | ||
| 29 | receives the surrounding source text, neighboring translation pairs, | ||
| 30 | and the previous version of the changed text, controlled by the | ||
| 31 | B<--xlate-context-window> option of L<App::Greple::xlate>. | ||
| 32 | |||
| 33 | =head1 CONFIGURATION | ||
| 34 | |||
| 35 | This engine uses the following defaults: | ||
| 36 | |||
| 37 | =over 4 | ||
| 38 | |||
| 39 | =item * B<model>: gpt-5.6-terra | ||
| 40 | |||
| 41 | =item * B<reasoning_effort>: low (lowest effort supported by llm for GPT-5.6 Terra) | ||
| 42 | |||
| 43 | =item * B<verbosity>: low | ||
| 44 | |||
| 45 | =item * B<max_length>: 3000 characters per batch | ||
| 46 | |||
| 47 | =back | ||
| 48 | |||
| 49 | No C<temperature> option is sent: reasoning models reject non-default | ||
| 50 | temperatures, and C<llm> only sends the option when specified. | ||
| 51 | |||
| 52 | No C<max_tokens> option is sent either. Omitting the cap leaves the | ||
| 53 | translation output naturally bounded by the input size and avoids | ||
| 54 | endpoint-specific output-token option differences. | ||
| 55 | |||
| 56 | =head1 ENVIRONMENT VARIABLES | ||
| 57 | |||
| 58 | =over 4 | ||
| 59 | |||
| 60 | =item * B<OPENAI_API_KEY> - OpenAI API key, read by the C<llm> command. | ||
| 61 | Alternatively use C<llm keys set openai>. | ||
| 62 | |||
| 63 | =back | ||
| 64 | |||
| 65 | =head1 RELATED OPTIONS | ||
| 66 | |||
| 67 | =over 4 | ||
| 68 | |||
| 69 | =item * B<--xlate-maxlen>=I<chars> - Maximum characters sent per request | ||
| 70 | (defaults to this engine's value of 3000 when unset) | ||
| 71 | |||
| 72 | =item * B<--xlate-maxline>=I<n> - Maximum lines sent per request | ||
| 73 | (default 0 = unlimited); useful as a safety valve if a large batch | ||
| 74 | causes a response element-count mismatch | ||
| 75 | |||
| 76 | =item * B<--xlate-debug> - Dump the C<llm> command and parameters | ||
| 77 | |||
| 78 | =item * B<--xlate-setopt backend=gpty> - Force the old gpty backend | ||
| 79 | engine for comparison | ||
| 80 | |||
| 81 | =back | ||
| 82 | |||
| 83 | =head1 DEPENDENCIES | ||
| 84 | |||
| 85 | =over 4 | ||
| 86 | |||
| 87 | =item * L<App::Greple::xlate> | ||
| 88 | |||
| 89 | =item * C<llm> command (L<https://llm.datasette.io/>) | ||
| 90 | |||
| 91 | =item * L<Command::Run>, L<JSON> | ||
| 92 | |||
| 93 | =back | ||
| 94 | |||
| 95 | =head1 SEE ALSO | ||
| 96 | |||
| 97 | =over 4 | ||
| 98 | |||
| 99 | =item * L<App::Greple::xlate> | ||
| 100 | |||
| 101 | =item * L<App::Greple::xlate::llm> | ||
| 102 | |||
| 103 | =item * L<App::Greple::xlate::gpty::gpt5> | ||
| 104 | |||
| 105 | =back | ||
| 106 | |||
| 107 | =head1 AUTHOR | ||
| 108 | |||
| 109 | Kazumasa Utashiro | ||
| 110 | |||
| 111 | =head1 LICENSE | ||
| 112 | |||
| 113 | Copyright 2026 Kazumasa Utashiro. | ||
| 114 | |||
| 115 | This library is free software; you can redistribute it and/or modify | ||
| 116 | it under the same terms as Perl itself. | ||
| 117 | |||
| 118 | =cut | ||
| 119 | |||
| 120 | 44 | ▶ | use v5.14; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 121 | 44 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 122 | 44 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 123 | 44 | ▶ | use utf8; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 124 | |||
| 125 | 44 | ▶ | use App::Greple::xlate::llm; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 126 | |||
| 127 | 44 | App::Greple::xlate::llm::register_engine(__PACKAGE__, | |
| 128 | model => 'gpt-5.6-terra', | ||
| 129 | options => [ [ reasoning_effort => 'low' ], | ||
| 130 | [ verbosity => 'low' ] ], | ||
| 131 | ); | ||
| 132 | |||
| 133 | 44 | 1; | |
| 134 | |||
| 135 | __DATA__ | ||