Skip to content

BookGen: A Python application using Google's Gemini 2.0 Flash to automatically generate complete books (PDF and TXT) from a given title and outline specifications.

License

Notifications You must be signed in to change notification settings

arham-kk/gemini-2-bookgen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gemini Book Generator

License: MIT

Overview

Gemini Book Generator is a Python application that leverages the power of Google's Gemini AI model to automatically generate entire books in both PDF and TXT formats. You provide the book title, desired number of chapters and subchapters, and the application does the rest! It crafts a detailed outline and then fleshes out each section with content generated by Gemini. The project uses Gradio to provide an intuitive web interface, making it easy for anyone to create their own AI-generated books.

Features

  • Automated Book Generation: Creates complete books from just a title and basic outline parameters.
  • Gemini AI Integration: Utilizes Google's Gemini model for high-quality, contextually relevant content generation.
  • Customizable Outline: Allows you to specify the number of chapters and subchapters to tailor the book's structure.
  • PDF and TXT Output: Generates the book in both PDF (using ReportLab) and plain text formats.
  • User-Friendly Interface: Provides an easy-to-use web interface built with Gradio.
  • Model Parameter Control: Offers the ability to adjust model parameters like temperature, top-p, and max output tokens.
  • Error Handling: Incorporates error handling and retry mechanisms for robust generation.

Demo

gradio file

Prerequisites

  • Python 3.8 or higher
  • A Google AI Gemini API key (get one from Google AI Studio)

Installation

  1. Clone the repository:

    git clone https://github.com/arham-kk/gemini-2-bookgen.git
    cd gemini-2-bookgen
  2. Install dependencies:

    pip install -r requirements.txt
  3. Set up your API key:

    • Add your Gemini API key to the .env file in the following format:

      GEMINI_API_KEY=your_api_key_here
      

Usage

  1. Run the application:

    python app.py
  2. Open your web browser and go to the URL indicated in your terminal.

  3. Enter the following in the Gradio interface:

    • Book Title
    • Number of Chapters
    • Number of Subchapters per Chapter
    • (Optional) Adjust model parameters (temperature, top-p, max output tokens)
  4. Click "Generate Book".

  5. Download the generated PDF and TXT files.

Customization

  • Model Parameters: You can fine-tune the generated content by modifying the model parameters in the Gradio interface. See the Gemini documentation for more details on these parameters.
  • PDF Styling: The appearance of the generated PDF can be customized by modifying the ReportLab styles in the generate_book function within app.py.

License

This project is licensed under the MIT License

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

About

BookGen: A Python application using Google's Gemini 2.0 Flash to automatically generate complete books (PDF and TXT) from a given title and outline specifications.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages