Skip to content

Latest commit

 

History

History
83 lines (53 loc) · 3.21 KB

README.md

File metadata and controls

83 lines (53 loc) · 3.21 KB

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.