Weave 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 Store Laravel Package

symfony/ai-store

Symfony AI Store provides a low-level abstraction for storing and retrieving documents in vector stores, with bridge packages for popular backends. Experimental and not covered by Symfony’s BC promise.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Vector Store Abstraction: Ideal for Laravel applications requiring RAG pipelines, semantic search, or AI-driven document retrieval. The bridge pattern enables multi-backend support (PostgreSQL, Pinecone, Weaviate, etc.) without vendor lock-in, aligning with Laravel’s modular ecosystem.
  • Laravel Synergy:
    • Service Container: Seamlessly integrates with Laravel’s DI, allowing dependency injection of StoreInterface implementations (e.g., PostgresStore).
    • Event System: PreQueryEvent/PostQueryEvent can be extended via Laravel’s listeners for logging, caching, or analytics.
    • Queue Workers: Batch indexing (IndexerInterface) can leverage Laravel Queues for async processing; v0.14.0’s indexer options passthrough allows queue jobs to vary loader behaviour (batch size, filters) per dispatch.
  • Experimental Risk: Still marked as experimental—no BC guarantee. Mitigate with feature flags (e.g., config('features.ai_store')) and version pinning (^0.14.0) in composer.json.
  • Hybrid Query Support: HybridQuery (keyword + vector) complements Laravel’s Eloquent query builder, enabling unified search UIs.
  • New in v0.14.0 — VectorDocumentInterface: Documents are now type-hinted against an interface rather than a concrete class. This is the single most TPM-relevant change: it opens the door to domain objects implementing the interface directly (e.g., an Eloquent model or a DTO), reducing the manual mapping layer previously required, and it makes test doubles trivial.
  • New in v0.14.0 — count() on stores: Enables pagination and result-count UIs without materialising vectors. Previously this required a separate search() with a large limit or a backend-specific query, so it removes an entire class of bespoke code from the search controller.
  • New in v0.14.0 — Any VectorInterface in vector queries: Decouples query construction from the concrete Vector class, so custom vector sources (e.g., cached embeddings, multi-modal vectors) can be passed directly. Low integration effort, moderate architectural upside.

Integration Feasibility

  • Composer + Laravel:
    • Install core + bridge (e.g., composer require symfony/ai-store:^0.14 symfony/ai-postgres-store).
    • Bind interfaces in AppServiceProvider:
      $this->app->bind(StoreInterface::class, PostgresStore::class);
      
  • Database Drivers:
    • PostgreSQL: Uses pgvector (requires extension). Note count() support is bridge-dependent—verify the Postgres bridge exposes it before relying on it for pagination.
    • Redis: Leverages Redis modules (e.g., RESEMBLANCE for cosine similarity).
    • SQLite: Native sqlite-vec support (zero-config for local dev).
  • Laravel-Specific Gaps:
    • No native Scout integration (custom adapter still required for full-search replacement).
    • Migration Support: Still requires manual schema setup (e.g., pgvector extension in PostgreSQL).
    • No first-party Eloquent trait: VectorDocumentInterface makes an HasVectorDocument-style trait straightforward to write in-house, but the package does not ship one.

Technical Risk

  1. Experimental Instability:
    • Mitigation: Pin to ^0.14.0 (minor-range) and gate all store calls behind feature flags.
    • Monitor: Symfony AI’s release notes for breaking changes.
  2. v0.14.0 Upgrade Risk (low but non-zero):
    • count() is an interface addition. Any in-house StoreInterface implementation or decorator (caching store, logging store, tenancy wrapper) must add a count() method or it will fatal. Audit custom stores before bumping.
    • VectorDocumentInterface type hints widen parameters (generally BC-safe) but may narrow return types in some signatures. Any code doing instanceof VectorDocument or type-hinting the concrete class should be reviewed.
    • Indexer options passthrough changes loader call signatures internally; custom loaders overriding load() may need signature updates.
    • Mitigation: Budget a half-day spike on a branch, run the existing test suite against v0.14.0, and diff any custom store/loader subclasses.
  3. Bridge Maturity:
    • Cloud Providers (Pinecone, Azure AI Search) may have rate limits or cost implications; feature parity for count() across bridges is not guaranteed at release.
    • Local Stores (SQLite, Redis) are more stable for prototyping.
  4. Performance Tuning:
    • Chunking: TextSplitTransformer still requires tuning chunk_size/delay; v0.14.0 lets these be passed per-indexing run rather than baked into the loader constructor—a genuine win for multi-tenant or per-collection tuning.
    • Batch Indexing: Laravel Queues can handle async Indexer::index(), but memory limits may require chunked processing.
  5. Laravel Ecosystem Friction:
    • Eloquent Model Bindings: Improved but not solved—VectorDocumentInterface enables a clean mapping trait, but it is still our code to write and maintain.
    • Caching: PSR-6 cache bridge exists but may need a Laravel Cache integration layer.

