Skip to content
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
7 changes: 6 additions & 1 deletion src/Builders/PromptBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,12 @@ public function isSupported(?CapabilityEnum $capability = null): bool

// If still no capability, infer from output modalities
if ($capability === null) {
$capability = $this->inferCapabilityFromOutputModalities();
try {
$capability = $this->inferCapabilityFromOutputModalities();
} catch (RuntimeException $e) {
// The output modality maps to no capability, so no model can support it.
return false;
}
}
}

Expand Down
13 changes: 13 additions & 0 deletions tests/unit/Builders/PromptBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3864,6 +3864,19 @@ public function testIsSupportedWithInferredCapability(): void
$this->assertTrue($builder->isSupported());
}

/**
* Tests isSupported returns false for an output modality without a matching capability.
*
* @return void
*/
public function testIsSupportedReturnsFalseForUnsupportedOutputModality(): void
{
$builder = new PromptBuilder($this->registry, 'Test prompt');
$builder->asOutputModalities(ModalityEnum::document());

$this->assertFalse($builder->isSupported());
}

/**
* Tests isSupported method with inferred capability from model interfaces.
*
Expand Down
Loading