Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 1fb7102

Browse files
committed
Fix after review
1 parent 0ebf75b commit 1fb7102

File tree

6 files changed

+11
-23
lines changed

6 files changed

+11
-23
lines changed

src/Bridge/Anthropic/ModelHandler.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace PhpLlm\LlmChain\Bridge\Anthropic;
66

7-
use http\Exception\RuntimeException;
7+
use PhpLlm\LlmChain\Exception\RuntimeException;
88
use PhpLlm\LlmChain\Model\Message\MessageBag;
99
use PhpLlm\LlmChain\Model\Model;
1010
use PhpLlm\LlmChain\Model\Response\ResponseInterface as LlmResponse;
@@ -15,11 +15,6 @@
1515
use Symfony\Component\HttpClient\Chunk\ServerSentEvent;
1616
use Symfony\Component\HttpClient\EventSourceHttpClient;
1717
use Symfony\Component\HttpClient\Exception\JsonException;
18-
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
19-
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
20-
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
21-
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
22-
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
2318
use Symfony\Contracts\HttpClient\HttpClientInterface;
2419
use Symfony\Contracts\HttpClient\ResponseInterface;
2520
use Webmozart\Assert\Assert;
@@ -61,22 +56,15 @@ public function request(Model $model, object|array|string $input, array $options
6156
]);
6257
}
6358

64-
/**
65-
* @throws TransportExceptionInterface
66-
* @throws ServerExceptionInterface
67-
* @throws RedirectionExceptionInterface
68-
* @throws DecodingExceptionInterface
69-
* @throws ClientExceptionInterface
70-
*/
7159
public function convert(ResponseInterface $response, array $options = []): LlmResponse
7260
{
7361
if ($options['stream'] ?? false) {
7462
return new StreamResponse($this->convertStream($response));
7563
}
7664

77-
$data = $response->toArray(false);
65+
$data = $response->toArray();
7866

79-
if (!isset($data['content']) || !count($data['content'])) {
67+
if (!isset($data['content']) || 0 === count($data['content'])) {
8068
throw new RuntimeException('Response does not contain any content');
8169
}
8270

src/Bridge/Ollama/LlamaModelHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace PhpLlm\LlmChain\Bridge\Ollama;
66

7-
use http\Exception\RuntimeException;
87
use PhpLlm\LlmChain\Bridge\Meta\Llama;
8+
use PhpLlm\LlmChain\Exception\RuntimeException;
99
use PhpLlm\LlmChain\Model\Message\MessageBag;
1010
use PhpLlm\LlmChain\Model\Model;
1111
use PhpLlm\LlmChain\Model\Response\ResponseInterface as LlmResponse;
@@ -42,7 +42,7 @@ public function request(Model $model, object|array|string $input, array $options
4242

4343
public function convert(ResponseInterface $response, array $options = []): LlmResponse
4444
{
45-
$data = $response->toArray(false);
45+
$data = $response->toArray();
4646

4747
if (!isset($data['message'])) {
4848
throw new RuntimeException('Response does not contain message');

src/Bridge/OpenAI/Embeddings/ResponseConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function supports(Model $model, array|string|object $input): bool
2121

2222
public function convert(ResponseInterface $response, array $options = []): VectorResponse
2323
{
24-
$data = $response->toArray(false);
24+
$data = $response->toArray();
2525

2626
if (!isset($data['data'])) {
2727
throw new RuntimeException('Response does not contain data');

src/Bridge/OpenAI/GPT/ResponseConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function convert(HttpResponse $response, array $options = []): LlmRespons
3333
return $this->convertStream($response);
3434
}
3535

36-
$data = $response->toArray(false);
36+
$data = $response->toArray();
3737

3838
if (!isset($data['choices'])) {
3939
throw new RuntimeException('Response does not contain choices');

src/Bridge/Replicate/LlamaResponseConverter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace PhpLlm\LlmChain\Bridge\Replicate;
66

7-
use http\Exception\RuntimeException;
87
use PhpLlm\LlmChain\Bridge\Meta\Llama;
8+
use PhpLlm\LlmChain\Exception\RuntimeException;
99
use PhpLlm\LlmChain\Model\Message\MessageBag;
1010
use PhpLlm\LlmChain\Model\Model;
1111
use PhpLlm\LlmChain\Model\Response\ResponseInterface as LlmResponse;
@@ -22,7 +22,7 @@ public function supports(Model $model, object|array|string $input): bool
2222

2323
public function convert(HttpResponse $response, array $options = []): LlmResponse
2424
{
25-
$data = $response->toArray(false);
25+
$data = $response->toArray();
2626

2727
if (!isset($data['output'])) {
2828
throw new RuntimeException('Response does not contain output');

src/Bridge/Voyage/ModelHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace PhpLlm\LlmChain\Bridge\Voyage;
66

7-
use http\Exception\RuntimeException;
87
use PhpLlm\LlmChain\Document\Vector;
8+
use PhpLlm\LlmChain\Exception\RuntimeException;
99
use PhpLlm\LlmChain\Model\Model;
1010
use PhpLlm\LlmChain\Model\Response\ResponseInterface as LlmResponse;
1111
use PhpLlm\LlmChain\Model\Response\VectorResponse;
@@ -40,7 +40,7 @@ public function request(Model $model, object|string|array $input, array $options
4040

4141
public function convert(ResponseInterface $response, array $options = []): LlmResponse
4242
{
43-
$response = $response->toArray(false);
43+
$response = $response->toArray();
4444

4545
if (!isset($response['data'])) {
4646
throw new RuntimeException('Response does not contain embedding data');

0 commit comments

Comments
 (0)