Skip to content

refactor!: rename Capability::OUTPUT_STRUCTURED to STRUCTURED_OUTPUT #362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions UPGRADE.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would for now favor to list the BC breaking PRs in the releases instead doing an upgrade guide - it's just additional work while a lot of stuff is still changing, sorry

Original file line number Diff line number Diff line change
@@ -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'`.
2 changes: 1 addition & 1 deletion src/Chain/StructuredOutput/ChainProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Platform/Bridge/Google/Gemini.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];

Expand Down
2 changes: 1 addition & 1 deletion src/Platform/Bridge/Mistral/Mistral.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Platform/Bridge/OpenAI/GPT.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Platform/Capability.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/Chain/StructuredOutput/ChainProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down