Key Questions for TPM

  1. Backend Priority:
    • Which vector store(s) are mandatory (e.g., PostgreSQL for cost, Pinecone for performance)?
    • Does the chosen bridge actually implement count() in v0.14.0, and if not, what is our fallback for pagination?
  2. Stability Requirements:
    • Can the team tolerate experimental status, or should a mature alternative (e.g., direct Pinecone SDK) be considered?
    • Do we have any in-house StoreInterface implementations or decorators that need a count() method before upgrade?
  3. Scaling Needs:
    • Will the system require horizontal scaling (e.g., Redis Cluster for ai-redis-store)?
  4. Laravel Integration Depth:
    • Should the package replace Scout for semantic search, or augment it?
    • Is real-time indexing (e.g., via Laravel Events) needed?
    • Should we invest in an Eloquent HasVectorDocument trait now that VectorDocumentInterface exists, or defer until the API stabilises?

Integration Approach

Stack Fit

  • Laravel Core:
    • Service Container: Replace StoreInterface implementations via bindings (e.g., PostgresStore for production, InMemoryStore for testing).
    • Events: Extend PreQueryEvent/PostQueryEvent with Laravel listeners for analytics or caching.
    • Queues: Offload batch indexing (Indexer::index()) to Laravel Queues, passing loader/indexer options per job for per-collection tuning.
  • Database Layer:
    • PostgreSQL: Requires pgvector extension; create a custom PostgresStore config:
      'ai_store' => [
          'postgres' => [
              'connection' => 'pgsql',
              'table' => 'vector_documents',
              'vector_column' => 'embedding',
          ],
      ],
      
    • Redis: Use ai-redis-store with Redis modules (e.g., RESEMBLANCE for cosine distance).
    • SQLite: Zero-config for local dev (ai-sqlite-store).
  • AI Pipeline:
    • Pair with symfony/ai-platform for vectorization (e.g., OpenAIVectorizer):
      $vectorizer = new OpenAIVectorizer($client, 'text-embedding-ada-002');
      $indexer = new Indexer($vectorizer, new PostgresStore($connection));
      
    • v0.14.0: Implement VectorDocumentInterface on an internal DTO (or Eloquent accessor-backed wrapper) so documents flow through stores without an adapter class.

Migration Path

  1. Prototype Phase:
    • Use InMemoryStore for local testing.
    • Replace with PostgresStore/RedisStore for validation.
  2. v0.13 → v0.14 Upgrade:
    • Pin ^0.14.0 on a branch; run the full test suite.
    • Add count() to any custom store/decorator; verify loader load() signatures.
    • Replace instanceof VectorDocument checks with VectorDocumentInterface hints.
    • No database migration is implied by the changelog.
  3. Production Readiness:
    • Feature Flags: Wrap StoreInterface calls in Laravel’s feature() helper.
    • Schema Migrations: Add pgvector extension (PostgreSQL) or Redis modules via Docker.
    • Monitoring: Instrument PreQueryEvent to log query performance; log count() latency separately if used on hot pagination paths.
  4. Rollout Strategy:
    • Canary: Deploy ai-store alongside existing vector logic (e.g., direct Pinecone SDK).
    • Feature Toggle: Enable per-route or per-user (e.g., config('features.ai_search')).

