Skip to content

Commit 66d46e4

Browse files
committed
ref
1 parent bff6d0c commit 66d46e4

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

.github/workflows/integration-tests.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ jobs:
7575
run: ../link
7676

7777
- name: Run commands examples
78-
run: php examples/commands/stores.php
78+
run: |
79+
php examples/commands/stores.php
80+
php examples/commands/message-stores.php
7981
8082
demo:
8183
runs-on: ubuntu-latest
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
require_once dirname(__DIR__).'/bootstrap.php';
13+
14+
use Symfony\AI\Chat\Bridge\HttpFoundation\SessionStore;
15+
use Symfony\AI\Chat\Bridge\Local\CacheStore;
16+
use Symfony\AI\Chat\Bridge\Local\InMemoryStore;
17+
use Symfony\AI\Chat\Command\DropStoreCommand;
18+
use Symfony\AI\Chat\Command\SetupStoreCommand;
19+
use Symfony\Component\Cache\Adapter\ArrayAdapter;
20+
use Symfony\Component\Console\Application;
21+
use Symfony\Component\Console\Input\ArrayInput;
22+
use Symfony\Component\Console\Output\ConsoleOutput;
23+
use Symfony\Component\DependencyInjection\ServiceLocator;
24+
use Symfony\Component\HttpFoundation\Request;
25+
use Symfony\Component\HttpFoundation\RequestStack;
26+
use Symfony\Component\HttpFoundation\Session\Session;
27+
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
28+
29+
$factories = [
30+
'cache' => static fn (): CacheStore => new CacheStore(new ArrayAdapter(), cacheKey: 'symfony'),
31+
'memory' => static fn (): InMemoryStore => new InMemoryStore('symfony'),
32+
'session' => static function (): SessionStore {
33+
$request = Request::create('/');
34+
$request->setSession(new Session(new MockArraySessionStorage()));
35+
36+
$requestStack = new RequestStack();
37+
$requestStack->push($request);
38+
39+
return new SessionStore($requestStack, 'symfony');
40+
}
41+
];
42+
43+
$storesIds = array_keys($factories);
44+
45+
$application = new Application();
46+
$application->setAutoExit(false);
47+
$application->setCatchExceptions(false);
48+
$application->addCommands([
49+
new SetupStoreCommand(new ServiceLocator($factories)),
50+
new DropStoreCommand(new ServiceLocator($factories)),
51+
]);
52+
53+
foreach ($storesIds as $store) {
54+
$setupOutputCode = $application->run(new ArrayInput([
55+
'command' => 'ai:message-store:setup',
56+
'store' => $store,
57+
]), new ConsoleOutput());
58+
59+
$dropOutputCode = $application->run(new ArrayInput([
60+
'command' => 'ai:message-store:drop',
61+
'store' => $store,
62+
'--force' => true,
63+
]), new ConsoleOutput());
64+
}

0 commit comments

Comments
 (0)