Skip to content

Fix LLM GIF parsing robustness and add CLI producer#3

Open
apshoemaker wants to merge 2 commits into
mainfrom
codex/linear-mention-dig-6-llm-gifs-7uus59
Open

Fix LLM GIF parsing robustness and add CLI producer#3
apshoemaker wants to merge 2 commits into
mainfrom
codex/linear-mention-dig-6-llm-gifs-7uus59

Conversation

@apshoemaker

Copy link
Copy Markdown
Owner

Motivation

  • Real-world LLM responses often include surrounding prose or fenced code blocks which caused a raw json.loads to fail with JSONDecodeError; the project needs a producer that tolerates those formats and emits ND75-ready GIF bytes.
  • Provide a reusable, test-covered producer CLI to generate GIFs from natural-language prompts so users can pipe LLM-generated animations into the existing push workflow.

Description

  • Add nd75_screen/llm_gif.py which extracts text from mixed Anthropic response blocks, scans and decodes embedded/fenced JSON payloads, validates storyboard shape, renders ND75-sized frames with PIL, and serializes them to an animated GIF via frames_to_gif.
  • Add nd75_screen/cli/llm.py CLI (nd75-llm-gif) that creates an Anthropic client from ANTHROPIC_API_KEY, accepts a prompt and --model override, and writes generated GIF bytes to stdout.buffer for pipe composition.
  • Add tests tests/test_llm_gif.py and tests/test_cli_llm.py covering fenced JSON parsing, ignoring non-text blocks, clear ValueError on missing JSON payloads, CLI stdout emission, and model override behavior.
  • Update packaging and docs by adding anthropic>=0.84.0 and a nd75-llm-gif script entry in pyproject.toml, and adding usage/examples for the new CLI to README.md.

Testing

  • Ran uv run pytest tests/test_llm_gif.py tests/test_cli_llm.py -q and the new tests passed.
  • Ran uv run pytest tests/ -q and the full test suite passed (81 passed).
  • Verified the CLI help with uv run python -m nd75_screen.cli.llm --help which printed the expected usage information.

Codex Task

… effectively become gifs as another mechanism by which gifs are pushed to the keyboard screen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant