Skip to content

Commit 481e8f2

Browse files
committed
ref
1 parent d9795b7 commit 481e8f2

File tree

10 files changed

+135
-15
lines changed

10 files changed

+135
-15
lines changed

.github/workflows/integration-tests.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ jobs:
5757
MEILI_MASTER_KEY: '${MEILISEARCH_MASTER_KEY:-changeMe}'
5858
ports:
5959
- '7700:7700'
60+
61+
mongodb:
62+
image: mongodb/mongodb-community-server:7.0-ubi9
63+
env:
64+
MONGO_INITDB_ROOT_USERNAME: 'symfony'
65+
MONGO_INITDB_ROOT_PASSWORD: 'symfony'
66+
ports:
67+
- '27017:27017'
6068

6169
qdrant:
6270
image: qdrant/qdrant

examples/.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ BRAVE_API_KEY=
6060
FIRECRAWL_HOST=https://api.firecrawl.dev
6161
FIRECRAWL_API_KEY=
6262

63-
# For using MongoDB Atlas (store)
64-
MONGODB_URI=
63+
# For using MongoDB Atlas / Community Edition (store)
64+
MONGODB_URI=mongodb://symfony:[email protected]:27017
6565

6666
# For using Pinecone (store)
6767
PINECONE_API_KEY=

examples/commands/stores.php

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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 Doctrine\DBAL\DriverManager;
15+
use Doctrine\DBAL\Tools\DsnParser;
16+
use MongoDB\Client as MongoDbClient;
17+
use Symfony\AI\Store\Bridge\Local\CacheStore;
18+
use Symfony\AI\Store\Bridge\Local\InMemoryStore;
19+
use Symfony\AI\Store\Bridge\MariaDb\Store as MariaDbStore;
20+
use Symfony\AI\Store\Bridge\Milvus\Store as MilvusStore;
21+
use Symfony\AI\Store\Bridge\Meilisearch\Store as MeilisearchStore;
22+
use Symfony\AI\Store\Bridge\MongoDb\Store as MongoDbStore;
23+
use Symfony\AI\Store\Bridge\Postgres\Store as PostgresStore;
24+
use Symfony\AI\Store\Bridge\Qdrant\Store as QdrantStore;
25+
use Symfony\AI\Store\Bridge\SurrealDb\Store as SurrealDbStore;
26+
use Symfony\AI\Store\Bridge\Typesense\Store as TypesenseStore;
27+
use Symfony\AI\Store\Command\DropStoreCommand;
28+
use Symfony\AI\Store\Command\SetupStoreCommand;
29+
use Symfony\Component\Cache\Adapter\ArrayAdapter;
30+
use Symfony\Component\Console\Application;
31+
use Symfony\Component\Console\Input\ArrayInput;
32+
use Symfony\Component\Console\Output\ConsoleOutput;
33+
use Symfony\Component\DependencyInjection\ServiceLocator;
34+
35+
$factories = [
36+
'cache' => static fn (): CacheStore => new CacheStore(new ArrayAdapter()),
37+
'mariadb' => static fn (): MariaDbStore => MariaDbStore::fromDbal(
38+
connection: DriverManager::getConnection((new DsnParser())->parse(env('MARIADB_URI'))),
39+
tableName: 'my_table_openai',
40+
indexName: 'my_index',
41+
),
42+
'memory' => static fn (): InMemoryStore => new InMemoryStore(),
43+
'meilisearch' => static fn (): MeilisearchStore => new MeilisearchStore(
44+
httpClient: http_client(),
45+
endpointUrl: env('MEILISEARCH_HOST'),
46+
apiKey: env('MEILISEARCH_API_KEY'),
47+
indexName: '_commands',
48+
),
49+
'milvus' => static fn (): MilvusStore => new MilvusStore(
50+
httpClient: http_client(),
51+
endpointUrl: env('MILVUS_HOST'),
52+
apiKey: env('MILVUS_API_KEY'),
53+
database: env('MILVUS_DATABASE'),
54+
collection: '_commands',
55+
),
56+
'mongodb' => static fn (): MongoDbStore => new MongoDbStore(
57+
client: new MongoDbClient(env('MONGODB_URI')),
58+
databaseName: 'my-database',
59+
collectionName: 'my-collection',
60+
indexName: 'my-index',
61+
vectorFieldName: 'vector',
62+
),
63+
'postgres' => static fn (): PostgresStore => PostgresStore::fromDbal(
64+
connection: DriverManager::getConnection((new DsnParser())->parse(env('POSTGRES_URI'))),
65+
tableName: 'my_table',
66+
),
67+
'qdrant' => static fn (): QdrantStore => new QdrantStore(
68+
http_client(),
69+
env('QDRANT_HOST'),
70+
env('QDRANT_SERVICE_API_KEY'),
71+
'_commands',
72+
),
73+
'surrealdb' => static fn (): SurrealDbStore => new SurrealDbStore(
74+
httpClient: http_client(),
75+
endpointUrl: env('SURREALDB_HOST'),
76+
user: env('SURREALDB_USER'),
77+
password: env('SURREALDB_PASS'),
78+
namespace: 'default',
79+
database: '_commands',
80+
table: '_commands',
81+
),
82+
'typesense' => static fn (): TypesenseStore => new TypesenseStore(
83+
httpClient: http_client(),
84+
endpointUrl: env('TYPESENSE_HOST'),
85+
apiKey: env('TYPESENSE_API_KEY'),
86+
collection: '_commands',
87+
),
88+
];
89+
90+
$storesIds = array_keys($factories);
91+
92+
$application = new Application();
93+
$application->setAutoExit(false);
94+
$application->add(new SetupStoreCommand(new ServiceLocator($factories), $storesIds));
95+
$application->add(new DropStoreCommand(new ServiceLocator($factories), $storesIds));
96+
97+
foreach ($storesIds as $store) {
98+
$application->run(new ArrayInput([
99+
'command' => 'ai:store:setup',
100+
'store' => $store,
101+
]), new ConsoleOutput());
102+
103+
$application->run(new ArrayInput([
104+
'command' => 'ai:store:drop',
105+
'store' => $store,
106+
]), new ConsoleOutput());
107+
}

