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

Laravel Ai Core Laravel Package

apavliukov/laravel-ai-core

Laravel AI Core provides a foundation for integrating AI capabilities into Laravel applications, with configurable drivers, service bindings, and a consistent API for working with AI models and providers. It aims to keep AI configuration and usage organized, testable, and framework-native.

View on GitHub
Deep Wiki
Context7

Getting Started

Start with the package README and the ModelAssignments base class. v0.4.0 moved the extension point to protected function store(); v0.4.1 is a bug-fix release and keeps that extension point. Install the package, publish its config/migrations, add the assignable contract/trait to an Eloquent model, and create a model assignment for a subject. A good first use case is attaching an AI model assignment to a subject and confirming the stamped subject key. In v0.4.1, subject-key stamping happens before host traits run, so assert the stamped key around assignment and any host-trait side effects. Check the package config first for subject-key stamping and rejected-answer report settings, then run the migrations and a single assignment in a test or tinker session.

Implementation Patterns

  • Custom assignment logic: extend ModelAssignments and implement protected function store() for persistence/side effects. Do not override assign(); it is final in v0.4.0 and remains so in v0.4.1.
  • Subject key stamping: let the package stamp subject keys during assignment rather than writing them manually, unless your config explicitly requires a custom key. In v0.4.1 stamping runs before host traits, so host traits can rely on the stamped subject key being present.
  • Assignable models: apply the package’s assignable contract/trait to models that should receive assignments. Use the row factory for test fixtures and seed data where assignment rows are needed.
  • Provider configuration: v0.4.1 reads providers once. Configure the provider list before the assignment flow rather than mutating provider config mid-request, and test any flow that conditionally changes providers during assignment.
  • Rejected-answer reports: generate these after assignment runs or on a schedule, and surface them in admin tooling or logs for auditing failed/rejected assignments.
  • Factory usage: use the row factory for tests and seed data. The v0.4.1 “sharper factory” fix reduces surprising factory behavior, but still scope factory calls carefully outside tests.
  • Typical workflow: resolve an assignable model → trigger the assignment → let the package stamp the subject key before host traits run → persist through store() → inspect rejected-answer reports.

Gotchas and Tips

  • Breaking change from v0.4.0 remains: any ModelAssignments subclass that overrides assign() must be refactored to store(). Search for function assign( in subclasses before upgrading. No new breaking change is indicated in v0.4.1.
  • Because assign() is final, do not attempt to call parent::assign() from a subclass override; put customization in store() instead.
  • v0.4.1 ordering change: subject keys are stamped before host traits run. Retest host traits that read the subject key or that previously depended on a different ordering.
  • Providers are read once in v0.4.1: avoid changing provider configuration in the middle of an assignment flow; set it before assignment and verify in tests if you rely on dynamic provider switching.
  • Verify subject key stamping in tests. If keys are missing, check the package config and clear the config cache after publishing.
  • Rejected-answer reports may depend on queue, logging, or report-driver configuration; confirm those settings before relying on reports in production.
  • The row factory is convenient but can create unintended database rows if used outside tests; scope it carefully.
  • For debugging, inspect the ModelAssignments subclass, check the stamped subject columns, verify host-trait ordering under v0.4.1, and use Laravel logs/Telescope around the assignment service.
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.
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle