diff --git a/README.md b/README.md index a78ec32..76ca64f 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ llm_chain: name: 'GPT' version: 'gpt-4o-mini' system_prompt: 'You are a helpful assistant that can answer questions.' # The default system prompt of the chain + include_tools: true # Include tool definitions at the end of the system prompt tools: - 'PhpLlm\LlmChain\Chain\ToolBox\Tool\SimilaritySearch' research: diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index aea4c96..5e0feed 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -77,6 +77,10 @@ public function getConfigTreeBuilder(): TreeBuilder ->defaultNull() ->info('The default system prompt of the chain') ->end() + ->booleanNode('include_tools') + ->info('Include tool definitions at the end of the system prompt') + ->defaultFalse() + ->end() ->arrayNode('tools') ->addDefaultsIfNotSet() ->treatFalseLike(['enabled' => false]) diff --git a/src/DependencyInjection/LlmChainExtension.php b/src/DependencyInjection/LlmChainExtension.php index 12706e1..cd0ef6b 100644 --- a/src/DependencyInjection/LlmChainExtension.php +++ b/src/DependencyInjection/LlmChainExtension.php @@ -296,6 +296,11 @@ private function processChainConfig(string $name, array $config, ContainerBuilde ->setAutowired(true) ->setArgument('$systemPrompt', $config['system_prompt']); + if ($config['include_tools']) { + $systemPromptInputProcessorDefinition + ->setArgument('$toolBox', new Reference('llm_chain.toolbox.'.$name)); + } + $inputProcessors[] = $systemPromptInputProcessorDefinition; }