Skip to main content

An A.I. tool for generating long Kindle ebooks based on a prompt

Project description

long_ebook_generator_ai

Version: 1.0.3 Author: Alexis Kirke (narrative.layer)

Overview

long-ebook-generator-ai is a Python library designed to generate long-form eBooks using AI-powered language models. It automates the process of creating structured book outlines, chapters, and converting them into an EPUB format, with optional Kindle compatibility. The package also supports AI-generated book covers and MathML conversion for LaTeX equations in the text.

The package integrates with OpenAI's API to generate book content based on customizable prompts, making it a powerful tool for authors, content creators, or developers looking to create AI-generated books.

Features

  • AI-Powered Outline and Content Generation: Automatically generate book outlines with chapters, sections, and subsections using OpenAI's GPT models.
  • EPUB Book Creation: Convert AI-generated content into an EPUB format, compatible with major eReaders.
  • Customizable Book Structures: Define the number of chapters, sections, and subsections for your book.
  • AI-Generated Book Covers: Automatically generate a cover for your book using image generation AI models.
  • LaTeX Equation Support: Convert LaTeX equations to MathML for display in the eBook.
  • Kindle Compatibility: Optionally force compatibility with Amazon Kindle devices.
  • Extendable with Custom Language Models: Easily integrate other language models by implementing a custom client.

Installation

Install the package using pip:

pip install long-ebook-generator-ai

Quick Start

Here's an example of how to generate an outline and an EPUB book using long-ebook-generator-ai.

1. Import and Initialize the Client

from book_writer import OpenAIClient, BookWriter

# Initialize the OpenAI client
openai_api_key = 'your-openai-api-key'
client = OpenAIClient(openai_api_key=openai_api_key)

# Initialize the BookWriter
title = "The AI Revolution"
writer = BookWriter(title=title, client=client)

2. Generate an Outline

outline = writer.generate_outline(
    num_chapters=5, 
    sections_per_chapter=3, 
    subsections_per_section=2, 
    paras_per_subsection=4
)
print(outline)

3. Generate the EPUB Book

writer.generate_ebook(
    author="Your Name",
    generate_cover=True,
    force_kindle_compatibility=True,
    image_prompt="A futuristic book cover showing an AI revolution"
)

Customization

You can easily extend the package by implementing your own language model client. Just create a new class inheriting from LLMClient and implement the generate_text method.

from book_writer import LLMClient

class CustomClient(LLMClient):
    def generate_text(self, prompt: str) -> str:
        # Custom implementation
        pass

Dependencies

  • openai - For OpenAI GPT integration.
  • ebooklib - To create and manage EPUB files.
  • Pillow - For image manipulation (used in cover generation).
  • tiktoken - Token management for GPT models.
  • json, html, re - Standard libraries for handling text formatting and file management.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

long-ebook-generator-ai-1.0.3.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

long_ebook_generator_ai-1.0.3-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file long-ebook-generator-ai-1.0.3.tar.gz.

File metadata

File hashes

Hashes for long-ebook-generator-ai-1.0.3.tar.gz
Algorithm Hash digest
SHA256 8aa892728f22a73945a346948544becf4747808fb52b849c9e6bb03726946415
MD5 31be26726ee947469fc76c90d0c3804a
BLAKE2b-256 34dd1ec02e4bc5b8d75d6c6a1315c443f5bb0d559c2c5585332d23efc4614864

See more details on using hashes here.

File details

Details for the file long_ebook_generator_ai-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for long_ebook_generator_ai-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 29f10dd26edd10114d321d14ad103f1d256598db36e299aa1cc55fcafedd0e39
MD5 7f785fb9032b1105b9c97e9927bd3ae6
BLAKE2b-256 0251db32ca16e9474663c91af8f096b9673c8866ba485725c644114c66062844

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page