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.1
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 long_ebook_generator_ai 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"
book_writer = BookWriter(title=title, client=client)

2. Generate an Outline

outline = book_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

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 long_ebook_generator_ai 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.1.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

long_ebook_generator_ai-1.0.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file long_ebook_generator_ai-1.0.1.tar.gz.

File metadata

File hashes

Hashes for long_ebook_generator_ai-1.0.1.tar.gz
Algorithm Hash digest
SHA256 013106c71feefa7c66ea57b29ff4f4c353002c1fc6b5fcee26aade51f3906911
MD5 390a70182f89e45e2eb74fba6e330e99
BLAKE2b-256 f774594cbb442e8ca68c05a87bce285cc36e2ba4dbff22ba2903baf500ba58b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for long_ebook_generator_ai-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 925ee2d50fb70a7461c6145306eaac958c9dadba915fb7425d1f5af717a8444c
MD5 6d1d4aeadd4aa4cb7884aed36900e262
BLAKE2b-256 ef377ac007166f105976b33cc10003fb4c7214f35e95f54d337922bc74a915ff

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