File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -22,13 +22,18 @@ public function __construct(
22
22
*/
23
23
public function sendRequest (string $ method , string $ url , array $ parameters = []): ResponseInterface
24
24
{
25
- return $ this -> client -> request ( $ method , $ url , [
25
+ $ requestParams = [
26
26
'headers ' => [
27
27
'Content-Type ' => 'application/json ' ,
28
28
'Authorization ' => 'Bearer ' .$ this ->authService ->getToken (),
29
- ],
30
- 'json ' => $ parameters
31
- ]);
29
+ ]
30
+ ];
31
+
32
+ if ($ parameters ) {
33
+ $ requestParams ['json ' ] = $ parameters ;
34
+ }
35
+
36
+ return $ this ->client ->request ($ method , $ url , $ requestParams );
32
37
}
33
38
34
39
public function getResult (ResponseInterface $ response , string $ resultClass ): ResultInterface
Original file line number Diff line number Diff line change 2
2
3
3
namespace Itsimiro \OpenAI \Services \API \Results ;
4
4
5
+ use Illuminate \Support \Collection ;
5
6
use Spatie \LaravelData \Data ;
6
- use Spatie \LaravelData \DataCollection ;
7
7
8
8
class ModelsResult extends Data implements ResultInterface
9
9
{
10
10
public function __construct (public array $ result )
11
11
{}
12
12
13
- public function getModels (): DataCollection
13
+ public function getModels (): Collection
14
14
{
15
- return ModelResult::collection ($ this ->result ['data ' ]);
15
+ return Collection::make ($ this ->result ['data ' ])->map (
16
+ fn (array $ item ) => new ModelResult ($ item )
17
+ );
16
18
}
17
19
}
You can’t perform that action at this time.
0 commit comments