Skip to content

Commit dab21e0

Browse files
minor #226 Fix exception messages (nicolas-grekas)
This PR was merged into the main branch. Discussion ---------- Fix exception messages | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Docs? | no | Issues | - | License | MIT As fabbot would suggest (+ minor tweaks) Commits ------- b78d305 Fix exception messages
2 parents 6651405 + b78d305 commit dab21e0

File tree

32 files changed

+50
-60
lines changed

32 files changed

+50
-60
lines changed

.github/workflows/code-quality.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,6 @@ concurrency:
1515
cancel-in-progress: true
1616

1717
jobs:
18-
cs-php:
19-
runs-on: ubuntu-latest
20-
steps:
21-
- uses: actions/checkout@v4
22-
- uses: shivammathur/setup-php@v2
23-
with:
24-
php-version: '8.3'
25-
tools: php-cs-fixer
26-
- name: php-cs-fixer
27-
run: php-cs-fixer check --diff
28-
2918
phpstan:
3019
name: PHPStan
3120
runs-on: ubuntu-latest

src/agent/src/Agent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function call(MessageBagInterface $messages, array $options = []): Result
8888

8989
throw new InvalidArgumentException('' === $message ? 'Invalid request to model or platform' : $message, previous: $e);
9090
} catch (HttpExceptionInterface $e) {
91-
throw new RuntimeException('Failed to request model', previous: $e);
91+
throw new RuntimeException('Failed to request model.', previous: $e);
9292
}
9393

9494
$output = new Output($model, $result, $messages, $options);
@@ -107,7 +107,7 @@ private function initializeProcessors(iterable $processors, string $interface):
107107
{
108108
foreach ($processors as $processor) {
109109
if (!$processor instanceof $interface) {
110-
throw new InvalidArgumentException(\sprintf('Processor %s must implement %s interface.', $processor::class, $interface));
110+
throw new InvalidArgumentException(\sprintf('Processor "%s" must implement "%s".', $processor::class, $interface));
111111
}
112112

113113
if ($processor instanceof AgentAwareInterface) {

src/agent/src/InputProcessor/ModelOverrideInputProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function processInput(Input $input): void
3030
}
3131

3232
if (!$options['model'] instanceof Model) {
33-
throw new InvalidArgumentException(\sprintf('Option "model" must be an instance of %s.', Model::class));
33+
throw new InvalidArgumentException(\sprintf('Option "model" must be an instance of "%s".', Model::class));
3434
}
3535

3636
$input->model = $options['model'];

src/agent/src/StructuredOutput/AgentProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function processInput(Input $input): void
6262
}
6363

6464
if (true === ($options['stream'] ?? false)) {
65-
throw new InvalidArgumentException('Streamed responses are not supported for structured output');
65+
throw new InvalidArgumentException('Streamed responses are not supported for structured output.');
6666
}
6767

6868
$options['response_format'] = $this->responseFormatFactory->create($options['output_structure']);

src/agent/tests/AgentTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function testConstructorThrowsExceptionForInvalidInputProcessor()
104104
$invalidProcessor = new \stdClass();
105105

106106
$this->expectException(InvalidArgumentException::class);
107-
$this->expectExceptionMessage('Processor stdClass must implement Symfony\AI\Agent\InputProcessorInterface interface.');
107+
$this->expectExceptionMessage('Processor "stdClass" must implement "Symfony\AI\Agent\InputProcessorInterface".');
108108

109109
/* @phpstan-ignore-next-line */
110110
new Agent($platform, $model, [$invalidProcessor]);
@@ -117,7 +117,7 @@ public function testConstructorThrowsExceptionForInvalidOutputProcessor()
117117
$invalidProcessor = new \stdClass();
118118

119119
$this->expectException(InvalidArgumentException::class);
120-
$this->expectExceptionMessage('Processor stdClass must implement Symfony\AI\Agent\OutputProcessorInterface interface.');
120+
$this->expectExceptionMessage('Processor "stdClass" must implement "Symfony\AI\Agent\OutputProcessorInterface".');
121121

122122
/* @phpstan-ignore-next-line */
123123
new Agent($platform, $model, [], [$invalidProcessor]);

src/agent/tests/InputProcessor/ModelOverrideInputProcessorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function testProcessInputWithoutModelOption()
5858
public function testProcessInputWithInvalidModelOption()
5959
{
6060
self::expectException(InvalidArgumentException::class);
61-
self::expectExceptionMessage('Option "model" must be an instance of Symfony\AI\Platform\Model.');
61+
self::expectExceptionMessage('Option "model" must be an instance of "Symfony\AI\Platform\Model".');
6262

6363
$gpt = new GPT();
6464
$model = new MessageBag();

src/platform/src/Bridge/Anthropic/ResultConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function convert(RawHttpResult|RawResultInterface $result, array $options
4545
$data = $result->getData();
4646

4747
if (!isset($data['content']) || [] === $data['content']) {
48-
throw new RuntimeException('Response does not contain any content');
48+
throw new RuntimeException('Response does not contain any content.');
4949
}
5050

5151
$toolCalls = [];

src/platform/src/Bridge/Azure/Meta/LlamaResultConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function convert(RawResultInterface $result, array $options = []): TextRe
3333
$data = $result->getData();
3434

3535
if (!isset($data['choices'][0]['message']['content'])) {
36-
throw new RuntimeException('Response does not contain output');
36+
throw new RuntimeException('Response does not contain output.');
3737
}
3838

3939
return new TextResult($data['choices'][0]['message']['content']);

src/platform/src/Bridge/Bedrock/Anthropic/ClaudeModelClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ public function convert(InvokeModelResponse $bedrockResponse): ToolCallResult|Te
6565
$data = json_decode($bedrockResponse->getBody(), true, 512, \JSON_THROW_ON_ERROR);
6666

6767
if (!isset($data['content']) || [] === $data['content']) {
68-
throw new RuntimeException('Response does not contain any content');
68+
throw new RuntimeException('Response does not contain any content.');
6969
}
7070

7171
if (!isset($data['content'][0]['text']) && !isset($data['content'][0]['type'])) {
72-
throw new RuntimeException('Response content does not contain any text or type');
72+
throw new RuntimeException('Response content does not contain any text or type.');
7373
}
7474

7575
$toolCalls = [];

src/platform/src/Bridge/Bedrock/Anthropic/ClaudeResultConverter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ public function convert(RawResultInterface|RawBedrockResult $result, array $opti
3636
$data = $result->getData();
3737

3838
if (!isset($data['content']) || [] === $data['content']) {
39-
throw new RuntimeException('Response does not contain any content');
39+
throw new RuntimeException('Response does not contain any content.');
4040
}
4141

4242
if (!isset($data['content'][0]['text']) && !isset($data['content'][0]['type'])) {
43-
throw new RuntimeException('Response content does not contain any text or type');
43+
throw new RuntimeException('Response content does not contain any text or type.');
4444
}
4545

4646
$toolCalls = [];

0 commit comments

Comments
 (0)