|
4 | 4 |
|
5 | 5 | namespace PhpLlm\LlmChain\Bridge\Anthropic; |
6 | 6 |
|
7 | | -use http\Exception\RuntimeException; |
| 7 | +use PhpLlm\LlmChain\Exception\RuntimeException; |
8 | 8 | use PhpLlm\LlmChain\Model\Message\MessageBag; |
9 | 9 | use PhpLlm\LlmChain\Model\Model; |
10 | 10 | use PhpLlm\LlmChain\Model\Response\ResponseInterface as LlmResponse; |
|
15 | 15 | use Symfony\Component\HttpClient\Chunk\ServerSentEvent; |
16 | 16 | use Symfony\Component\HttpClient\EventSourceHttpClient; |
17 | 17 | 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; |
23 | 18 | use Symfony\Contracts\HttpClient\HttpClientInterface; |
24 | 19 | use Symfony\Contracts\HttpClient\ResponseInterface; |
25 | 20 | use Webmozart\Assert\Assert; |
@@ -61,22 +56,15 @@ public function request(Model $model, object|array|string $input, array $options |
61 | 56 | ]); |
62 | 57 | } |
63 | 58 |
|
64 | | - /** |
65 | | - * @throws TransportExceptionInterface |
66 | | - * @throws ServerExceptionInterface |
67 | | - * @throws RedirectionExceptionInterface |
68 | | - * @throws DecodingExceptionInterface |
69 | | - * @throws ClientExceptionInterface |
70 | | - */ |
71 | 59 | public function convert(ResponseInterface $response, array $options = []): LlmResponse |
72 | 60 | { |
73 | 61 | if ($options['stream'] ?? false) { |
74 | 62 | return new StreamResponse($this->convertStream($response)); |
75 | 63 | } |
76 | 64 |
|
77 | | - $data = $response->toArray(false); |
| 65 | + $data = $response->toArray(); |
78 | 66 |
|
79 | | - if (!isset($data['content']) || !count($data['content'])) { |
| 67 | + if (!isset($data['content']) || 0 === count($data['content'])) { |
80 | 68 | throw new RuntimeException('Response does not contain any content'); |
81 | 69 | } |
82 | 70 |
|
|
0 commit comments