examples/compose.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ services:
2323
ports:
2424
- '7700:7700'
2525

26+
mongodb:
27+
image: mongodb/mongodb-community-server:7.0-ubi9
28+
environment:
29+
MONGO_INITDB_ROOT_USERNAME: 'symfony'
30+
MONGO_INITDB_ROOT_PASSWORD: 'symfony'
31+
ports:
32+
- '27017:27017'
33+
2634
qdrant:
2735
image: qdrant/qdrant
2836
environment:
@@ -67,7 +75,7 @@ services:
6775
ports:
6876
- '8001:8000'
6977

70-
# Milvus services
78+
# Milvus services
7179
etcd:
7280
container_name: milvus-etcd
7381
image: quay.io/coreos/etcd:v3.5.18
@@ -91,9 +99,6 @@ services:
9199
environment:
92100
MINIO_ACCESS_KEY: minioadmin
93101
MINIO_SECRET_KEY: minioadmin
94-
ports:
95-
- '9001:9001'
96-
- '9000:9000'
97102
volumes:
98103
- minio_vlm:/minio_data
99104
command: minio server /minio_data --console-address ":9001"

examples/composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,9 @@
3838
"php-http/discovery": true
3939
},
4040
"sort-packages": true
41+
},
42+
"require-dev": {
43+
"mongodb/mongodb": "^2.1",
44+
"symfony/dependency-injection": "^7.3"
4145
}
4246
}

examples/rag/meilisearch.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@
2424
use Symfony\AI\Store\Document\TextDocument;
2525
use Symfony\AI\Store\Document\Vectorizer;
2626
use Symfony\AI\Store\Indexer;
27-
use Symfony\Component\HttpClient\HttpClient;
2827
use Symfony\Component\Uid\Uuid;
2928

3029
require_once dirname(__DIR__).'/bootstrap.php';
3130

3231
// initialize the store
3332
$store = new Store(
34-
httpClient: HttpClient::create(),
33+
httpClient: http_client(),
3534
endpointUrl: env('MEILISEARCH_HOST'),
3635
apiKey: env('MEILISEARCH_API_KEY'),
3736
indexName: 'movies',

examples/rag/milvus.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
);
3939

4040
// initialize the index
41-
$store->initialize();
41+
$store->setup();
4242

4343
// create embeddings and documents
4444
$documents = [];

examples/rag/neo4j.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@
2424
use Symfony\AI\Store\Document\TextDocument;
2525
use Symfony\AI\Store\Document\Vectorizer;
2626
use Symfony\AI\Store\Indexer;
27-
use Symfony\Component\HttpClient\HttpClient;
2827
use Symfony\Component\Uid\Uuid;
2928

3029
require_once dirname(__DIR__).'/bootstrap.php';
3130

3231
// initialize the store
3332
$store = new Store(
34-
httpClient: HttpClient::create(),
33+
httpClient: http_client(),
3534
endpointUrl: env('NEO4J_HOST'),
3635
username: env('NEO4J_USERNAME'),
3736
password: env('NEO4J_PASSWORD'),

examples/rag/qdrant.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@
2424
use Symfony\AI\Store\Document\TextDocument;
2525
use Symfony\AI\Store\Document\Vectorizer;
2626
use Symfony\AI\Store\Indexer;
27-
use Symfony\Component\HttpClient\HttpClient;
2827
use Symfony\Component\Uid\Uuid;
2928

3029
require_once dirname(__DIR__).'/bootstrap.php';
3130

3231
// initialize the store
3332
$store = new Store(
34-
HttpClient::create(),
33+
http_client(),
3534
env('QDRANT_HOST'),
3635
env('QDRANT_SERVICE_API_KEY'),
3736
'movies',

examples/rag/surrealdb.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@
2424
use Symfony\AI\Store\Document\TextDocument;
2525
use Symfony\AI\Store\Document\Vectorizer;
2626
use Symfony\AI\Store\Indexer;
27-
use Symfony\Component\HttpClient\HttpClient;
2827
use Symfony\Component\Uid\Uuid;
2928

3029
require_once dirname(__DIR__).'/bootstrap.php';
3130

3231
// initialize the store
3332
$store = new Store(
34-
httpClient: HttpClient::create(),
33+
httpClient: http_client(),
3534
endpointUrl: env('SURREALDB_HOST'),
3635
user: env('SURREALDB_USER'),
3736
password: env('SURREALDB_PASS'),

0 commit comments

Comments
 (0)