prompt consts

This commit is contained in:
2026-03-04 22:15:21 +01:00
parent 25a43814dd
commit 1407653eeb

View File

@@ -36,6 +36,24 @@ INSTRUCTIONS_FILE = "INSTRUCTIONS.md"
GEMINI_MODEL = "gemini-flash-latest" GEMINI_MODEL = "gemini-flash-latest"
GEMINI_BASE_URL = "https://generativelanguage.googleapis.com/v1beta/models" 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 # Helpers
@@ -156,15 +174,10 @@ def cmd_write(args):
print(f"→ Generating blog post in {original_lang} with Gemini...") print(f"→ Generating blog post in {original_lang} with Gemini...")
prompt = ( prompt = WRITE_PROMPT_TEMPLATE.format(
"Please read the following instructions carefully and follow them to write a blog post.\n\n" instructions=instructions,
"## INSTRUCTIONS\n\n" original_lang=original_lang,
f"{instructions}\n\n" source=source
"## 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}"
) )
result = gemini_generate(api_key, prompt) result = gemini_generate(api_key, prompt)
@@ -180,11 +193,9 @@ def cmd_translate(args):
print(f"→ Translating blog post to {translate_lang} with Gemini...") print(f"→ Translating blog post to {translate_lang} with Gemini...")
prompt = ( prompt = TRANSLATE_PROMPT_TEMPLATE.format(
f"Translate the following Markdown blog post into {translate_lang}. " translate_lang=translate_lang,
"Preserve all Markdown formatting, headings, links, and code blocks exactly. " blogpost=blogpost
"Output only the translated Markdown with no additional commentary.\n\n"
f"{blogpost}"
) )
result = gemini_generate(api_key, prompt) result = gemini_generate(api_key, prompt)