diff --git a/generator.py b/generator.py index 878af91..fb74377 100644 --- a/generator.py +++ b/generator.py @@ -36,6 +36,24 @@ INSTRUCTIONS_FILE = "INSTRUCTIONS.md" GEMINI_MODEL = "gemini-flash-latest" GEMINI_BASE_URL = "https://generativelanguage.googleapis.com/v1beta/models" +WRITE_PROMPT_TEMPLATE = """Please read the following instructions carefully and follow them to write a blog post. + +## INSTRUCTIONS + +{instructions} + +## TASK + +Read the source content below and write a blog post from it in {original_lang} language. Output only the blog post in Markdown format, with no additional commentary. + +## SOURCE CONTENT + +{source}""" + +TRANSLATE_PROMPT_TEMPLATE = """Translate the following Markdown blog post into {translate_lang}. Preserve all Markdown formatting, headings, links, and code blocks exactly. Output only the translated Markdown with no additional commentary. + +{blogpost}""" + # --------------------------------------------------------------------------- # Helpers @@ -156,15 +174,10 @@ def cmd_write(args): print(f"→ Generating blog post in {original_lang} with Gemini...") - prompt = ( - "Please read the following instructions carefully and follow them to write a blog post.\n\n" - "## INSTRUCTIONS\n\n" - f"{instructions}\n\n" - "## TASK\n\n" - f"Read the source content below and write a blog post from it in {original_lang} language. " - "Output only the blog post in Markdown format, with no additional commentary.\n\n" - "## SOURCE CONTENT\n\n" - f"{source}" + prompt = WRITE_PROMPT_TEMPLATE.format( + instructions=instructions, + original_lang=original_lang, + source=source ) result = gemini_generate(api_key, prompt) @@ -180,11 +193,9 @@ def cmd_translate(args): print(f"→ Translating blog post to {translate_lang} with Gemini...") - prompt = ( - f"Translate the following Markdown blog post into {translate_lang}. " - "Preserve all Markdown formatting, headings, links, and code blocks exactly. " - "Output only the translated Markdown with no additional commentary.\n\n" - f"{blogpost}" + prompt = TRANSLATE_PROMPT_TEMPLATE.format( + translate_lang=translate_lang, + blogpost=blogpost ) result = gemini_generate(api_key, prompt)