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

acquaintsoft logo
Acquaint Softtech

Hire Laravel developers with AI expertise at $20/hr. Get started in 48 hours.

Visit Acquaint Softtech

The latest

View all →
Mastering Laravel Testing: A Video Course on Laravel Tests image

Mastering Laravel Testing: A Video Course on Laravel Tests

Read article
NativePHP Mobile Security Advisories: Update to 4.6.1 image

NativePHP Mobile Security Advisories: Update to 4.6.1

Read article
Volker Dusch on the PHP RCE Vulnerabilities and Disclosure image

Volker Dusch on the PHP RCE Vulnerabilities and Disclosure

Read article
Decide with Jev: Turn AI Answers into Decisions with PHP Rules image

Decide with Jev: Turn AI Answers into Decisions with PHP Rules

Read article
Skuul: Open-Source School Management Built on Laravel image

Skuul: Open-Source School Management Built on Laravel

Read article
Laravel Read Replicas: Prevent Stale Reads After a Write image

Laravel Read Replicas: Prevent Stale Reads After a Write

Read article