An A.I. tool for generating long Kindle ebooks based on a prompt
Project description
long_ebook_generator_ai
Version: 1.0.2 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
Built Distribution
File details
Details for the file long_ebook_generator_ai-1.0.2.tar.gz
.
File metadata
- Download URL: long_ebook_generator_ai-1.0.2.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cfadfc5ad7795c27332b6452f9b2d1643b3660acd7a3c0faeb2f101bca7e5d8 |
|
MD5 | 416dff0a8b066671af7b8106fcf9d716 |
|
BLAKE2b-256 | dd34bf8e829326900f3a8ed39b2e3b2a26991db12a2fa0a9f35f2f77b402e331 |
File details
Details for the file long_ebook_generator_ai-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: long_ebook_generator_ai-1.0.2-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a82193e2dccceb09f5673fc4904d7b40f452364b739a6d9bd3841602b9e56dc2 |
|
MD5 | 7afb89539502c21623a2667dd8e2bd64 |
|
BLAKE2b-256 | b0994e460b8d3fded08ecbfdc57721fe73636392500af527eec94400cc001e1c |