-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
47 lines (36 loc) · 1.44 KB
/
script.py
File metadata and controls
47 lines (36 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""Script generation module — turns commit summaries into a 6-panel comic script via Gemini Flash."""
import json
import os
import re
def generate_comic_script(
commits_summary: str,
system_prompt: str,
lang_addon: str,
api_key: str = None,
) -> dict:
"""Use Gemini to turn commit summaries into a comic script.
Args:
commits_summary: Summarised git commits / standup notes.
system_prompt: The base system prompt (e.g. contents of config/script_system.md).
lang_addon: Language-specific addendum (e.g. contents of config/language_en.md).
api_key: Google API key. Falls back to GOOGLE_API_KEY env var.
Returns:
Parsed JSON dict representing the 6-panel comic script.
"""
from google import genai
from google.genai import types
client = genai.Client(api_key=api_key or os.environ.get("GOOGLE_API_KEY"))
system = system_prompt + "\n\n" + lang_addon
response = client.models.generate_content(
model="gemini-2.5-flash",
contents=f"Here are this week's git commits from our dev team:\n{commits_summary}\n\nWrite the 6-panel comic strip script!",
config=types.GenerateContentConfig(
system_instruction=system,
temperature=1.0,
),
)
raw = response.text.strip()
# Strip markdown fences if present
raw = re.sub(r"^```(?:json)?\s*", "", raw)
raw = re.sub(r"\s*```$", "", raw)
return json.loads(raw)