Skip to content

Commit bb02cef

Browse files
authored
feat: allow access of methods and read of properties through AsyncRes… (#284)
…ponse
1 parent d743b7b commit bb02cef

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

examples/image-generator-dall-e-3.php

-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use PhpLlm\LlmChain\Bridge\OpenAI\DallE;
44
use PhpLlm\LlmChain\Bridge\OpenAI\DallE\ImageResponse;
55
use PhpLlm\LlmChain\Bridge\OpenAI\PlatformFactory;
6-
use PhpLlm\LlmChain\Model\Response\AsyncResponse;
76
use Symfony\Component\Dotenv\Dotenv;
87

98
require_once dirname(__DIR__).'/vendor/autoload.php';
@@ -24,10 +23,6 @@
2423
],
2524
);
2625

27-
if ($response instanceof AsyncResponse) {
28-
$response = $response->unwrap();
29-
}
30-
3126
assert($response instanceof ImageResponse);
3227

3328
echo 'Revised Prompt: '.$response->revisedPrompt.PHP_EOL.PHP_EOL;

src/Model/Response/AsyncResponse.php

+13
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,17 @@ public function unwrap(): ResponseInterface
3636

3737
return $this->convertedResponse;
3838
}
39+
40+
/**
41+
* @param array<int, mixed> $arguments
42+
*/
43+
public function __call(string $name, array $arguments): mixed
44+
{
45+
return $this->unwrap()->{$name}(...$arguments);
46+
}
47+
48+
public function __get(string $name): mixed
49+
{
50+
return $this->unwrap()->{$name};
51+
}
3952
}

0 commit comments

Comments
 (0)