Skip to content

Commit 9c8f63b

Browse files
linting
1 parent 31e44d8 commit 9c8f63b

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/Agents/Adapters/Ollama.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,18 @@ public function embed(string $text): array
7070
$payload
7171
);
7272
$body = $response->getBody();
73+
/**
74+
* @var array{
75+
* error?: string,
76+
* embeddings?: array<int, array<int, float>>,
77+
* total_duration?: int,
78+
* load_duration?: int
79+
* }|null $json
80+
*/
7381
$json = is_string($body) ? json_decode($body, true) : null;
82+
7483
if (isset($json['error'])) {
75-
throw new \Exception($json['error']);
84+
throw new \Exception($json['error'], $response->getStatusCode());
7685
}
7786

7887
return [
@@ -167,6 +176,7 @@ protected function formatErrorMessage($json): string
167176
if (! is_array($json)) {
168177
return '(unknown_error) Unknown error';
169178
}
179+
170180
return $json['error'] ?? ($json['message'] ?? 'Unknown error');
171181
}
172182

0 commit comments

Comments
 (0)