We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6365947 commit 3a813b7Copy full SHA for 3a813b7
src/Chain/Toolbox/Tool/Chain.php
@@ -0,0 +1,30 @@
1
+<?php
2
+
3
+declare(strict_types=1);
4
5
+namespace PhpLlm\LlmChain\Chain\Toolbox\Tool;
6
7
+use PhpLlm\LlmChain\ChainInterface;
8
+use PhpLlm\LlmChain\Model\Message\Message;
9
+use PhpLlm\LlmChain\Model\Message\MessageBag;
10
+use PhpLlm\LlmChain\Model\Response\TextResponse;
11
12
+final readonly class Chain
13
+{
14
+ public function __construct(
15
+ private ChainInterface $chain,
16
+ ) {
17
+ }
18
19
+ /**
20
+ * @param string $message the message to pass to the chain
21
+ */
22
+ public function __invoke(string $message): string
23
+ {
24
+ $response = $this->chain->call(new MessageBag(Message::ofUser($message)));
25
26
+ assert($response instanceof TextResponse);
27
28
+ return $response->getContent();
29
30
+}
0 commit comments