Skip to content

Commit

Permalink
Use HasLinkedAgentsInterface interface for linked agents handling
Browse files Browse the repository at this point in the history
  • Loading branch information
butschster committed Sep 6, 2024
1 parent 371ba1c commit 6fc61d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"require": {
"php": "^8.3",
"llm-agents/agents": "^1.2",
"llm-agents/agents": "dev-feature/embeddings as 1.0",
"llm-agents/json-schema-mapper": "^1.0"
},
"require-dev": {
Expand Down
5 changes: 5 additions & 0 deletions src/Interceptors/LinkedAgentsInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down

0 comments on commit 6fc61d8

Please sign in to comment.