Skip to main content

A cli app that generates short stories and AI images from prompts using a language model.

Project description

StoryTime

StoryTime is a Textual-based terminal application that uses Google's Gemini API to generate short stories and AI-generated images from user prompts. The app provides a simple TUI (Text User Interface) for entering prompts, confirming actions, and viewing results. When a user submits a prompt, the app generates a story and a corresponding image, saving the image to disk with a descriptive filename. The project is designed for creative exploration, rapid prototyping, and as a demonstration of integrating LLMs and generative image models into a modern Python TUI.

Features:

  • Enter a custom story prompt and generate a short story using LLM.
  • Generate AI image illustrations for your story with flexible options:
    • Use the story as context and describe the image yourself
    • Break the story into logical chunks (paragraphs) and generate an image for each, with consistent style
    • Skip image generation if desired
  • Save generated images to disk with creative, context-aware filenames.
  • All interactions are handled in a modern, responsive terminal UI.
  • Includes unit tests for core logic and easy setup with uv and pytest.

Setup

This project uses uv for fast Python virtual environment and dependency management.

1. Create and activate a virtual environment

uv venv .venv
source .venv/bin/activate

2. Install all dependencies (including dev dependencies) and the package in editable mode

pip install -e .

Or, if you want to use uv:

uv pip install .[dev]

Running the Unit Tests

pytest

Or, if not in an activated venv:

.venv/bin/pytest

Running the Program

After installing in editable mode, run the app with:

storytime

This command is available as long as your virtual environment is activated.

CLI Usage

You can use the command-line interface directly with the unified entry point:

storytime story "Tell me a story about a robot"

After generating a story, you will be prompted to choose how to generate illustrations:

  • Use the story as context and describe the image yourself
  • Break the story into logical chunks (paragraphs) and generate an image for each, with consistent style
  • Skip image generation

You can also generate a standalone image:

storytime image "A beautiful sunset over mountains"

Or launch the interactive TUI:

storytime tui

Tab Completion

StoryTime CLI supports tab completion for commands, options, and arguments.

Quick Setup (Automatic)

Enable tab completion with:

storytime --install-completion

Note: If you get an error about existing files, use the manual setup below.

Manual Setup

If automatic installation doesn't work, you can set up completion manually for your shell:

Bash (add to ~/.bashrc):

eval "$(storytime --show-completion)"

Zsh (add to ~/.zshrc):

eval "$(storytime --show-completion)"

Fish (add to ~/.config/fish/config.fish):

storytime --show-completion | source

After adding the line to your shell configuration, restart your terminal or run:

source ~/.bashrc  # for bash
source ~/.zshrc   # for zsh

Using Tab Completion

Once enabled, you can use tab completion for:

  • Commands: storytime <TAB> shows available commands (story, image, tui)
  • Options: storytime story --<TAB> shows options like --output-dir, --verbose, etc.
  • Help: Use storytime <command> --help to see all available options

Editing and Debugging

  • All source code is in the storytime/ package. When editing or adding files, use package imports (e.g., from storytime.gemini_backend import GeminiBackend).
  • To add a new backend, create a new file in storytime/ and implement the LLMBackend interface.
  • To debug, you can add print statements or use a debugger in any module in the storytime/ package.
  • After making changes, rerun the tests with pytest to ensure everything works.

Adding New Dependencies

  • To add a new main (runtime) dependency:
uv pip install <package>
  • To add a new dev (test/tooling) dependency:
uv pip install --extra dev <package>
  • After adding dependencies, uv will update your pyproject.toml and uv.lock automatically.

Notes

  • Make sure you have a valid GEMINI_API_KEY in your environment before running the program.
  • The TUI requires a terminal that supports Textual applications.

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

storyforge-0.0.1b1.tar.gz (30.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

storyforge-0.0.1b1-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file storyforge-0.0.1b1.tar.gz.

File metadata

  • Download URL: storyforge-0.0.1b1.tar.gz
  • Upload date:
  • Size: 30.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.13

File hashes

Hashes for storyforge-0.0.1b1.tar.gz
Algorithm Hash digest
SHA256 72e53ad98419850195410fa01f3b7367f89660ff18c488d72609a09e92539f5f
MD5 27dbd0f11bc6b3b81defc2fdf59e54f3
BLAKE2b-256 f807ee30a7478508035f725dd17d29ce7d6d5efdd7a4af86cb0df25d74be5171

See more details on using hashes here.

File details

Details for the file storyforge-0.0.1b1-py3-none-any.whl.

File metadata

File hashes

Hashes for storyforge-0.0.1b1-py3-none-any.whl
Algorithm Hash digest
SHA256 7d46ed4930032cb66e4d2a9ea21567b4969a0cbaf390b8dfc9cfa8169ff47b94
MD5 f5821cab9d6ba87050f4eda69c57441c
BLAKE2b-256 c449172200f458b9d806705781a7be1057009bdbae8ddbdad4a83408b6666c4e

See more details on using hashes here.

Supported by

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