diff --git a/composer.json b/composer.json index 9822aec..03fc500 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "license": "MIT", "require": { "php": "^8.3", - "llm-agents/agents": "^1.2", + "llm-agents/agents": "^1.5", "llm-agents/json-schema-mapper": "^1.0" }, "require-dev": { diff --git a/src/Interceptors/LinkedAgentsInjector.php b/src/Interceptors/LinkedAgentsInjector.php index 9769843..cb803f1 100644 --- a/src/Interceptors/LinkedAgentsInjector.php +++ b/src/Interceptors/LinkedAgentsInjector.php @@ -5,6 +5,7 @@ namespace LLM\Agents\PromptGenerator\Interceptors; use LLM\Agents\Agent\AgentRepositoryInterface; +use LLM\Agents\Agent\HasLinkedAgentsInterface; use LLM\Agents\LLM\Prompt\Chat\MessagePrompt; use LLM\Agents\LLM\Prompt\Chat\Prompt; use LLM\Agents\LLM\Prompt\Chat\PromptInterface; @@ -27,6 +28,10 @@ public function generate( ): PromptInterface { \assert($input->prompt instanceof Prompt); + if (!$input->agent instanceof HasLinkedAgentsInterface) { + return $next($input); + } + if (\count($input->agent->getAgents()) === 0) { return $next($input); } diff --git a/src/Interceptors/UserPromptInjector.php b/src/Interceptors/UserPromptInjector.php index 6862a36..3568e15 100644 --- a/src/Interceptors/UserPromptInjector.php +++ b/src/Interceptors/UserPromptInjector.php @@ -4,10 +4,9 @@ namespace LLM\Agents\PromptGenerator\Interceptors; -use LLM\Agents\LLM\Prompt\Chat\ChatMessage; +use LLM\Agents\LLM\Prompt\Chat\MessagePrompt; use LLM\Agents\LLM\Prompt\Chat\Prompt; use LLM\Agents\LLM\Prompt\Chat\PromptInterface; -use LLM\Agents\LLM\Prompt\Chat\Role; use LLM\Agents\PromptGenerator\InterceptorHandler; use LLM\Agents\PromptGenerator\PromptGeneratorInput; use LLM\Agents\PromptGenerator\PromptInterceptorInterface; @@ -23,10 +22,10 @@ public function generate( return $next( input: $input->withPrompt( $input->prompt->withAddedMessage( - new ChatMessage( - content: (string) $input->userPrompt, - role: Role::User, - ), + MessagePrompt::user('{user_prompt}') + ->withValues([ + 'user_prompt' => (string) $input->userPrompt, + ]), ), ), );