Compatibility

Laravel Component Integration Notes Workarounds
Eloquent No first-party trait; VectorDocumentInterface (v0.14.0) makes a custom trait viable Implement interface on a DTO or via Accessors/Mutators
Scout No native integration Build custom ScoutEngine adapter
Cache PSR-6 bridge exists (ai-cache-store) Wrap in Laravel Cache facade
Queues Supports async Indexer::index(); per-run loader options in v0.14.0 Use Laravel Queues for batch processing
Events Extend PreQueryEvent/PostQueryEvent Register listeners in EventServiceProvider
Pagination count() added in v0.14.0; bridge coverage varies Fallback to search() with bounded limit

Sequencing

  1. Phase 0: v0.14.0 Upgrade Spike (new)
    • Bump to ^0.14.0 on a branch, run tests, patch custom stores/loaders, audit VectorDocument type hints.
  2. Phase 1: Core Integration
    • Bind StoreInterface to a bridge (e.g., PostgresStore).
    • Implement Indexer for document ingestion; introduce a VectorDocumentInterface implementation as the canonical document type.
  3. Phase 2: Query Layer
    • Add HybridQuery support for keyword + vector search.
    • Wire count() into paginated search endpoints (with fallback path).
    • Integrate with Laravel routes/controllers.
  4. Phase 3: Scaling
    • Configure Redis for caching or distributed ai-redis-store.
    • Optimize chunking (TextSplitTransformer) using per-run indexer options.
  5. Phase 4: Observability
    • Log PreQueryEvent/PostQueryEvent via Laravel’s Log facade.
    • Add Prometheus metrics for query latency and count latency.

Operational Impact

Maintenance

  • Dependency Updates:
    • Pin symfony/ai-store to minor versions (^0.14.0) due to experimental status.
    • Monitor Symfony AI’s GitHub Issues for breaking changes.
  • Interface Churn (rising):
    • v0.14.0 added a method to StoreInterface (count) and introduced VectorDocumentInterface. Expect further additive interface changes at this cadence; budget a recurring per-minor upgrade ticket rather than treating upgrades as free.
  • Bridge-Specific Maintenance:
    • Cloud Bridges (Pinecone, Azure AI Search): Monitor provider rate limits and costs; confirm count() feature parity per bridge.
    • Database Bridges: Ensure compatibility with Laravel migrations (e.g., pgvector schema updates).
  • Laravel-Specific Tasks:
    • Service Provider: Centralize StoreInterface bindings in AppServiceProvider.
    • Config Validation: Add Laravel’s config/caching for store configurations.
    • Custom Code Surface: Every decorator (tenancy, caching, logging) must now satisfy count(); track these in one package so upgrades are single-file changes.

Support

  • Troubleshooting:
    • Vectorization Errors: Validate TextDocument input (e.g., empty text, malformed metadata).
    • Query Failures: Check HybridQuery syntax and backend-specific filters (e.g., Elasticsearch DSL).
    • Count Discrepancies: count() may not honour filters identically across bridges—verify semantics before surfacing to users.
    • Performance Issues: Profile Indexer::index() batch size and chunking parameters; now tunable per run via indexer options.
  • Community Resources:
    • Symfony AI Slack: #ai channel for real-time support.
    • GitHub Discussions: symfony/ai for bridge-specific issues.
  • Fallback Plan:
    • Maintain direct SDK integrations (e.g., Pinecone PHP SDK) as a backup for critical paths, and a search(limit: N) fallback for count().

Scaling

  • Horizontal Scaling:
    • Redis Cluster: Deploy ai-redis-store with Redis Cluster for distributed vector storage.
    • Read Replicas: Route count() and read queries to replicas where the bridge supports connection selection, keeping write-path indexing on the primary.
  • Throughput:
    • count() removes the "fetch N to count" anti-pattern, materially reducing payload size and DB egress on paginated search UIs.
    • Per-run indexer options let one worker pool serve collections with different batch profiles without separate container configs.
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.
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel