| 1 | package App::Greple::xlate::llm::gpt6; | ||
| 2 | |||
| 3 | 5 | our $VERSION = "2.03"; | |
| 4 | |||
| 5 | =encoding utf-8 | ||
| 6 | |||
| 7 | =head1 NAME | ||
| 8 | |||
| 9 | App::Greple::xlate::llm::gpt6 - GPT-6 Astra translation engine (llm backend) for greple xlate module | ||
| 10 | |||
| 11 | =head1 SYNOPSIS | ||
| 12 | |||
| 13 | greple -Mxlate --xlate-engine=gpt6 --xlate=ja file.txt | ||
| 14 | |||
| 15 | =head1 DESCRIPTION | ||
| 16 | |||
| 17 | This module provides GPT-6 Astra 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/>). Select it with | ||
| 20 | C<xlate -e gpt6 -t JA file.txt>. Its cache files use the separate | ||
| 21 | C<*.xlate-gpt6-*.json> namespace. | ||
| 22 | |||
| 23 | The C<llm> command must be installed and must know the C<gpt-6-astra> | ||
| 24 | model (check with C<llm models | grep gpt-6-astra>). If the call fails, this module | ||
| 25 | inspects the environment and reports what is missing. | ||
| 26 | |||
| 27 | This engine is context-aware: when re-translating changed blocks it | ||
| 28 | receives the surrounding source text, neighboring translation pairs, | ||
| 29 | and the previous version of the changed text, controlled by the | ||
| 30 | B<--xlate-context-window> option of L<App::Greple::xlate>. | ||
| 31 | |||
| 32 | =head1 CONFIGURATION | ||
| 33 | |||
| 34 | This engine uses the following defaults: | ||
| 35 | |||
| 36 | =over 4 | ||
| 37 | |||
| 38 | =item * B<model>: gpt-6-astra | ||
| 39 | |||
| 40 | =item * B<reasoning_effort>: low (lowest effort supported by llm for GPT-6 Astra) | ||
| 41 | |||
| 42 | =item * B<max_length>: 3000 characters per batch | ||
| 43 | |||
| 44 | =back | ||
| 45 | |||
| 46 | No C<temperature> option is sent: GPT-6 Astra does not support this | ||
| 47 | parameter, and C<llm> only sends it when specified. | ||
| 48 | |||
| 49 | No C<max_tokens> option is sent either. Omitting the cap leaves the | ||
| 50 | translation output naturally bounded by the input size and avoids | ||
| 51 | endpoint-specific output-token option differences. | ||
| 52 | |||
| 53 | No C<verbosity> option is sent. The shared prompt requires a JSON | ||
| 54 | array with no commentary; omitting this option also supports custom | ||
| 55 | Responses models registered with C<llm 0.33>. | ||
| 56 | |||
| 57 | =head1 MODEL REGISTRATION | ||
| 58 | |||
| 59 | If C<llm models> does not list C<gpt-6-astra>, add the following entry | ||
| 60 | to C<extra-openai-models.yaml> in the C<llm> user directory (the directory | ||
| 61 | containing the path printed by C<llm logs path>). Preserve any existing entries. | ||
| 62 | |||
| 63 | - model_id: gpt-6-astra | ||
| 64 | model_name: gpt-6-astra | ||
| 65 | responses: true | ||
| 66 | reasoning: true | ||
| 67 | supports_schema: true | ||
| 68 | |||
| 69 | Check registration with C<llm models -m gpt-6-astra --options>. | ||
| 70 | Model registration does not grant API access; the API key must have | ||
| 71 | access to GPT-6 Astra. | ||
| 72 | |||
| 73 | =head1 ENVIRONMENT VARIABLES | ||
| 74 | |||
| 75 | =over 4 | ||
| 76 | |||
| 77 | =item * B<OPENAI_API_KEY> - OpenAI API key, read by the C<llm> command. | ||
| 78 | Alternatively use C<llm keys set openai>. | ||
| 79 | |||
| 80 | =back | ||
| 81 | |||
| 82 | =head1 RELATED OPTIONS | ||
| 83 | |||
| 84 | =over 4 | ||
| 85 | |||
| 86 | =item * B<--xlate-maxlen>=I<chars> - Maximum characters sent per request | ||
| 87 | (defaults to this engine's value of 3000 when unset) | ||
| 88 | |||
| 89 | =item * B<--xlate-maxline>=I<n> - Maximum lines sent per request | ||
| 90 | (default 0 = unlimited); useful as a safety valve if a large batch | ||
| 91 | causes a response element-count mismatch | ||
| 92 | |||
| 93 | =item * B<--xlate-debug> - Dump the C<llm> command and parameters | ||
| 94 | |||
| 95 | =back | ||
| 96 | |||
| 97 | =head1 DEPENDENCIES | ||
| 98 | |||
| 99 | =over 4 | ||
| 100 | |||
| 101 | =item * L<App::Greple::xlate> | ||
| 102 | |||
| 103 | =item * C<llm> command (L<https://llm.datasette.io/>) | ||
| 104 | |||
| 105 | =item * L<Command::Run>, L<JSON> | ||
| 106 | |||
| 107 | =back | ||
| 108 | |||
| 109 | =head1 SEE ALSO | ||
| 110 | |||
| 111 | =over 4 | ||
| 112 | |||
| 113 | =item * L<App::Greple::xlate> | ||
| 114 | |||
| 115 | =item * L<App::Greple::xlate::llm> | ||
| 116 | |||
| 117 | =item * L<App::Greple::xlate::llm::gpt5> | ||
| 118 | |||
| 119 | =item * L<https://developers.openai.com/api/docs/models/gpt-6-astra> | ||
| 120 | |||
| 121 | =back | ||
| 122 | |||
| 123 | =head1 AUTHOR | ||
| 124 | |||
| 125 | Kazumasa Utashiro | ||
| 126 | |||
| 127 | =head1 LICENSE | ||
| 128 | |||
| 129 | Copyright 2026 Kazumasa Utashiro. | ||
| 130 | |||
| 131 | This library is free software; you can redistribute it and/or modify | ||
| 132 | it under the same terms as Perl itself. | ||
| 133 | |||
| 134 | =cut | ||
| 135 | |||
| 136 | 5 | ▶ | use v5.14; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 137 | 5 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 138 | 5 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 139 | 5 | ▶ | use utf8; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 140 | |||
| 141 | 5 | ▶ | use App::Greple::xlate::llm; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 142 | |||
| 143 | 5 | App::Greple::xlate::llm::register_engine(__PACKAGE__, | |
| 144 | model => 'gpt-6-astra', | ||
| 145 | options => [ [ reasoning_effort => 'low' ] ], | ||
| 146 | ); | ||
| 147 | |||
| 148 | 5 | 1; | |
| 149 | |||
| 150 | __DATA__ | ||