From 1221fb299a3bff121c52f1840bfecccdb93e7146 Mon Sep 17 00:00:00 2001 From: Pavel Buchnev Date: Wed, 4 Sep 2024 22:09:00 +0400 Subject: [PATCH] Fixes problem with Agent executor --- src/Agent/AgentExecutor.php | 8 +++++--- src/LLM/Prompt/Context.php | 12 ++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 src/LLM/Prompt/Context.php diff --git a/src/Agent/AgentExecutor.php b/src/Agent/AgentExecutor.php index 417bb78..4828c15 100644 --- a/src/Agent/AgentExecutor.php +++ b/src/Agent/AgentExecutor.php @@ -11,7 +11,9 @@ use LLM\Agents\LLM\OptionsFactoryInterface; use LLM\Agents\LLM\OptionsInterface; use LLM\Agents\LLM\Prompt\Chat\Prompt; +use LLM\Agents\LLM\Prompt\Context; use LLM\Agents\LLM\Prompt\Tool; +use LLM\Agents\LLM\PromptContextInterface; use LLM\Agents\LLM\Response\ChatResponse; use LLM\Agents\LLM\Response\ToolCalledResponse; use LLM\Agents\Solution\ToolLink; @@ -36,14 +38,14 @@ public function execute( string|\Stringable|Prompt $prompt, ?ContextInterface $context = null, ?OptionsInterface $options = null, - ?array $sessionContext = null, + PromptContextInterface $promptContext = new Context(), ): Execution { $agent = $this->agents->get($agent); $context ??= $this->contextFactory->create(); - if (! $prompt instanceof Prompt) { - $prompt = $this->promptGenerator->generate($agent, $prompt, $sessionContext); + if (!$prompt instanceof Prompt) { + $prompt = $this->promptGenerator->generate($agent, $prompt, $promptContext); } $model = $agent->getModel(); diff --git a/src/LLM/Prompt/Context.php b/src/LLM/Prompt/Context.php new file mode 100644 index 0000000..b4c2c60 --- /dev/null +++ b/src/LLM/Prompt/Context.php @@ -0,0 +1,12 @@ +