2 min read

Building a basic "chat with a PDF" app as my AI learning project

Building a basic "chat with a PDF"
app as my AI learning project

Earlier this month I decided to start learning how to build AI products in my free time.

It's been quite a satisfying journey. Based on what I've learned, I even wrote up a sort of cheat sheet for building chatbots. And once you've learned the new ideas and components of an AI app, it's not that hard.

The app uses OpenAI's API and I'm using their GPT-3.5-turbo model. I'm using their embeddings endpoint to create embeddings for the uploaded PDF content, and using the chat endpoint to ask the AI questions about the document.

In the requests to the API, I asked it to assume the role of "an explanation bot that explains complex information in simple everyday English".

The learning project actually turned into a half-decent app for interrogating PDFs. Even I myself was impressed with how useful a simple AI integration can be.

To test it out, I uploaded a long PDF from the UK Home Office. It's a document explaining how to apply for UK citizenship. Basically, a long and tedious document to read. Then I asked it a few questions.

Using AI to clarify a long PDF

I liked how it summarised the answers and explained them back to me in simple English. Actually, I'm more of a bullet-point kinda guy so I would actually have preferred shorter answers in bullets. But this still saved me a tonne of time trying to read through the document.

Once I had the basic functionality working, then I tidied the frontend up a bit with some simple Tailwind classes. Instead of the usual chat box at the bottom, I decided to put it at the top and have the AI's responses appear below it.

Here's the tech stack for this simple app:

  • Backend: Laravel + Nginx
  • Database: PostgresQL + pgvector extension
  • Frontend: Livewire + Tailwind
  • AI API: OpenAI / GPT-3.5

I go into more detail about the above in a Twitter thread.

For us indie businesses, building is just half the story. To turn this into a money-making project, I'll need to launch this and have people pay to use it.

This is my task this weekend - polish and launch this learning project as an actual product. And yes, I have bought the domain name: clarifypdf.com :)

As always I'll be sharing all the details as I go on Twitter @farez. Or you can just sign up to my newsletter and get posts like this one on my AI SaaS journey.