Menu

Building a news pipeline with the Laravel AI SDK: agents, structured output and the pitfalls nobody warns you about
📰

Building a news pipeline with the Laravel AI SDK: agents, structured output and the pitfalls nobody warns you about

DEV Community: php·Ivaylo Nikolov·19 days ago
#R0MUwLTq
#devto#dev#schema#agent#model
Long article (2630 words) — no AI summary yet.
Reading 0:00
15s threshold

NewSumm reads news from hundreds of outlets, groups articles about the same event into one story, and writes a short summary of what the outlets agree on and where they differ. On a normal day that is tens of thousands of articles.

The whole pipeline runs on the Laravel AI SDK ( laravel/ai ): embeddings for every article, and agents that summarise stories, describe each outlet's angle and extract the people and places a story is about. This post is about the Laravel side: how the code is organised, what the SDK gives you for free, and the three failures that cost us real time because no test could see them.

If you want the maths behind the grouping (embeddings, running centroids, how the clusters are distributed), that is in Clustering the news with cheap models . Here we stay in PHP.

The code below is simplified from our real classes. The prompts, models and thresholds are left out on purpose; the structure is what transfers.

1.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.