Skip to content

Commit f53dfe5

Browse files
docs(store): Integrate supabase into the store package
- Adds documentation for the new store integration
1 parent 474313a commit f53dfe5

File tree

12 files changed

+334
-103
lines changed

12 files changed

+334
-103
lines changed

examples/.env

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,46 @@ LMSTUDIO_HOST_URL=http://127.0.0.1:1234
112112
QDRANT_HOST=http://127.0.0.1:6333
113113
QDRANT_SERVICE_API_KEY=changeMe
114114

115+
# SurrealDB (store)
116+
SURREALDB_HOST=http://127.0.0.1:8000
117+
SURREALDB_USER=symfony
118+
SURREALDB_PASS=symfony
119+
120+
# Neo4J (store)
121+
NEO4J_HOST=http://127.0.0.1:7474
122+
NEO4J_DATABASE=neo4j
123+
NEO4J_USERNAME=neo4j
124+
NEO4J_PASSWORD=symfonyai
125+
126+
# Typesense (store)
127+
TYPESENSE_HOST=http://127.0.0.1:8108
128+
TYPESENSE_API_KEY=changeMe
129+
130+
# Milvus (store)
131+
MILVUS_HOST=http://127.0.0.1:19530
132+
MILVUS_API_KEY=root:Milvus
133+
MILVUS_DATABASE=symfony
134+
135+
# Cloudflare (store)
136+
CLOUDFLARE_ACCOUNT_ID=
137+
CLOUDFLARE_API_KEY=
138+
139+
# Cerebras
140+
CEREBRAS_API_KEY=
141+
142+
CHROMADB_HOST=http://127.0.0.1
143+
CHROMADB_PORT=8001
144+
145+
# For using Clickhouse (store)
146+
CLICKHOUSE_HOST=http://symfony:[email protected]:8123
147+
CLICKHOUSE_DATABASE=symfony
148+
CLICKHOUSE_TABLE=symfony
149+
150+
# Weaviate (store)
151+
WEAVIATE_HOST=http://127.0.0.1:8080
152+
WEAVIATE_API_KEY=symfony
153+
154+
# Supabase (store)
115155
SUPABASE_URL=
116156
SUPABASE_API_KEY=
117157
SUPABASE_TABLE=

examples/commands/stores.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use Symfony\AI\Store\Bridge\Neo4j\Store as Neo4jStore;
2525
use Symfony\AI\Store\Bridge\Postgres\Store as PostgresStore;
2626
use Symfony\AI\Store\Bridge\Qdrant\Store as QdrantStore;
27-
use Symfony\AI\Store\Bridge\Supabase\Store as SupabaseStore;
2827
use Symfony\AI\Store\Bridge\SurrealDb\Store as SurrealDbStore;
2928
use Symfony\AI\Store\Bridge\Typesense\Store as TypesenseStore;
3029
use Symfony\AI\Store\Bridge\Weaviate\Store as WeaviateStore;
@@ -89,15 +88,6 @@
8988
env('QDRANT_SERVICE_API_KEY'),
9089
'symfony',
9190
),
92-
'supabase' => static fn (): SupabaseStore => new SupabaseStore(
93-
http_client(),
94-
env('SUPABASE_URL'),
95-
env('SUPABASE_API_KEY'),
96-
env('SUPABASE_TABLE'),
97-
env('SUPABASE_VECTOR_FIELD'),
98-
env('SUPABASE_VECTOR_DIMENSION'),
99-
env('SUPABASE_MATCH_FUNCTION'),
100-
),
10191
'surrealdb' => static fn (): SurrealDbStore => new SurrealDbStore(
10292
httpClient: http_client(),
10393
endpointUrl: env('SURREALDB_HOST'),

examples/rag/supabase.php

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,10 @@
2828

2929
require_once dirname(__DIR__).'/bootstrap.php';
3030

31-
echo "Make sure you've run the SQL setup from SUPABASE_SETUP.md first!\n\n";
32-
3331
$store = new Store(
34-
http: http_client(),
32+
httpClient: http_client(),
3533
url: env('SUPABASE_URL'),
3634
apiKey: env('SUPABASE_API_KEY'),
37-
table: env('SUPABASE_TABLE'),
38-
vectorFieldName: env('SUPABASE_VECTOR_FIELD'),
39-
vectorDimension: (int) env('SUPABASE_VECTOR_DIMENSION'),
40-
functionName: env('SUPABASE_MATCH_FUNCTION')
4135
);
4236

4337
$documents = [];
@@ -51,49 +45,25 @@ functionName: env('SUPABASE_MATCH_FUNCTION')
5145
}
5246

5347
$platform = PlatformFactory::create(
54-
env('OLLAMA_HOST_URL') ?? 'http://localhost:11434',
48+
env('OLLAMA_HOST_URL'),
5549
http_client()
5650
);
5751

