Chat with Summary
Overview¶
Example¶
```php
script()->section('main')->appendMessage($startMessage); for($i = 0; $i < $maxSteps; $i++) { $chat->script() ->section('system') ->withMessages(Messages::fromString($sys[$i % 2], 'system')); $chat->script() ->section('context') ->withMessages(Messages::fromString($context, 'system')); $messages = $chat->script() ->select(['system', 'context', 'summary', 'buffer', 'main']) ->toMessages() ->remapRoles(['assistant' => 'user', 'user' => 'assistant', 'system' => 'system']); $response = (new Inference) ->using('deepseek') ->with( messages: $messages->toArray(), options: ['max_tokens' => 256], ) ->get(); echo "\n"; dump('>>> '.$response); echo "\n"; $chat->appendMessage(new Message(role: 'assistant', content: $response), 'main'); } //dump($chat->script()); ?>