Welcome to BookBot! This application is an experiment in using AI to make book content more accessible by answering real-time questions from readers. This README will guide you through setting up the application locally on your machine.
Before you begin, make sure you have the following:
- Ruby (version 3.1.3)
- Rails 7
- Node.js
- Yarn
- An OpenAI API key
-
Clone this repository to your local machine:
git clone https://github.com/FawazFarid/bookbot.git cd bookbot
-
Install Ruby gems:
bundle install
-
Create and migrate the database:
rails db:create rails db:migrate
-
Set up your environment variables: Rename the .env.example file to .env:
cp .env.example .env
Replace `OPENAI_API_KEY`` with your actual OpenAI API key in the .env file.
-
Download and place your book PDF in the root folder of the project as
book.pdf
. Generate and format embeddings for the book using the following command:rake manuscript:format
-
Start the Server:
bin/dev
-
Visit
http://localhost:3000
to view the application.
- Ask a Question:
- Enter your question in the text box on the homepage.
- Click the "Ask Question" button to get a real-time answer based on the book content.
- "I'm Feeling Lucky":
- Click the "I'm Feeling Lucky" button to get a random question from predefined options.
- Experiment and Explore:
- Feel free to experiment with different questions and explore the AI's responses.
This project was designed for the book "The Minimalist Entrepreneur" by Sahil Lavingia. However, you can use this application with your own book by following these steps:
-
Replace the book.pdf file in the root folder of the project with your own book PDF.
-
Generate and format embeddings for the book using the following command:
rake manuscript:format
-
Change the book title and author, links e.t.c inside the codebase. Some good places to look at include
app/javascript/components/
folder andapp/services/answer_with_context_service.rb
file.
Contributions are welcome! If you find any issues or want to enhance the application, please fork this repository, make your changes, and submit a pull request.