Created
March 17, 2025 13:42
-
-
Save KaQuMiQ/00a7831a2c768070e6c4d18f2b114c3c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! uv -n run | |
| # /// script | |
| # requires-python = ">=3.12" | |
| # dependencies = [ | |
| # "draive[gemini]~=0.49.1", | |
| # ] | |
| # /// | |
| from asyncio import run | |
| from draive import Stage, ctx, load_env, setup_logging | |
| from draive.gemini import Gemini, GeminiGenerationConfig | |
| load_env() | |
| setup_logging("comic") | |
| async def main() -> None: | |
| async with ctx.scope( | |
| "comic", | |
| Gemini().lmm_invoking(), | |
| GeminiGenerationConfig(model="gemini-2.0-flash-exp"), | |
| ): | |
| comic = await Stage.sequence( | |
| Stage.completion( | |
| """ | |
| Draw comic a scene out of the following: | |
| Panel Description: | |
| A nervous character peers cautiously from behind a thick tree, partially hidden in the shadows. Their wide eyes and tense posture suggest fear or hesitation. The forest path ahead is dimly lit, winding into the dense trees, creating an eerie and mysterious atmosphere. Leaves and branches frame the scene, adding depth and texture. | |
| Narration Box: | |
| “You will never know…” | |
| """, | |
| output="image", | |
| ), | |
| Stage.completion( | |
| """ | |
| Draw a follow up comic a scene out of the following: | |
| Panel Description: | |
| The character cautiously steps out from behind the tree, still tense but determined. Their body language shows hesitation—one foot slightly raised mid-step, shoulders slightly hunched. The forest path ahead remains shadowy, with twisted branches overhead. Soft light filters through the trees, casting eerie patterns on the ground. The atmosphere is thick with suspense, as if danger might lurk just beyond the panel’s edges. | |
| Narration Box: | |
| “…when to go out with a feature…” | |
| """, | |
| output="image", | |
| ).extend_result(), | |
| Stage.completion( | |
| """ | |
| Draw a follow up comic a scene out of the following: | |
| Panel Description: | |
| The character suddenly dashes back behind the tree, arms tensed and legs in mid-sprint. Their expression is a mix of fear and realization, eyes wide as if they’ve seen something unsettling on the path ahead. Leaves rustle around them, emphasizing the quick movement. The shadows under the tree seem darker now, as if offering both safety and uncertainty. The forest remains ominous, with the path still stretching into the unknown. | |
| Narration Box: | |
| “…until you try!” | |
| """, | |
| output="image", | |
| ).extend_result(), | |
| Stage.completion( | |
| """ | |
| Draw a follow up comic a scene out of the following: | |
| Panel Description: | |
| The character peeks out from behind the tree again, eyes wide but now with a mix of relief and lingering tension. Their posture is slightly more relaxed but still cautious. On the forest path, a wild boar charges through, kicking up dirt and leaves as it rushes past. The scene has a sense of movement, with motion lines emphasizing the boar’s speed. The atmosphere remains dense with trees and shadows, but the immediate danger seems to have passed. | |
| Dialogue (Character): | |
| “Huh… that was close.” | |
| """, | |
| output="image", | |
| ).extend_result(), | |
| ).execute() | |
| with open("./comic.md", "w") as file: | |
| file.write(comic.as_string(include_data=True)) | |
| run(main()) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run using uv:
uv -n run gemini_comic.pyinstall uv (optional):
curl -LsSf https://astral.sh/uv/install.sh | sh