Skip to content

Commit 688a636

Browse files
fixed the typings for the json response in the ollama json response
1 parent 22ed668 commit 688a636

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Agents/Adapters/Ollama.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ public function embed(string $text): array
7373
/**
7474
* @var array{
7575
* error?: string,
76-
* embeddings?: array<int, array<int, float>>,
77-
* total_duration?: int,
78-
* load_duration?: int
76+
* embeddings: array<int, array<int, float>>,
77+
* total_duration: int,
78+
* load_duration: int
7979
* }|null $json
8080
*/
8181
$json = is_string($body) ? json_decode($body, true) : null;
@@ -85,7 +85,7 @@ public function embed(string $text): array
8585
}
8686

8787
return [
88-
'embedding' => $json['embeddings'][0],
88+
'embedding' => $json['embeddings'] ? $json['embeddings'][0] : [],
8989
'total_duration' => $json['total_duration'] ?? null,
9090
'load_duration' => $json['load_duration'] ?? null,
9191
];
@@ -173,7 +173,7 @@ public function getName(): string
173173
*/
174174
protected function formatErrorMessage($json): string
175175
{
176-
if (!is_array($json)) {
176+
if (! is_array($json)) {
177177
return '(unknown_error) Unknown error';
178178
}
179179

0 commit comments

Comments
 (0)