Skip to content

Commit a06d4e5

Browse files
committed
docs: split into components
1 parent 500970c commit a06d4e5

File tree

3 files changed

+112
-1
lines changed

3 files changed

+112
-1
lines changed

src/store/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Symfony AI - Store Component
2+
3+
The Store component provides a low-level abstraction for storing and retrieving documents in a vector store.
4+
5+
## Installation
6+
7+
```bash
8+
composer require symfony/ai-store
9+
```
10+
11+
**This repository is a READ-ONLY sub-tree split**. See
12+
https://github.com/symfony/ai to create issues or submit pull requests.
13+
14+
## Resources
15+
16+
- [Documentation](doc/index.rst)
17+
- [Report issues](https://github.com/symfony/ai/issues) and
18+
[send Pull Requests](https://github.com/symfony/ai/pulls)
19+
in the [main Symfony AI repository](https://github.com/symfony/ai)
20+
21+
[1]: https://symfony.com/backers
22+
[3]: https://symfony.com/sponsor

src/store/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "symfony/ai-store",
33
"type": "library",
4-
"description": "PHP library for abstracting interaction with data stores in AI applications.",
4+
"description": "Low-level abstraction for storing and retrieving documents in a vector store.",
55
"keywords": [
66
"ai",
77
"mongodb",

src/store/doc/index.rst

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
Symfony AI - Store Component
2+
============================
3+
4+
The Store component provides a low-level abstraction for storing and retrieving documents in a vector store.
5+
6+
Installation
7+
------------
8+
9+
Install the bundle using Composer:
10+
11+
.. code-block:: terminal
12+
13+
$ composer require symfony/ai-store
14+
15+
Purpose
16+
-------
17+
18+
A typical use-case in agentic applications is a dynamic context-extension with similar and useful information, for so
19+
called **Retrieval Augmented Generation** (RAG). The Store component implements low-level interfaces, that can be
20+
implemented by different concrete and vendor-specific implementations, so called bridges.
21+
On top of those bridges, the Store component provides higher level features to populate and query those stores with and
22+
for documents.
23+
24+
Embedder
25+
--------
26+
27+
One higher level feature is the ``Symfony\AI\Store\Embedder``. The purpose of this service is to populate a store with documents.
28+
Therefore it accepts one or multiple ``Symfony\AI\Store\Document\TextDocument`` objects, converts them into embeddings and stores them in the
29+
used vector store.
30+
31+
Simple usage example:
32+
33+
.. code-block: php
34+
35+
use Symfony\AI\Store\Embedder;
36+
use Symfony\AI\Store\Document\TextDocument;
37+
38+
$embedder = new Embedder($storeBridge);
39+
$document = new TextDocument('This is a sample document.');
40+
$embedder->embed($document);
41+
42+
You can find more advanced usage in combination with an Agent using the store for RAG in the examples folder:
43+
44+
1. `Similarity Search with MongoDB (RAG)`_
45+
1. `Similarity Search with Pinecone (RAG)`_
46+
47+
Supported Stores
48+
----------------
49+
50+
1. Azure Search
51+
1. ChromaDB
52+
1. MongoDB
53+
1. Pinecone
54+
55+
See `GitHub`_ for planned stores.
56+
57+
58+
Implementing a Bridge
59+
---------------------
60+
61+
The main extension points of the Store component are
62+
63+
1. **Symfony\AI\Store\StoreInterface**: That takes care of adding documents to the store
64+
1. **Symfony\AI\Store\VectorStoreInterface**: That takes care of querying the store for documents
65+
66+
This leads to a store implementing two methods:
67+
68+
.. code-block: php
69+
70+
use Symfony\AI\Store\StoreInterface;
71+
use Symfony\AI\Store\VectorStoreInterface;
72+
73+
class MyStore implements StoreInterface, VectorStoreInterface
74+
{
75+
public function add(VectorDocument ...$documents): void
76+
{
77+
// Implementation to add a document to the store
78+
}
79+
80+
public function query(Vector $vector, array $options = [], ?float $minScore = null): array
81+
{
82+
// Implementation to query the store for documents
83+
return [];
84+
}
85+
}
86+
87+
.. _`Similarity Search with MongoDB (RAG)`: https://github.com/symfony/ai/blob/main/examples/store/mongodb-similarity-search.php
88+
.. _`Similarity Search with Pinecone (RAG)`: https://github.com/symfony/ai/blob/main/examples/store/pinecone-similarity-search.php
89+
.. _`GitHub`: https://github.com/symfony/ai/issues/16

0 commit comments

Comments
 (0)