Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Ai Postgres Store

Ai Postgres Store Laravel Package

symfony/ai-postgres-store

Symfony AI Store integration for PostgreSQL using pgvector. Store and query embeddings with Postgres vector/halfvec types, distance operators, and indexing options. Links to pgvector docs plus Symfony AI contribution and issue resources.

View on GitHub
Deep Wiki
Context7

PostgreSQL pgvector vector store bridge for Symfony AI

Frequently asked questions about Ai Postgres Store
Can I use symfony/ai-postgres-store in Laravel without Symfony’s full-stack?
Yes. The package implements Symfony’s Store interface, but you can wrap it in a Laravel service provider or facade to abstract Symfony dependencies. Focus on the `VectorStoreInterface` methods (e.g., `save()`, `findNearest()`) and use Doctrine DBAL for raw PostgreSQL queries if needed. Avoid Symfony’s HttpFoundation or Console components to keep your app lightweight.
What Laravel versions and PHP requirements does this package support?
The package targets PHP 8.1+ and works with Laravel 10/11. Symfony AI (v1.0+) is the direct dependency, so ensure your `composer.json` pins Symfony to a stable version (e.g., `^6.4`). Test thoroughly if using Laravel’s newer query builder features, as some Symfony components may not align perfectly.
How do I set up pgvector in PostgreSQL for Laravel?
Run `CREATE EXTENSION vector;` in your PostgreSQL instance. For Laravel migrations, use raw SQL (e.g., `Schema::raw('ALTER TABLE embeddings ADD COLUMN vector vector(768)')`) since Eloquent doesn’t natively support pgvector types. Document this step in your deployment scripts, as it requires DBA access or CI/CD updates.
What’s the performance difference between pgvector and dedicated vector DBs like Pinecone?
pgvector delivers sub-100ms latency for <1M vectors with HNSW indexing, comparable to Pinecone’s free tier. For >10M vectors, consider partitioning (e.g., by `embedding_id` ranges) or sharding. Benchmark hybrid queries (vector + full-text) in your Laravel app—pgvector’s GIN indexes handle metadata well, but complex filters may need raw SQL optimization.
Can I combine vector search with Eloquent relationships or full-text search?
Yes. Use PostgreSQL’s full-text search operators (e.g., `TO_TSVECTOR`) alongside pgvector’s `<->` distance operator in raw SQL queries. For Eloquent, create a custom accessor or use `DB::select()` to merge results. Example: `SELECT * FROM embeddings WHERE vector <-> ?::vector < 0.5 AND to_tsvector('content') @@ to_tsquery('search term')`.
How do I handle schema changes if pgvector or Symfony AI updates?
Monitor Symfony AI’s [release notes](https://github.com/symfony/ai/releases) for Store interface changes. Use Laravel migrations with raw SQL fallbacks for pgvector-specific updates (e.g., new distance metrics). Isolate Symfony dependencies behind a Laravel adapter layer to minimize breaking changes during upgrades.
Is there a Laravel-specific wrapper or facade for this package?
No official wrapper exists, but you can create one in ~20 lines of code. Extend Symfony’s `VectorStore` and bind it to Laravel’s container in a service provider. Example: `app()->bind(VectorStoreInterface::class, fn() => new PostgresVectorStore($pdo, $config));`. This abstracts Symfony’s Store interface while exposing Laravel-friendly methods.
What’s the best way to test this in a Laravel app?
Use Laravel’s `DatabaseMigrations` and `RefreshDatabase` traits for pgvector setup/teardown. Mock the `VectorStoreInterface` in unit tests with PHPUnit’s `createMock()`. For integration tests, seed embeddings via raw SQL or a data factory, then assert query results with `DB::select()`. Test hybrid searches with `assertContains()` on merged results.
How do I monitor vector search performance in production?
Enable PostgreSQL’s `pg_stat_statements` extension to track query latency. Log custom metrics in Laravel (e.g., `Log::info('Vector search latency:', $executionTime)`) or use a package like `spatie/laravel-monitoring`. Compare raw pgvector queries vs. Laravel-wrapped calls to identify ORM overhead.
Are there alternatives to symfony/ai-postgres-store for Laravel?
For Laravel, consider `laravel-ai/vector` (Pinecone/Weaviate) or `meilisearch/meilisearch-php` for managed services. For self-hosted, `typedb/typeql` (for knowledge graphs) or `milvus-io/milvus` (scalable vector DB) are options. pgvector stands out for hybrid search and cost savings if you’re already using PostgreSQL, but evaluate your team’s expertise in raw SQL vs. managed APIs.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky