diff --git a/UPGRADE.md b/UPGRADE.md new file mode 100644 index 00000000..d67630ae --- /dev/null +++ b/UPGRADE.md @@ -0,0 +1,37 @@ +# Upgrade Guide + +## Breaking Changes + +### Capability Constant Rename + +The capability constant `Capability::OUTPUT_STRUCTURED` has been renamed to `Capability::STRUCTURED_OUTPUT` to follow a more consistent naming pattern. + +Additionally, the constant value has been changed from `'output-structured'` to `'structured-output'`. + +#### Before +```php +use PhpLlm\LlmChain\Platform\Capability; + +// Constant name +Capability::OUTPUT_STRUCTURED + +// Constant value +'output-structured' +``` + +#### After +```php +use PhpLlm\LlmChain\Platform\Capability; + +// Constant name +Capability::STRUCTURED_OUTPUT + +// Constant value +'structured-output' +``` + +#### Migration + +Update all references in your code from `Capability::OUTPUT_STRUCTURED` to `Capability::STRUCTURED_OUTPUT`. + +If you're storing or comparing capability strings directly, also update from `'output-structured'` to `'structured-output'`. \ No newline at end of file diff --git a/src/Chain/StructuredOutput/ChainProcessor.php b/src/Chain/StructuredOutput/ChainProcessor.php index a201cc4f..b4abc0cf 100644 --- a/src/Chain/StructuredOutput/ChainProcessor.php +++ b/src/Chain/StructuredOutput/ChainProcessor.php @@ -46,7 +46,7 @@ public function processInput(Input $input): void return; } - if (!$input->model->supports(Capability::OUTPUT_STRUCTURED)) { + if (!$input->model->supports(Capability::STRUCTURED_OUTPUT)) { throw MissingModelSupportException::forStructuredOutput($input->model::class); } diff --git a/src/Platform/Bridge/Google/Gemini.php b/src/Platform/Bridge/Google/Gemini.php index ddc95ea5..74a11c5f 100644 --- a/src/Platform/Bridge/Google/Gemini.php +++ b/src/Platform/Bridge/Google/Gemini.php @@ -29,7 +29,7 @@ public function __construct(string $name = self::GEMINI_2_PRO, array $options = Capability::INPUT_AUDIO, Capability::INPUT_PDF, Capability::OUTPUT_STREAMING, - Capability::OUTPUT_STRUCTURED, + Capability::STRUCTURED_OUTPUT, Capability::TOOL_CALLING, ]; diff --git a/src/Platform/Bridge/Mistral/Mistral.php b/src/Platform/Bridge/Mistral/Mistral.php index 8dff6898..ada6a99e 100644 --- a/src/Platform/Bridge/Mistral/Mistral.php +++ b/src/Platform/Bridge/Mistral/Mistral.php @@ -34,7 +34,7 @@ public function __construct( Capability::INPUT_MESSAGES, Capability::OUTPUT_TEXT, Capability::OUTPUT_STREAMING, - Capability::OUTPUT_STRUCTURED, + Capability::STRUCTURED_OUTPUT, ]; if (\in_array($name, [self::PIXSTRAL, self::PIXSTRAL_LARGE, self::MISTRAL_SMALL], true)) { diff --git a/src/Platform/Bridge/OpenAI/GPT.php b/src/Platform/Bridge/OpenAI/GPT.php index 172a4d5e..1c844052 100644 --- a/src/Platform/Bridge/OpenAI/GPT.php +++ b/src/Platform/Bridge/OpenAI/GPT.php @@ -75,7 +75,7 @@ public function __construct( } if (\in_array($name, self::STRUCTURED_OUTPUT_SUPPORTING, true)) { - $capabilities[] = Capability::OUTPUT_STRUCTURED; + $capabilities[] = Capability::STRUCTURED_OUTPUT; } parent::__construct($name, $capabilities, $options); diff --git a/src/Platform/Capability.php b/src/Platform/Capability.php index e1861db5..a3c9dcff 100644 --- a/src/Platform/Capability.php +++ b/src/Platform/Capability.php @@ -21,7 +21,7 @@ class Capability public const OUTPUT_AUDIO = 'output-audio'; public const OUTPUT_IMAGE = 'output-image'; public const OUTPUT_STREAMING = 'output-streaming'; - public const OUTPUT_STRUCTURED = 'output-structured'; + public const STRUCTURED_OUTPUT = 'structured-output'; public const OUTPUT_TEXT = 'output-text'; // FUNCTIONALITY diff --git a/tests/Chain/StructuredOutput/ChainProcessorTest.php b/tests/Chain/StructuredOutput/ChainProcessorTest.php index 553c8a42..07e8cd45 100644 --- a/tests/Chain/StructuredOutput/ChainProcessorTest.php +++ b/tests/Chain/StructuredOutput/ChainProcessorTest.php @@ -40,7 +40,7 @@ public function processInputWithOutputStructure(): void { $chainProcessor = new ChainProcessor(new ConfigurableResponseFormatFactory(['some' => 'format'])); - $model = new Model('gpt-4', [Capability::OUTPUT_STRUCTURED]); + $model = new Model('gpt-4', [Capability::STRUCTURED_OUTPUT]); $input = new Input($model, new MessageBag(), ['output_structure' => 'SomeStructure']); $chainProcessor->processInput($input); @@ -53,7 +53,7 @@ public function processInputWithoutOutputStructure(): void { $chainProcessor = new ChainProcessor(new ConfigurableResponseFormatFactory()); - $model = new Model('gpt-4', [Capability::OUTPUT_STRUCTURED]); + $model = new Model('gpt-4', [Capability::STRUCTURED_OUTPUT]); $input = new Input($model, new MessageBag(), []); $chainProcessor->processInput($input); @@ -79,7 +79,7 @@ public function processOutputWithResponseFormat(): void { $chainProcessor = new ChainProcessor(new ConfigurableResponseFormatFactory(['some' => 'format'])); - $model = new Model('gpt-4', [Capability::OUTPUT_STRUCTURED]); + $model = new Model('gpt-4', [Capability::STRUCTURED_OUTPUT]); $options = ['output_structure' => SomeStructure::class]; $input = new Input($model, new MessageBag(), $options); $chainProcessor->processInput($input); @@ -100,7 +100,7 @@ public function processOutputWithComplexResponseFormat(): void { $chainProcessor = new ChainProcessor(new ConfigurableResponseFormatFactory(['some' => 'format'])); - $model = new Model('gpt-4', [Capability::OUTPUT_STRUCTURED]); + $model = new Model('gpt-4', [Capability::STRUCTURED_OUTPUT]); $options = ['output_structure' => MathReasoning::class]; $input = new Input($model, new MessageBag(), $options); $chainProcessor->processInput($input);