Skip to content

1.0.0

Choose a tag to compare

@marcreichel marcreichel released this 27 Sep 15:25
· 102 commits to main since this release
ef67283

Classify text in PHP without paying for an LLM API. laya-php is a typed SDK for Laya, a self-hosted model that answers classification questions about text in 100+ languages, and gives you calibrated confidence with every answer.

1.0.0 is the first stable release. From here on the public API follows semver.

$triage = $laya->decide($ticket, Triage::class);

$triage->department; // Department::Billing
$triage->churn;      // true

What's in 1.0

  • Three question types. Question::choice(), Question::score() and Question::yesNo() return typed answers with probabilities and a calibrated answerConfidence, which is comparable across question types.
  • Decisions into objects. $laya->decide($text, Triage::class) reads #[Ask], #[Describe] and #[Levels] attributes from a class and returns a hydrated instance. Backed enums map to choices, bools to yes/no and #[Levels] ints to scores.
  • Any PSR-18 client. Guzzle, Symfony HttpClient and others are auto-discovered, or you can pass your own client, for example one with retries.
  • Laravel integration (new since 0.0.1). For Laravel 13+, the service provider is auto-discovered and reads LAYA_URL and LAYA_API_KEY. Publish the config with php artisan vendor:publish --tag=laya-config.
  • Testing without a server. Laya::fake([...]) answers from values you register, and offers assertPredicted(), assertPredictedCount() and assertNothingPredicted(). In Laravel it also replaces the container binding, so injected code and queued jobs get the fake.
  • Typed exceptions. They cover authentication, validation, a busy server, a failed transport and other server errors, and all implement LayaException.
  • Checkpoint pinning. Pass model: Model::English, Model::Multilingual or Model::TypedDecisions. Otherwise Laya's router picks a checkpoint by language.
  • Jev-compatible. laya-serve speaks the same /v1/systemone wire protocol, which makes this a self-hosted alternative to Jev AI. It hasn't been tested against the hosted Jev API.

Quality

  • 100% line coverage and a 100% mutation score (Pest), both enforced in CI
  • PHPStan at level max
  • Tested on PHP 8.4 and 8.5
  • Integration-tested against a live laya-serve; compose.yaml pins upstream Laya to commit 4066d5d

Requirements

  • PHP 8.4+
  • A running laya-serve; the repository's compose.yaml starts one
  • Laravel 13+ (optional)

Upgrading from 0.0.1

No breaking changes. Laravel users can drop any manual Laya binding and use the auto-discovered provider.

composer require marcreichel/laya-php:^1.0