Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 12422a4

Browse files
committed
-
1 parent 303a14e commit 12422a4

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/Chain/InputProcessor/SystemPromptInputProcessor.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@
1717
public function __construct(
1818
private string $systemPrompt,
1919
private ?ToolBoxInterface $toolBox = null,
20-
private bool $includeTools = false,
2120
private LoggerInterface $logger = new NullLogger(),
2221
) {
23-
if ($includeTools && null === $toolBox) {
24-
throw new \InvalidArgumentException('Tool definitions cannot be included without a ToolBox.');
25-
}
2622
}
2723

2824
public function processInput(Input $input): void
@@ -37,7 +33,11 @@ public function processInput(Input $input): void
3733

3834
$message = $this->systemPrompt;
3935

40-
if ($this->includeTools) {
36+
if ($this->toolBox instanceof ToolBoxInterface
37+
&& [] !== $this->toolBox->getMap()
38+
) {
39+
$this->logger->debug('Append tool definitions to system prompt.');
40+
4141
$tools = implode(PHP_EOL.PHP_EOL, array_map(
4242
fn (Metadata $tool) => <<<TOOL
4343
## {$tool->name}

tests/Chain/InputProcessor/SystemPromptInputProcessorTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public function needsToolboxToBeAbleToIncludeToolDefinitions(): void
7777
new SystemPromptInputProcessor(
7878
'This is a system prompt',
7979
toolBox: null,
80-
includeTools: true,
8180
);
8281
}
8382

@@ -95,9 +94,9 @@ public function getMap(): array
9594
ToolRequiredParams::class,
9695
'tool_required_params',
9796
<<<DESCRIPTION
98-
A tool with required parameters
99-
or not
100-
DESCRIPTION,
97+
A tool with required parameters
98+
or not
99+
DESCRIPTION,
101100
'bar',
102101
null
103102
),
@@ -108,8 +107,7 @@ public function execute(ToolCall $toolCall): mixed
108107
{
109108
return null;
110109
}
111-
},
112-
includeTools: true,
110+
}
113111
);
114112

115113
$input = new Input(new GPT(), new MessageBag(Message::ofUser('This is a user message')), []);

0 commit comments

Comments
 (0)