It takes 10 lines of code to talk to a PDF using AI with @LangChainAI
Here's the breakdown:
Here's the breakdown:
What's going on:
- We load the PDF file
- Split the long document into smaller chunks
- Embed each chunk using OpenAI's ada-002
- Store embeddings into an in-memory Faiss Vector DB
- Ask it questions
All using Langchain's utility methods,
- We load the PDF file
- Split the long document into smaller chunks
- Embed each chunk using OpenAI's ada-002
- Store embeddings into an in-memory Faiss Vector DB
- Ask it questions
All using Langchain's utility methods,
As a quick reminder, here's the code again.
@LangChainAI does all of this for us.
Obviously this isn't a full app. But that's not the point.
The point is that the "Core AI Functionality" just takes 10 lines of code to implement.
@LangChainAI does all of this for us.
Obviously this isn't a full app. But that's not the point.
The point is that the "Core AI Functionality" just takes 10 lines of code to implement.
If we wanted to make this a full app, we'll need to:
• Separate the embed & query steps
• Store the embeddings permanently onto disk or cloud
• Create API endpoints
• Create a UI
But the good news? Those are things we already know how to do as developers.
• Separate the embed & query steps
• Store the embeddings permanently onto disk or cloud
• Create API endpoints
• Create a UI
But the good news? Those are things we already know how to do as developers.
Take this example.
From start to finish, this PDF-to-AI chatbot in NextJS took me about 4 hours to build. It even scrolls to the exact page in the PDF where the AI found the answer.
From start to finish, this PDF-to-AI chatbot in NextJS took me about 4 hours to build. It even scrolls to the exact page in the PDF where the AI found the answer.
In summary, utility libraries like Langchain supercharge our capabilities as developers.
"Integrating AI" just became a simple npm install. You don't need to be an expert in Machine Learning to build incredible AI apps anymore.
"Integrating AI" just became a simple npm install. You don't need to be an expert in Machine Learning to build incredible AI apps anymore.
I'm going to walk through a full-stack AI project (and share its source code) for a more in-depth Langchain + OpenAI guide later.
Follow my acc if this would be interesting to you!
I'll cover more advanced topics like custom chains, agents & tools, and interacting with the web!
Follow my acc if this would be interesting to you!
I'll cover more advanced topics like custom chains, agents & tools, and interacting with the web!
Loading suggestions...