58-
$embeddingModel = new Ollama('mxbai-embed-large');
59-
$vectorizer = new Vectorizer($platform, $embeddingModel);
52+
$vectorizer = new Vectorizer($platform, new Ollama('mxbai-embed-large'));
6053
$loader = new InMemoryLoader($documents);
6154
$indexer = new Indexer($loader, $vectorizer, $store, logger: logger());
6255
$indexer->index();
6356

64-
$chatModel = new Ollama('llama3.2:3b');
65-
6657
$similaritySearch = new SimilaritySearch($vectorizer, $store);
6758
$toolbox = new Toolbox([$similaritySearch], logger: logger());
6859
$processor = new AgentProcessor($toolbox);
69-
$agent = new Agent($platform, $chatModel, [$processor], [$processor], logger: logger());
60+
$agent = new Agent($platform, new Ollama('llama3.2:3b'), [$processor], [$processor], logger: logger());
7061

7162
$messages = new MessageBag(
7263
Message::forSystem('Please answer all user questions only using SimilaritySearch function.'),
7364
Message::ofUser('Which movie fits the theme of technology?')
7465
);
7566

76-
echo "Query: Which movie fits the theme of technology?\n";
77-
echo "Processing...\n";
67+
$result = $agent->call($messages);
7868

79-
try {
80-
$result = $agent->call($messages);
81-
echo '✅ Response: '.$result->getContent()."\n\n";
82-
} catch (Exception $e) {
83-
echo '❌ Error: '.$e->getMessage()."\n\n";
84-
}
85-
86-
$messages2 = new MessageBag(
87-
Message::forSystem('Please answer all user questions only using SimilaritySearch function.'),
88-
Message::ofUser('What are some good action movies?')
89-
);
90-
91-
echo "Query: What are some good action movies?\n";
92-
echo "Processing...\n";
93-
94-
try {
95-
$result2 = $agent->call($messages2);
96-
echo '✅ Response: '.$result2->getContent()."\n\n";
97-
} catch (Exception $e) {
98-
echo '❌ Error: '.$e->getMessage()."\n\n";
99-
}
69+
echo $result->getContent().\PHP_EOL;

src/ai-bundle/config/options.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,14 @@
491491
->useAttributeAsKey('name')
492492
->arrayPrototype()
493493
->children()
494+
->stringNode('http_client')
495+
->cannotBeEmpty()
496+
->defaultValue('http_client')
497+
->info('Service ID of the HTTP client to use')
498+
->end()
494499
->scalarNode('url')->isRequired()->cannotBeEmpty()->end()
495500
->scalarNode('api_key')->isRequired()->cannotBeEmpty()->end()
496-
->scalarNode('table')->isRequired()->cannotBeEmpty()->end()
501+
->scalarNode('table')->end()
497502
->scalarNode('vector_field')->end()
498503
->integerNode('vector_dimension')->end()
499504
->scalarNode('function_name')->end()

src/ai-bundle/doc/index.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Configuration
148148
HTTP Client Configuration
149149
-------------------------
150150

151-
Each platform can be configured with a custom HTTP client service to handle API requests.
151+
Each platform can be configured with a custom HTTP client service to handle API requests.
152152
This allows you to customize timeouts, proxy settings, SSL configurations, and other HTTP-specific options.
153153

154154
By default, all platforms use the standard Symfony HTTP client service (``http_client``):
@@ -237,7 +237,7 @@ The system prompt text will be automatically translated using the configured tra
237237
Memory Provider Configuration
238238
-----------------------------
239239

240-
Memory providers allow agents to access and utilize conversation history and context from previous interactions.
240+
Memory providers allow agents to access and utilize conversation history and context from previous interactions.
241241
This enables agents to maintain context across conversations and provide more personalized responses.
242242

243243
**Static Memory (Simple)**
@@ -292,7 +292,7 @@ Memory can work independently or alongside the system prompt:
292292
model:
293293
class: 'Symfony\AI\Platform\Bridge\OpenAi\Gpt'
294294
memory: 'You are a helpful assistant with conversation history'
295-
295+
296296
# Agent with both memory and prompt (memory prepended to prompt)
297297
memory_and_prompt_agent:
298298
model:

src/ai-bundle/src/AiBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
11001100
if ('supabase' === $type) {
11011101
foreach ($stores as $name => $store) {
11021102
$arguments = [
1103-
new Reference('http_client'),
1103+
isset($store['http_client']) ? new Reference($store['http_client']) : new Definition(HttpClientInterface::class),
11041104
$store['url'],
11051105
$store['api_key'],
11061106
];

src/store/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ CHANGELOG
4545
- Pinecone
4646
- PostgreSQL with pgvector extension
4747
- Qdrant
48+
- Supabase
4849
- SurrealDB
4950
- Typesense
5051
- Weaviate

src/store/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"pinecone",
1818
"postgres",
1919
"qdrant",
20+
"supabase",
2021
"surrealdb",
2122
"typesense",
2223
"weaviate"

0 commit comments

Comments
 (0)