Zine rencontre les Pull Requests (et plus)

La disponibilité de nouveaux générateurs d’images comme OpenAI gpt-image-1
ouvre la porte à d’innombrables nouvelles façons de visualiser et d’annoter les artefacts logiciels.
“Zine” est une forme d’art graphique populaire qui combine texte et images pour raconter une histoire. Peut-on demander au LLM de générer un zine à partir d’un diff de pull request ? voix robotique hors ligne : Oui, nous le pouvons.
Le script ci-dessous est une transformation en 2 étapes à l’aide du LLM du pull request en zine :
- utiliser
gpt-4.1-mini
pour transformer le diff en une invite pour génération d’image - utiliser
gpt-image-1
pour générer l’image à partir de cette invite -
- un peu de plomberie pour téléverser l’image générée dans une branche et l’ajouter à la description de la pull request
script({ title: "Pull Request Ziner", description: "Generate a zine from a pull request description from the git diff", temperature: 0.5, systemSafety: true, parameters: { base: { type: "string", description: "The base branch of the pull request", }, maxTokens: { type: "number", description: "The maximum number of tokens to generate", default: 14000, }, },});const { vars, output, dbg } = env;const maxTokens = vars.maxTokens;const defaultBranch = vars.base || (await git.defaultBranch());const branch = await git.branch();if (branch === defaultBranch) cancel("you are already on the default branch");
// compute diffconst changes = await git.diff({ base: defaultBranch,});console.log(changes);if (!changes) cancel("no changes found");
// generate mapconst { text: zine } = await runPrompt( (ctx) => { const gd = ctx.def("GIT_DIFF", changes, { maxTokens, detectPromptInjection: "available", }); ctx.$`You are an expert zine cartoon artist, prompt genius and omniscient code developer. You will summarize the code in the git diff ${gd} and generate a description of the changes as a zine. The description will be used by a LLM to generate an image of the zine. The zine will be used to tell "tell the story" of the changes. Be descriptive about the visual features of the zine as you would for a zine. Use names from the code symbols. MINIMIZE THE USE OF TEXT, FAVOR GRAPHICS. do NOT explain that GIT_DIFF displays changes in the codebase try to extract the intent of the changes, don't focus on the details Avoid studio ghibli style. The model has a context window of 4096 tokens. The output image is landscape. Generate a single page zine for all panels/pages. `.role("system"); }, { label: "summarize code to zine", model: "large", },);const { image } = (await generateImage( `Your task is to generate a Zine with the following instruction. Minimize the use of text, favor graphics. ${zine}`, { model: "image", quality: "high", size: "landscape", outputFormat: "jpeg", maxWidth: 800, }, )) || {};if (!image) cancel("no image found");const ghFile = await github.uploadAsset(image);await output.image(ghFile, "zine");
Sketchnotes (mise à jour)
Section intitulée « Sketchnotes (mise à jour) »“Sketchnotes” est un autre style de prise de notes visuelle qui combine des éléments dessinés à la main avec du texte pour transmettre des informations. C’est une excellente façon de résumer une pull request et de la rendre plus attrayante.
script({ title: "Pull Request Visual Sketch", description: "Generate a visual note from a pull request description from the git diff", temperature: 0.5, systemSafety: true, parameters: { base: { type: "string", description: "The base branch of the pull request", }, maxTokens: { type: "number", description: "The maximum number of tokens to generate", default: 14000, }, },});const { vars, output, dbg } = env;const maxTokens = vars.maxTokens;const defaultBranch = vars.base || (await git.defaultBranch());const branch = await git.branch();if (branch === defaultBranch) cancel("you are already on the default branch");
// compute diffconst changes = await git.diff({ base: defaultBranch,});console.log(changes);if (!changes) cancel("no changes found");
// generate mapconst { text: zine } = await runPrompt( (ctx) => { const gd = ctx.def("GIT_DIFF", changes, { maxTokens, detectPromptInjection: "available", }); ctx.$`You are an expert at sketchnotes (visual note taking), prompt genius and omniscient code developer. You will summarize the code in the git diff ${gd} and generate a sketchnote (visual note) for the changes. The description will be used by a LLM to generate an image of the zine. Use names from the code symbols. MINIMIZE THE USE OF TEXT, FAVOR GRAPHICS. do NOT explain that GIT_DIFF displays changes in the codebase try to extract the intent of the changes, don't focus on the details Avoid studio ghibli style. Ignore the low-level programming language details, focus on the high-level concepts. The model has a context window of 4096 tokens. The output image is landscape. `.role("system"); }, { label: "summarize code to sketch", model: "large", },);const { image } = (await generateImage( `Your task is to generate a SketchNote (visual note) with the following instruction. Minimize the use of text, favor graphics. ${zine}`, { model: "image", quality: "high", size: "landscape", outputFormat: "jpeg", maxWidth: 800, }, )) || {};if (!image) cancel("no image found");const ghFile = await github.uploadAsset(image);await output.image(ghFile, "sketch");
Qu’en est-il des autres styles ?
Section intitulée « Qu’en est-il des autres styles ? »Pour pousser l’idée encore plus loin, nous pouvons demander au LLM de choisir un style graphique aléatoire et de générer un diff de pull request dans ce style. Cette idée a été appliquée dans https://github.com/microsoft/genaiscript/pull/1512.
- collage
- mural
- illustration éditoriale
Le zine est une manière ludique de visualiser le diff de la pull request. Ce n’est pas parfait mais c’est attrayant et peut-être que c’est tout ce dont vous avez besoin pour inciter quelqu’un à revoir votre PR !
Il y aura d’autres façons de visualiser le logiciel à l’avenir, grâce à ces incroyables générateurs d’images.