Laravel Tutorials

Decide with Jev: Three Questions in One Request with the Laravel AI SDK

Published

▶️ Watch the video tutorial (9 minutes)

A single yes or no doesn't tell you much about a draft. It can tell you the draft matches the brief, but not what kind of text it is or whether the steps are easy to follow. So in this episode of Decide with Jev, I ask Jev three questions about the same draft and still send only one request. Each question gets its own kind of answer:

  • A Boolean: does the draft deliver the brief?
  • A choice: is it a tutorial, an announcement, an opinion, or something else?
  • A score: does the reader get clear steps and a way to check the result?

Why not one overall score? Because "7 out of 10" hides too much. When it drops to a 5, you can't tell which part got worse. Three separate answers point straight at the part that changed.

First I move the request into its own service, so the app and the tests ask the exact same questions. That set of questions gets a name and a version, and if the rules change later, it becomes a new version.

I also add "other" to the list of formats. Without it, Jev has to squeeze every draft into one of the three, even when none of them fit. Then I read the answers. A choice answer tells you which option Jev picked and how likely each option was. It also comes with a confidence number that shows how clear the pick was. A score answer can land between two levels, so I use  level()  to get the most likely level and  normalized()  to turn the score into a number from 0 to 1.

One catch: the three questions don't see each other's answers. Jev answers all of them at the same time, so the format pick can't change how the steps get scored. When one answer should affect another decision, I handle it in PHP after the request comes back.

⭐ GitHub: https://github.com/harris21/decide-with-jev ▶️ Watch Episode 2 now →

Harris Raftopoulos photo

Senior Software Engineer • Staff & Educator @ Laravel News • Co-organizer @ Laravel Greece Meetup

Sponsored

masteringlaravel logo
Laravel Code Review

Get expert guidance in a few days with a Laravel code review

Visit Laravel Code Review

The latest

View all →
Synapse: A Dev Dashboard for Laravel AI SDK Agents image

Synapse: A Dev Dashboard for Laravel AI SDK Agents

Read article
Grant: Enum-Based Roles and Permissions for Laravel image

Grant: Enum-Based Roles and Permissions for Laravel

Read article
Securing Filament plugins with Plumb image

Securing Filament plugins with Plumb

Read article
LayaPHP: Self-Hosted Text Classification for PHP and Laravel image

LayaPHP: Self-Hosted Text Classification for PHP and Laravel

Read article
WhenMounted and BigInt Props in Inertia.js v3.8 image

WhenMounted and BigInt Props in Inertia.js v3.8

Read article
Postcodes for Laravel: GB Postcode Lookup and Geography Data image

Postcodes for Laravel: GB Postcode Lookup and Geography Data

Read article