File tree Expand file tree Collapse file tree 1 file changed +3
-10
lines changed
Expand file tree Collapse file tree 1 file changed +3
-10
lines changed Original file line number Diff line number Diff line change @@ -70,22 +70,15 @@ 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- */
73+
8174 $ json = is_string ($ body ) ? json_decode ($ body , true ) : null ;
8275
8376 if (isset ($ json ['error ' ])) {
8477 throw new \Exception ($ json ['error ' ], $ response ->getStatusCode ());
8578 }
8679
8780 return [
88- 'embedding ' => $ json ['embeddings ' ][ 0 ],
81+ 'embedding ' => $ json ['embeddings ' ] ? $ json [ ' embeddings ' ][ 0 ] : [ ],
8982 'total_duration ' => $ json ['total_duration ' ] ?? null ,
9083 'load_duration ' => $ json ['load_duration ' ] ?? null ,
9184 ];
@@ -173,7 +166,7 @@ public function getName(): string
173166 */
174167 protected function formatErrorMessage ($ json ): string
175168 {
176- if (!is_array ($ json )) {
169+ if (! is_array ($ json )) {
177170 return '(unknown_error) Unknown error ' ;
178171 }
179172
You can’t perform that action at this time.
0 commit comments