An AI-powered novel generation tool that creates complete novels from simple prompts.
- Generate complete novels with multiple chapters
- Support for various writing styles (Fantasy, Romance, Science Fiction, etc.)
- Automatic cover image generation
- EPUB and Markdown format output
- Smart chapter and style determination based on prompts
- Command-line interface and API support
- Python 3.8 or higher
- Poetry (Python package manager)
First, install Poetry if you haven't already:
curl -sSL https://install.python-poetry.org | python3 -
poetry add llm-novelist
# Clone the repository
git clone https://github.com/zhoudongyan/llm-novelist.git
cd llm-novelist
# Install dependencies
poetry install
# Activate the virtual environment
poetry shell
Create a .env
file in your project root with the following variables:
# OpenAI Configuration
OPENAI_BASE_URL=your_openai_base_url
OPENAI_API_KEY=your_openai_api_key
LLM_MODEL=gpt-3.5-turbo # Optional, defaults to GPT-3.5
# Stability AI Configuration
STABILITY_API_KEY=your_stability_api_key
You can run the tool in two ways:
- Using the
-m
flag (recommended):
poetry run python -m llm_novelist --prompt "Your story prompt" [options]
- Direct package execution:
poetry run llm_novelist --prompt "Your story prompt" [options]
Options: --chapters NUMBER Number of chapters (optional) --style STYLE Writing style (optional) --output-dir DIR Output directory (default: output) --author NAME Author name (default: AI)
Example:
poetry run python -m llm_novelist --prompt "A story about AI and justice" --style "scifi" --chapters 10
from llm_novelist import generate_novel
result = generate_novel(
prompt="Your story prompt",
num_chapters=10, # Optional
style="fantasy", # Optional
output_dir="output",
author="AI"
)
if result["status"] == "success":
print(f"Novel generated: {result['title']}")
print(f"Output directory: {result['output_dir']}")
print(f"Files: {result['files']}")
- Clone the repository
- Install dependencies:
poetry install
- Activate the virtual environment:
poetry shell
- Run tests:
poetry run pytest
- Format code:
poetry run black . poetry run isort .
- Type checking:
poetry run mypy .
- Linting:
poetry run ruff check .
MIT License