Skip to content

Commit a23055d

Browse files
linting issues fixed
1 parent 688a636 commit a23055d

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

src/Agents/Adapters/Ollama.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +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-
*/
8173
$json = is_string($body) ? json_decode($body, true) : null;
8274

75+
if (! is_array($json)) {
76+
throw new \Exception('Invalid response format received from the API');
77+
}
78+
8379
if (isset($json['error'])) {
8480
throw new \Exception($json['error'], $response->getStatusCode());
8581
}
8682

8783
return [
88-
'embedding' => $json['embeddings'] ? $json['embeddings'][0] : [],
84+
'embedding' => $json['embeddings'][0] ?? [],
8985
'total_duration' => $json['total_duration'] ?? null,
9086
'load_duration' => $json['load_duration'] ?? null,
9187
];

0 commit comments

Comments
 (0)