55namespace PhpLlm \LlmChain \Bridge \OpenAI \Whisper ;
66
77use PhpLlm \LlmChain \Bridge \OpenAI \Whisper ;
8- use PhpLlm \LlmChain \Model \Message \Content \Audio ;
98use PhpLlm \LlmChain \Model \Model ;
109use PhpLlm \LlmChain \Platform \ModelClient as BaseModelClient ;
1110use Symfony \Contracts \HttpClient \HttpClientInterface ;
@@ -22,22 +21,17 @@ public function __construct(
2221 Assert::stringNotEmpty ($ apiKey , 'The API key must not be empty. ' );
2322 }
2423
25- public function supports (Model $ model, object | array | string $ input ): bool
24+ public function supports (Model $ model ): bool
2625 {
27- return $ model instanceof Whisper && $ input instanceof Audio ;
26+ return $ model instanceof Whisper;
2827 }
2928
30- public function request (Model $ model , object | array | string $ input , array $ options = []): ResponseInterface
29+ public function request (Model $ model , array $ payload , array $ options = []): ResponseInterface
3130 {
32- assert ($ input instanceof Audio);
33-
3431 return $ this ->httpClient ->request ('POST ' , 'https://api.openai.com/v1/audio/transcriptions ' , [
3532 'auth_bearer ' => $ this ->apiKey ,
3633 'headers ' => ['Content-Type ' => 'multipart/form-data ' ],
37- 'body ' => array_merge ($ options , $ model ->getOptions (), [
38- 'model ' => $ model ->getName (),
39- 'file ' => $ input ->asResource (),
40- ]),
34+ 'body ' => array_merge ($ options , $ payload , ['model ' => $ model ->getName ()]),
4135 ]);
4236 }
4337}
0 commit comments