A small async script that asks an LLM (local via Ollama, or remotely via the Anthropic API) for a short-form video concept, and validates the response into a typed Pydantic model before using it.
This is a learning project for picking up Python idioms that differ from Dart/Java:
type hints + mypy, asyncio, Pydantic v2 for structured/validated data, and the uv +
ruff + src/ toolchain.
Given a one-line brief, it returns a VideoConcept:
{
"hook": "...",
"script": ["...", "..."],
"on_screen_text": ["..."],
"duration_seconds": 30
}The shape is enforced two ways: the model is constrained to emit JSON matching the schema
generated from VideoConcept, and the response is re-validated through Pydantic afterward —
so a malformed response raises immediately instead of propagating bad data.
- Python 3.12+
- uv for dependency management
- Ollama running locally, with a model pulled (e.g.
qwen3:4b)
uv sync # creates .venv and installs dependencies
ollama serve # in a separate terminal, if not already running
ollama pull qwen3:4b # or any model you prefer — see "Changing the model" belowDry run — no Ollama, no network, just proves the Pydantic validation works:
uv run python -m ai_video_concepts.concept --dryReal run — calls your local model:
uv run python -m ai_video_concepts.conceptEdit MODEL in src/ai_video_concepts/concept.py to match exactly what ollama list shows
(including the tag, e.g. qwen3:4b, not just qwen3).
uv run ruff check src/ # lint
uv run ruff format src/ # auto-format
uv run mypy src/ # strict type-checkBoth ruff and mypy are configured in pyproject.toml and should report clean before
committing changes.