You give your favorite books, the script fetches books information such as title, genres, and synopsis. All this info is passed to ChatGPT using a prompt template to get the book recommendations.
The AI Book Recommender π€π works by interacting with two main components: Goodreads π for fetching book data, and OpenAI's ChatGPT π§ for generating recommendations.
-
Goodreads π: We're using Goodreads to fetch details about your favorite books π, including the book title π·οΈ, author ποΈ, genres π·οΈ, and synopsis π. The script then extracts this data and uses it to generate personalized book recommendations π―.
-
OpenAI's ChatGPT π§ : We're using ChatGPT to generate book recommendations based on the book data fetched from Goodreads π. We feed ChatGPT with a conversation context π¨οΈ where the user talks about their favorite books (the data fetched from Goodreads). The AI then responds with book recommendations π in a conversational manner.
- Python 3.7 and above π
- An OpenAI API key π
- Git π
Here is detailed explanation for installing all the dependencies π§©.
- Clone this repository on your local machine.
git clone https://github.com/decisivedevops/ai-book-recommender.git
- Navigate to the repository.
cd ai-book-recommender/
- Create a Python virtual environment and activate it.
python3 -m venv venv
source venv/bin/activate
- Install the necessary dependencies.
pip install -r requirements.txt
- Rename the
sample.config.toml
file toconfig.toml
:
mv sample.config.toml config.toml
-
Open the
config.toml
file and update your OpenAI API key in the appropriate field. -
Update your favorite books info in the
config.toml
file. Follow the provided format and add the titles and authors of your favorite books.
[books]
favorites = """
Book Title, Author
Book Title, Author
Book Title, Author
"""
- Run the
main.py
script:
python3 main.py
- The script gives reading recommendations based on your favorite books. The suggestions are also saved in the
logs
folder.
The configuration file, config.toml
, has various settings used by the script:
- OpenAI settings, including the model name, temperature, and API key π‘οΈ.
- A list of your favorite books π.
- Message templates used when interacting with ChatGPT π.
Contributions are welcome. If you find a bug π or have an idea for an improvement or new feature, please raise an issue or submit a pull request.
AI Book Recommender is open source and available under the MIT License.