Skip to content

Commit 48e1850

Browse files
authored
feat: support include tools feature to system prompt (#68)
1 parent 34c0838 commit 48e1850

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ llm_chain:
4848
name: 'GPT'
4949
version: 'gpt-4o-mini'
5050
system_prompt: 'You are a helpful assistant that can answer questions.' # The default system prompt of the chain
51+
include_tools: true # Include tool definitions at the end of the system prompt
5152
tools:
5253
- 'PhpLlm\LlmChain\Chain\ToolBox\Tool\SimilaritySearch'
5354
research:

src/DependencyInjection/Configuration.php

+4
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ public function getConfigTreeBuilder(): TreeBuilder
7777
->defaultNull()
7878
->info('The default system prompt of the chain')
7979
->end()
80+
->booleanNode('include_tools')
81+
->info('Include tool definitions at the end of the system prompt')
82+
->defaultFalse()
83+
->end()
8084
->arrayNode('tools')
8185
->addDefaultsIfNotSet()
8286
->treatFalseLike(['enabled' => false])

src/DependencyInjection/LlmChainExtension.php

+5
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ private function processChainConfig(string $name, array $config, ContainerBuilde
296296
->setAutowired(true)
297297
->setArgument('$systemPrompt', $config['system_prompt']);
298298

299+
if ($config['include_tools']) {
300+
$systemPromptInputProcessorDefinition
301+
->setArgument('$toolBox', new Reference('llm_chain.toolbox.'.$name));
302+
}
303+
299304
$inputProcessors[] = $systemPromptInputProcessorDefinition;
300305
}
301306

0 commit comments

Comments
 (0)