diff --git a/composer.json b/composer.json index a6a1528..d2783ff 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "ext-iconv": "*", "codewithkyrian/chromadb-php": "^0.3.0", "league/commonmark": "^2.6", - "php-llm/llm-chain-bundle": "^0.12", + "php-llm/llm-chain-bundle": "^0.13", "phpdocumentor/reflection-docblock": "^5.5", "phpstan/phpdoc-parser": "^1.33", "runtime/frankenphp-symfony": "^0.2.0", diff --git a/composer.lock b/composer.lock index 997aa28..b8acaf9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "361b524e4d42d6082c809c4755d2a03e", + "content-hash": "75f4aff9c33ddc3f384eba32a38dbaad", "packages": [ { "name": "codewithkyrian/chromadb-php", @@ -1146,16 +1146,16 @@ }, { "name": "php-llm/llm-chain", - "version": "0.11", + "version": "0.13.0", "source": { "type": "git", "url": "https://github.com/php-llm/llm-chain.git", - "reference": "f064e67a10ae8c0f24ed13da022dd30a7a878a50" + "reference": "04edf87c9881b609971aaa96eb82c5fba4b36050" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-llm/llm-chain/zipball/f064e67a10ae8c0f24ed13da022dd30a7a878a50", - "reference": "f064e67a10ae8c0f24ed13da022dd30a7a878a50", + "url": "https://api.github.com/repos/php-llm/llm-chain/zipball/04edf87c9881b609971aaa96eb82c5fba4b36050", + "reference": "04edf87c9881b609971aaa96eb82c5fba4b36050", "shasum": "" }, "require": { @@ -1190,6 +1190,7 @@ "symfony/css-selector": "^6.4 || ^7.1", "symfony/dom-crawler": "^6.4 || ^7.1", "symfony/dotenv": "^6.4 || ^7.1", + "symfony/event-dispatcher": "^6.4 || ^7.1", "symfony/finder": "^6.4 || ^7.1", "symfony/process": "^6.4 || ^7.1", "symfony/var-dumper": "^6.4 || ^7.1" @@ -1220,27 +1221,27 @@ "description": "A slim PHP component with tooling around LLMs.", "support": { "issues": "https://github.com/php-llm/llm-chain/issues", - "source": "https://github.com/php-llm/llm-chain/tree/0.11" + "source": "https://github.com/php-llm/llm-chain/tree/0.13.0" }, - "time": "2024-12-28T22:43:20+00:00" + "time": "2025-01-05T15:40:45+00:00" }, { "name": "php-llm/llm-chain-bundle", - "version": "0.12.0", + "version": "0.13.0", "source": { "type": "git", "url": "https://github.com/php-llm/llm-chain-bundle.git", - "reference": "f11f24578053ed2d430bf27f89022c6024d6bf09" + "reference": "4bbfd7eba201bd7af5dcd7a774c10a7dee852ded" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-llm/llm-chain-bundle/zipball/f11f24578053ed2d430bf27f89022c6024d6bf09", - "reference": "f11f24578053ed2d430bf27f89022c6024d6bf09", + "url": "https://api.github.com/repos/php-llm/llm-chain-bundle/zipball/4bbfd7eba201bd7af5dcd7a774c10a7dee852ded", + "reference": "4bbfd7eba201bd7af5dcd7a774c10a7dee852ded", "shasum": "" }, "require": { "php": ">=8.2", - "php-llm/llm-chain": "^0.11", + "php-llm/llm-chain": "^0.13", "symfony/config": "^6.4 || ^7.0", "symfony/dependency-injection": "^6.4 || ^7.0", "symfony/framework-bundle": "^6.4 || ^7.0" @@ -1269,9 +1270,9 @@ "description": "Symfony integration bundle for php-llm/llm-chain", "support": { "issues": "https://github.com/php-llm/llm-chain-bundle/issues", - "source": "https://github.com/php-llm/llm-chain-bundle/tree/0.12.0" + "source": "https://github.com/php-llm/llm-chain-bundle/tree/0.13.0" }, - "time": "2024-12-30T16:17:45+00:00" + "time": "2025-01-05T16:10:04+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -3217,16 +3218,16 @@ }, { "name": "symfony/finder", - "version": "v7.2.0", + "version": "v7.2.2", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "6de263e5868b9a137602dd1e33e4d48bfae99c49" + "reference": "87a71856f2f56e4100373e92529eed3171695cfb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/6de263e5868b9a137602dd1e33e4d48bfae99c49", - "reference": "6de263e5868b9a137602dd1e33e4d48bfae99c49", + "url": "https://api.github.com/repos/symfony/finder/zipball/87a71856f2f56e4100373e92529eed3171695cfb", + "reference": "87a71856f2f56e4100373e92529eed3171695cfb", "shasum": "" }, "require": { @@ -3261,7 +3262,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v7.2.0" + "source": "https://github.com/symfony/finder/tree/v7.2.2" }, "funding": [ { @@ -3277,7 +3278,7 @@ "type": "tidelift" } ], - "time": "2024-10-23T06:56:12+00:00" + "time": "2024-12-30T19:00:17+00:00" }, { "name": "symfony/flex", @@ -3349,16 +3350,16 @@ }, { "name": "symfony/framework-bundle", - "version": "v7.2.1", + "version": "v7.2.2", "source": { "type": "git", "url": "https://github.com/symfony/framework-bundle.git", - "reference": "1c630f4697c9bd87b342e8090cc9022071af4d77" + "reference": "aaf86f38b483ce101c7e60be050bc0140431cfe2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/framework-bundle/zipball/1c630f4697c9bd87b342e8090cc9022071af4d77", - "reference": "1c630f4697c9bd87b342e8090cc9022071af4d77", + "url": "https://api.github.com/repos/symfony/framework-bundle/zipball/aaf86f38b483ce101c7e60be050bc0140431cfe2", + "reference": "aaf86f38b483ce101c7e60be050bc0140431cfe2", "shasum": "" }, "require": { @@ -3479,7 +3480,7 @@ "description": "Provides a tight integration between Symfony components and the Symfony full-stack framework", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/framework-bundle/tree/v7.2.1" + "source": "https://github.com/symfony/framework-bundle/tree/v7.2.2" }, "funding": [ { @@ -3495,20 +3496,20 @@ "type": "tidelift" } ], - "time": "2024-12-07T13:24:01+00:00" + "time": "2024-12-19T14:25:03+00:00" }, { "name": "symfony/http-client", - "version": "v7.2.1", + "version": "v7.2.2", "source": { "type": "git", "url": "https://github.com/symfony/http-client.git", - "reference": "ff4df2b68d1c67abb9fef146e6540ea16b58d99e" + "reference": "339ba21476eb184290361542f732ad12c97591ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client/zipball/ff4df2b68d1c67abb9fef146e6540ea16b58d99e", - "reference": "ff4df2b68d1c67abb9fef146e6540ea16b58d99e", + "url": "https://api.github.com/repos/symfony/http-client/zipball/339ba21476eb184290361542f732ad12c97591ec", + "reference": "339ba21476eb184290361542f732ad12c97591ec", "shasum": "" }, "require": { @@ -3574,7 +3575,7 @@ "http" ], "support": { - "source": "https://github.com/symfony/http-client/tree/v7.2.1" + "source": "https://github.com/symfony/http-client/tree/v7.2.2" }, "funding": [ { @@ -3590,7 +3591,7 @@ "type": "tidelift" } ], - "time": "2024-12-07T08:50:44+00:00" + "time": "2024-12-30T18:35:15+00:00" }, { "name": "symfony/http-client-contracts", @@ -3672,16 +3673,16 @@ }, { "name": "symfony/http-foundation", - "version": "v7.2.0", + "version": "v7.2.2", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "e88a66c3997859532bc2ddd6dd8f35aba2711744" + "reference": "62d1a43796ca3fea3f83a8470dfe63a4af3bc588" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/e88a66c3997859532bc2ddd6dd8f35aba2711744", - "reference": "e88a66c3997859532bc2ddd6dd8f35aba2711744", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/62d1a43796ca3fea3f83a8470dfe63a4af3bc588", + "reference": "62d1a43796ca3fea3f83a8470dfe63a4af3bc588", "shasum": "" }, "require": { @@ -3730,7 +3731,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v7.2.0" + "source": "https://github.com/symfony/http-foundation/tree/v7.2.2" }, "funding": [ { @@ -3746,20 +3747,20 @@ "type": "tidelift" } ], - "time": "2024-11-13T18:58:46+00:00" + "time": "2024-12-30T19:00:17+00:00" }, { "name": "symfony/http-kernel", - "version": "v7.2.1", + "version": "v7.2.2", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "d8ae58eecae44c8e66833e76cc50a4ad3c002d97" + "reference": "3c432966bd8c7ec7429663105f5a02d7e75b4306" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/d8ae58eecae44c8e66833e76cc50a4ad3c002d97", - "reference": "d8ae58eecae44c8e66833e76cc50a4ad3c002d97", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/3c432966bd8c7ec7429663105f5a02d7e75b4306", + "reference": "3c432966bd8c7ec7429663105f5a02d7e75b4306", "shasum": "" }, "require": { @@ -3844,7 +3845,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v7.2.1" + "source": "https://github.com/symfony/http-kernel/tree/v7.2.2" }, "funding": [ { @@ -3860,7 +3861,7 @@ "type": "tidelift" } ], - "time": "2024-12-11T12:09:10+00:00" + "time": "2024-12-31T14:59:40+00:00" }, { "name": "symfony/monolog-bridge", @@ -4337,22 +4338,22 @@ }, { "name": "symfony/property-info", - "version": "v7.2.1", + "version": "v7.2.2", "source": { "type": "git", "url": "https://github.com/symfony/property-info.git", - "reference": "65fb9be15380f949d72ff405473cce733364b8b4" + "reference": "1dfeb0dac7a99f7b3be42db9ccc299c5a6483fcf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/property-info/zipball/65fb9be15380f949d72ff405473cce733364b8b4", - "reference": "65fb9be15380f949d72ff405473cce733364b8b4", + "url": "https://api.github.com/repos/symfony/property-info/zipball/1dfeb0dac7a99f7b3be42db9ccc299c5a6483fcf", + "reference": "1dfeb0dac7a99f7b3be42db9ccc299c5a6483fcf", "shasum": "" }, "require": { "php": ">=8.2", "symfony/string": "^6.4|^7.0", - "symfony/type-info": "^7.1" + "symfony/type-info": "~7.1.9|^7.2.2" }, "conflict": { "phpdocumentor/reflection-docblock": "<5.2", @@ -4400,7 +4401,7 @@ "validator" ], "support": { - "source": "https://github.com/symfony/property-info/tree/v7.2.1" + "source": "https://github.com/symfony/property-info/tree/v7.2.2" }, "funding": [ { @@ -4416,7 +4417,7 @@ "type": "tidelift" } ], - "time": "2024-12-07T08:50:44+00:00" + "time": "2024-12-31T11:04:50+00:00" }, { "name": "symfony/routing", @@ -4995,16 +4996,16 @@ }, { "name": "symfony/twig-bridge", - "version": "v7.2.1", + "version": "v7.2.2", "source": { "type": "git", "url": "https://github.com/symfony/twig-bridge.git", - "reference": "d5cdf4d59da5ab44ebd7503480c22d8235887de0" + "reference": "29e4c66de9618e67dc1f5f13bc667aca2a228f1e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/twig-bridge/zipball/d5cdf4d59da5ab44ebd7503480c22d8235887de0", - "reference": "d5cdf4d59da5ab44ebd7503480c22d8235887de0", + "url": "https://api.github.com/repos/symfony/twig-bridge/zipball/29e4c66de9618e67dc1f5f13bc667aca2a228f1e", + "reference": "29e4c66de9618e67dc1f5f13bc667aca2a228f1e", "shasum": "" }, "require": { @@ -5085,7 +5086,7 @@ "description": "Provides integration for Twig with various Symfony components", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/twig-bridge/tree/v7.2.1" + "source": "https://github.com/symfony/twig-bridge/tree/v7.2.2" }, "funding": [ { @@ -5101,7 +5102,7 @@ "type": "tidelift" } ], - "time": "2024-12-07T09:50:32+00:00" + "time": "2024-12-19T14:25:03+00:00" }, { "name": "symfony/twig-bundle", @@ -5189,16 +5190,16 @@ }, { "name": "symfony/type-info", - "version": "v7.2.1", + "version": "v7.2.2", "source": { "type": "git", "url": "https://github.com/symfony/type-info.git", - "reference": "4f402070b08ad0b87e9cadbb07b87fb36061e6e4" + "reference": "3b5a17470fff0034f25fd4287cbdaa0010d2f749" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/type-info/zipball/4f402070b08ad0b87e9cadbb07b87fb36061e6e4", - "reference": "4f402070b08ad0b87e9cadbb07b87fb36061e6e4", + "url": "https://api.github.com/repos/symfony/type-info/zipball/3b5a17470fff0034f25fd4287cbdaa0010d2f749", + "reference": "3b5a17470fff0034f25fd4287cbdaa0010d2f749", "shasum": "" }, "require": { @@ -5244,7 +5245,7 @@ "type" ], "support": { - "source": "https://github.com/symfony/type-info/tree/v7.2.1" + "source": "https://github.com/symfony/type-info/tree/v7.2.2" }, "funding": [ { @@ -5260,7 +5261,7 @@ "type": "tidelift" } ], - "time": "2024-12-11T07:49:41+00:00" + "time": "2024-12-20T13:38:37+00:00" }, { "name": "symfony/uid", @@ -6579,16 +6580,16 @@ }, { "name": "php-cs-fixer/shim", - "version": "v3.66.0", + "version": "v3.66.1", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/shim.git", - "reference": "6824b91b16d2e123afed9bf9c96ec283882346c9" + "reference": "5e56b2f7a19b1a88f745bbbc6be452bb5336eb07" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/6824b91b16d2e123afed9bf9c96ec283882346c9", - "reference": "6824b91b16d2e123afed9bf9c96ec283882346c9", + "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/5e56b2f7a19b1a88f745bbbc6be452bb5336eb07", + "reference": "5e56b2f7a19b1a88f745bbbc6be452bb5336eb07", "shasum": "" }, "require": { @@ -6625,22 +6626,22 @@ "description": "A tool to automatically fix PHP code style", "support": { "issues": "https://github.com/PHP-CS-Fixer/shim/issues", - "source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.66.0" + "source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.66.1" }, - "time": "2024-12-29T13:46:48+00:00" + "time": "2025-01-05T14:43:53+00:00" }, { "name": "phpstan/phpstan", - "version": "2.0.4", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "50d276fc3bf1430ec315f2f109bbde2769821524" + "reference": "2392d360fdf54ea253aa6c68cad1d4ba2e54e927" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/50d276fc3bf1430ec315f2f109bbde2769821524", - "reference": "50d276fc3bf1430ec315f2f109bbde2769821524", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/2392d360fdf54ea253aa6c68cad1d4ba2e54e927", + "reference": "2392d360fdf54ea253aa6c68cad1d4ba2e54e927", "shasum": "" }, "require": { @@ -6685,7 +6686,7 @@ "type": "github" } ], - "time": "2024-12-17T17:14:01+00:00" + "time": "2024-12-31T07:30:03+00:00" }, { "name": "phpunit/php-code-coverage", @@ -8230,16 +8231,16 @@ }, { "name": "symfony/stopwatch", - "version": "v7.2.0", + "version": "v7.2.2", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "696f418b0d722a4225e1c3d95489d262971ca924" + "reference": "e46690d5b9d7164a6d061cab1e8d46141b9f49df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/696f418b0d722a4225e1c3d95489d262971ca924", - "reference": "696f418b0d722a4225e1c3d95489d262971ca924", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/e46690d5b9d7164a6d061cab1e8d46141b9f49df", + "reference": "e46690d5b9d7164a6d061cab1e8d46141b9f49df", "shasum": "" }, "require": { @@ -8272,7 +8273,7 @@ "description": "Provides a way to profile code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/stopwatch/tree/v7.2.0" + "source": "https://github.com/symfony/stopwatch/tree/v7.2.2" }, "funding": [ { @@ -8288,20 +8289,20 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:21:43+00:00" + "time": "2024-12-18T14:28:33+00:00" }, { "name": "symfony/web-profiler-bundle", - "version": "v7.2.0", + "version": "v7.2.2", "source": { "type": "git", "url": "https://github.com/symfony/web-profiler-bundle.git", - "reference": "8843019fa7140a4aa079f1a8d71fd010f61de5f2" + "reference": "5d37d9bd86ab49bd94c57e18e601e27fb6760f2c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/web-profiler-bundle/zipball/8843019fa7140a4aa079f1a8d71fd010f61de5f2", - "reference": "8843019fa7140a4aa079f1a8d71fd010f61de5f2", + "url": "https://api.github.com/repos/symfony/web-profiler-bundle/zipball/5d37d9bd86ab49bd94c57e18e601e27fb6760f2c", + "reference": "5d37d9bd86ab49bd94c57e18e601e27fb6760f2c", "shasum": "" }, "require": { @@ -8354,7 +8355,7 @@ "dev" ], "support": { - "source": "https://github.com/symfony/web-profiler-bundle/tree/v7.2.0" + "source": "https://github.com/symfony/web-profiler-bundle/tree/v7.2.2" }, "funding": [ { @@ -8370,7 +8371,7 @@ "type": "tidelift" } ], - "time": "2024-11-19T10:12:55+00:00" + "time": "2024-12-11T15:34:14+00:00" }, { "name": "theseer/tokenizer", diff --git a/config/packages/llm_chain.yaml b/config/packages/llm_chain.yaml index 79e086b..149c13c 100644 --- a/config/packages/llm_chain.yaml +++ b/config/packages/llm_chain.yaml @@ -34,6 +34,7 @@ llm_chain: version: 'gpt-4o-mini' options: temperature: 0.5 + system_prompt: 'Please answer the users question based on Wikipedia and provide a link to the article.' tools: - 'PhpLlm\LlmChain\Chain\ToolBox\Tool\Wikipedia' store: diff --git a/src/Wikipedia/Chat.php b/src/Wikipedia/Chat.php index 4e2316b..158be08 100644 --- a/src/Wikipedia/Chat.php +++ b/src/Wikipedia/Chat.php @@ -24,11 +24,7 @@ public function __construct( public function loadMessages(): MessageBag { - $default = new MessageBag( - Message::forSystem('Please answer the users question based on Wikipedia and provide a link to the article.') - ); - - return $this->requestStack->getSession()->get(self::SESSION_KEY, $default); + return $this->requestStack->getSession()->get(self::SESSION_KEY, new MessageBag()); } public function submitMessage(string $message): void