Search Entire PDFs with Zero Search Logic - Ship AI with Laravel EP6
Chapters14
Discusses using provider-hosted vector stores and a file search tool to give the agent access to full documents, not just short FAQs.
Ship AI with Laravel by offloading full document search to provider-hosted vector stores for scalable, multi-document queries.
Summary
Laravel News creator Harris returns with a practical shift from DIY semantic search to provider-hosted vector stores for full PDFs and manuals. The episode demonstrates uploading documents to an AI provider, chunking text, generating embeddings, and leveraging a hosted vector store so the agent retrieves data without local processing. Harris contrasts this with the previous episode’s full DIY approach, noting the trade-offs between on-premises control and scalable, serverless handling. The workflow uses Laravel AI SDK to create a vector store, upload multiple Markdown documents (like return policies and shipping guides), and index them for retrieval. A key addition is the file search tool from the SDK, allowing the agent to pull specific document sections when needed. The combined setup keeps quick FAQ-style answers on a local knowledge base while routing policy-heavy or documentation-heavy questions to the provider’s file search. Harris also walks through wiring up prompts, updating configuration with the vector store ID, and testing via a test route that simulates real customer inquiries. The episode ends hinting at a live, streaming UI for real-time chat in the next installment.
Key Takeaways
- Using provider-hosted vector stores offloads embedding, indexing, and retrieval to the AI provider, enabling scalable handling of long PDFs and manuals.
- The Laravel AI SDK’s file search provider is wired to a specific vector store, pulling relevant document chunks during a query.
- A single project can combine local semantic search for FAQs with provider-backed file search for full documentation, routing queries accordingly.
- Creating and configuring a vector store involves a PHP artisan command, adding a vector store ID to the env file, and referencing it in config AI settings.
- Document ingestion is demonstrated with five Markdown files (e.g., return policy, shipping guide, billing FAQ, account security, product warranty) uploaded and indexed.
- The approach includes practical workflow notes like updating prompts to differentiate quick FAQs from detailed policy questions and citing exact policy timelines.
- A real-world test shows the agent answering a damaged-item question by pulling the relevant return policy section, illustrating accurate, policy-based responses.
Who Is This For?
Essential viewing for Laravel developers who want to scale document search beyond FAQs by using provider-hosted vector stores and the Laravel AI SDK to index and retrieve full documents.
Notable Quotes
"Last episode we built semantic search from scratch. For design similarity, the whole thing works great for short FAQ articles."
—Sets up the contrast with today’s provider-hosted approach.
"The trade-off is straightforward. DIY from episode 5 gives you full control and keeps data on your servers. Provider hosted handles all the complexity and scales to much larger data sets."
—Highlights the core decision between DIY vs provider-hosted.
"The SDK has a built-in file search provider tool that handles all the retrieval. We just point it at our vector store."
—Key tech detail about how file search integrates.
"Two tools in one response. If we used order lookup for the detail on order 1042 and file search for the damaged item policy the response references the specific order and the correct return procedure."
—Demonstrates practical multi-tool usage in a test scenario.
"Your OpenAI key needs billing credits attached, not just the free tier allowance."
—Practical caveat about testing costs and rate limits.
Questions This Video Answers
- How do I set up a provider-hosted vector store in Laravel for full document search?
- What is the difference between DIY semantic search and provider-hosted file search in Laravel AI SDK?
- Can I combine FAQ-style knowledge with full documentation search in the same agent?
- How do you index Markdown documents into a vector store using Laravel?
- What are best practices for testing a multi-tool agent with OpenAI in Laravel?
Laravel NewsLaravel AI SDKProvider-hosted vector storeFile search toolKnowledge baseDocument ingestionMarkdown documentsPolicy retrievalOpenAI integration
Full Transcript
Last episode we built semantic search from scratch. For design similarity, the whole thing works great for short FAQ articles. But what about entire PDFs, product manuals, hundreds of pages of documentation? I'm Harris from Laravel News, and today we're using provider host vector stores and the file search tool to give our agent access to full documents. Let's get right to it. So last time we did everything ourselves. We generated the bendings. We stored them in our database. We wrote the similarity search that works well for understanding the mechanics and for small data sets where you want full control.
Today is the other approach. We upload documents to the AI provider. They chunk the text, generate embeddings and hosted vector store. When the agent searches, the provider handles retrieval. We just wire it up. The trade-off is straightforward. DIY from episode 5 gives you full control and keeps data on your servers. Provider hosted handles all the complexity and scales to much larger data sets. In production, you might use both though. So let's be the provider host version this time. First a command to set up our knowledge base with provider. Let's go to our terminal and write php artisan make command vector store.
Let's go back and open this up. We need to upload our documentation files and create a vector store and add those files to it. So let's go back to our file here. I have the full implementation. Now we call the signature KB setup store. And what this does is it uploads support document and create a vector store with the AI provider. We have such of a small info at the beginning. Then we use this stores method which is basically coming out from the Laravel AI SDK. We create the store. We add two things. The name we call this support AI knowledge base.
And the second one is the description customer support accumulation policies and procedures. Then we have the info down here. So we say again vector store created. So we identif we have this identification for our vector down here. Then we have an array of documents. We're going to have five documents in this case. All of them are going to be markdown files. Large markdown files that each one of us might have and now and then. So the return policy, shipping guide, the billing FAQ, account security, and product warranty in this case. We have a bar to check the progress down here.
And last but not least, we have this for each loop down here. But what it does is it uses document from storage. And document again, as you can see, comes from the Laravel AI SDK. So we get the path of those files. We do document storage and we do add them in our store. That's what we do. We advance the progress bar. And then we have some more information messages down here when everything is done. Now let's create some sample docs. The ones we need up here. Let's now go to storage/private. And we're going to add everything in here.
I'm going to open up my sidebar. So let's start by creating those files. What those files will be. So return policy.md. That's file number one. Going to copy the policy. We don't need to do all of this manually at this point. Just a pretty standard policy. You can see here it's a markdown file. You can look this up in the GitHub repo we have if you want that. So way more detailed than an FAQ articles. So a full policy document with sections, edge cases, specific timelines. So, exactly the kind of things you want the agents to reference.
Let's go ahead now and go to our terminal and run the command we need. PHP is an KB setup store. We're going to run the first one with only one article, only one markdown file. So, you can see exactly how this chops this up into vectors. Going to run this. It's creating the vector store. And as you can see, even though we got vectors created, the file was not found. And this makes sense because we need to add this under the docs directory. Of course, you can find them in the GitHub repo. We have a link for that in the description below.
Now, with the power of screencasting, you can see all the files down here. So, let's go and run our command. PHP artisan kb setup store. We create the vector vector store created. And as we can see the bar progresses fine. All documents uploaded and indexed. We have a store ID. save this store ID in your env file as vector store ID. We need to do that. So let's copy that and let's create this vector store ID. Let's go here that in and you can add it here. So vector store id equals and store that. You also need to make sure that we reference that in our config file.
So let's open up AI. PHP and up here you can add vector store ID that comes from the env vector store ID. Pretty cool. Now the good part, the SDK has a built-in file search provider tool that handles all the retrieval. We just point it at our vector store. Let's go back to our file here. Setup vector store. Scroll up. We'll keep our custom tools from previous episodes and add file search alongside them. So let's come here to our file. Let's scroll down and add exactly that. So new file search as you can see we get this from AI SDK from Lav SDK.
import that and and what we are going to add in this case is stores which will be the config we just added AI vector store id. It's the ID we have just added in our AI.getsp configuration file. So now let's use that one line for file search. It tells the provider to search our vector store whenever the agent needs documentation. The provider handles the query, pulls the most relevant chunks, and returns them to the agent. Notice we're keeping similarity search here from the last episode. The agent now has two search paths. Local symbatic search for FAQ articles in post and the providers file search for full documentation.
The agent picks whichever fits the question. At this point, we need to update our instructions up here. I'm going to copy and paste the new prompt for that. and let's discuss this together. So here it is. The main thing you should be looking into is down here. So for quick FAQ style questions, use knowledgebased search tool. For detailed policy questions, use the file search tool to find specific documentation. Always base policy answers on the knowledge base. Never make a policies. And with citing policies, be specific about timelines and conditions. So file search for detailed policy questions.
And for the FAQ style questions, we use the knowledgebased search tool we built in the previous episode. Pretty neat. Here's the complete support agent. It can look up orders, pull customer history, search our FAQ databases, and dig through full documentation. And what's left now? We need to test it, right? So, let's go to our routes file. Scroll down, and we're going to create a new route down here. We're going to call this one support rag test. So it's going to be a get request of course. So support rag test. Let's close that here. What do we need in this case?
So we need the agent here. Then new support agent, the one we have. And then we also want a user. So let's get the first user in our case in this example. So first user. Now what we need is a response. So the response will be based on the agent and then for the user we just pulled prompts. What are we going to say here? So I received a D item in my order. So what are my options? How long will a refund take? Because the user would like to know about that. And then just return the response text.
Of course, the customer is asking about Damas items and refund timelines, specific policy details. Let's go to support rag agent. Let's go back here. Let's wait for the response. We got rate limited. Wow. Quick note before we hit the browser. Your open AI key needs billing credits attached, not just the free tier allowance. So, this episode is the most token hungry of this series so far since file search pumps retrieve chunks back into the model on every request. So, if you don't have credits added, you hit a 429 rate limit the moment the agent fires.
Drop $5, maybe less to test this out if you want and you're good to go. And run this. Waiting for a response. I'm sorry your item arrived damaged. Your options, if possible, take photos and the packaging. C uh contact support with 48 hours of delivery. We can provide a free return shipping label, etc., etc., etc. That's pretty cool. The customer is asking about damas items and refund timelines. Specific policy details. So, the agent at this point used file search, found the return policy documentation, pulled the damaged item section, and gave an accurate answer. 48 hours to report and everything else we saw so far.
So all from our docs, that's the most important part. Now something that combines tools. Let's go back to our editor in the same route down here. Let's change that. Let's say my order 1042 arrived damaged. What should I do? Save. Let's go back to our browser. Refresh. And now we got the response. I'm sorry your order 1042 arrived damaged. Please do these steps. And then it proceeds with the steps. Let us know whether you prefer replacement or a full refund. Okay, that's pretty cool. If you are able to upload the photos too, that will help things up.
By the way, I just check our Open AI account for those requests for those two requests and we spent $0.01, which is pretty neat in my opinion for such a huge token count. Two tools in one response. If we used order lookup for the detail on order 1042 and file search for the damaged item policy the response references the specific order and the correct return procedure. That's a real support interaction here. One more thing as your doc chains updating the vector store is straightforward. You can see some examples here in Tinkerwell. We can add documents we can add them with metadata for filtering.
We can remove outdated documents and we can also delete and replace them. Pretty neat, right? Our support agent now has four tools. We can do order lookup, customer history, FAQ search, and full document search. It handles all the specific questions, policy inquiries, and everything in between. All backed by real data. In the next episode, this is the real time chat UI. So streaming responses with live wire so that customers sees the reply appear word by word. It changes the whole feel of the app. See you in the next
More from Laravel News
Get daily recaps from
Laravel News
AI-powered summaries delivered to your inbox. Save hours every week while staying fully informed.








![[VOD] Laravel 13 & Livewire Blaze thumbnail](https://rewiz.app/images?url=https://i.ytimg.com/vi/-PNYsJMsgjw/maxresdefault.jpg)
