Loading video player...
Episode 5 of Ship AI with Laravel, a series on Laravel News where we build a full AI platform using Laravel 13 and the Laravel AI SDK. The agent looks up orders and remembers conversations. But ask it "what's your return policy?" and it makes something up. No access to our actual documentation. In this episode we give it a knowledge base. I walk through what embeddings actually are. Text converted to vectors that capture meaning, so "how do I return a damaged item?" and "what if my package arrived broken?" land close together even though the words are different. We build a KnowledgeArticle model with a vector column using pgvector, a 1,536-dimension embedding, and an Artisan command that seeds eight FAQ articles and generates their embeddings. Searching uses Laravel 13's whereVectorSimilarTo method, which finds articles by meaning rather than keywords. I test it with a few different queries to show it works. Then we wire the search into the support agent as a similarity search tool and update the instructions so it reaches for the knowledge base on policy questions. Ask "what's your return policy?" and the answer comes from the actual return policy. ā GitHub: https://github.com/harris21/ship-ai-with-laravel š Full series playlist: https://www.youtube.com/playlist?list=PLsmlCYEtWNI_plnKPPO13XjfDJoMIfhLN š Timestamps 00:00 Why Agents Hallucinate 00:37 Embeddings Explained 02:01 Create Knowledge Model 02:39 Store Vectors in Postgres 04:23 Generate Article Embeddings 05:49 Seed the Knowledge Base 07:22 Semantic Search Route 09:46 Test Searches in Browser 11:17 Add Tool to Agent 13:09 End to End Agent Test 14:35 Wrap Up and Next Steps ---------------------------------------------------------------------- ā« Business Inquiries: hello@laravel-news.com ---------------------------------------------------------------------- JOIN OUR WEEKLY LARAVEL NEWSLETTER š https://laravel-news.com/newsletter ----------------------------------------------------------------------