From 890f0515bbc16c60a0008112502b04dbf43d325e Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Thu, 6 Mar 2025 16:38:45 +0100 Subject: [PATCH 1/2] Add new option `include_tools` --- src/DependencyInjection/Configuration.php | 4 ++++ src/DependencyInjection/LlmChainExtension.php | 5 +++++ 2 files changed, 9 insertions(+) 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; } From bac706e0fd09def06e24c80b43945aaa79ed7749 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Fri, 7 Mar 2025 11:13:33 +0100 Subject: [PATCH 2/2] - --- README.md | 1 + 1 file changed, 1 insertion(+) 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: