@@ -51,9 +51,9 @@ llm_chain:
5151 api_version : ' 2024-07-01'
5252` ` `
5353
54- ## Features
54+ ## Usage
5555
56- ### Simple Chat
56+ ### Chain Service
5757
5858Use the simple chat service to leverage GPT:
5959` ` ` php
@@ -62,7 +62,7 @@ use PhpLlm\LlmChain\Chat;
6262final readonly class MyService
6363{
6464 public function __construct(
65- private Chat $chat ,
65+ private Chain $chain ,
6666 ) {
6767 }
6868
@@ -72,39 +72,14 @@ final readonly class MyService
7272 $messages[] = Message::forSystem('Speak like a pirate.');
7373 $messages[] = Message::ofUser($message);
7474
75- return $this->chat->send ($messages);
75+ return $this->chain->call ($messages);
7676 }
7777}
7878```
7979
80- ### Tool Chain
80+ ### Register Tools
8181
82- Use the tool chain service to leverage tool calling with GPT:
83- ``` php
84- use PhpLlm\LlmChain\Message\Message;
85- use PhpLlm\LlmChain\Message\MessageBag;
86- use PhpLlm\LlmChain\ToolChain;
87-
88- final readonly class MyService
89- {
90- public function __construct(
91- private ToolChain $toolChain,
92- ) {
93- }
94-
95- public function processMessage(string $message): void
96- {
97- $messages = $this->loadMessageBag();
98- $messages[] = Message::ofUser($message);
99-
100- $response = $this->toolChain->call($messages);
101- $messages[] = Message::ofAssistant($response);
102-
103- $this->saveMessages($messages);
104- }
105- }
106- ```
107- Extend the tool chain service to add your own tools:
82+ You can register tools by using the ` AsTool ` attribute and enable the chain to execute it:
10883``` php
10984use PhpLlm\LlmChain\ToolBox\AsTool;
11085
@@ -120,4 +95,6 @@ final class CompanyName
12095
12196### Profiler
12297
98+ The profiler panel provides insights into the chain's execution:
99+
123100![ Profiler] ( ./profiler.png )
0 commit comments