From 4990df20109cf71699237124239cf6a65143594c Mon Sep 17 00:00:00 2001 From: Mike Lay Date: Mon, 13 Jul 2026 18:54:22 -0700 Subject: [PATCH 1/6] New model and llama.cpp --- .github/workflows/poem.yml | 2 +- Dockerfile | 11 ------- README.md | 4 ++- action.py | 39 ---------------------- action.yml | 67 +++++++++++++++++++++++++++++++++++--- 5 files changed, 66 insertions(+), 57 deletions(-) delete mode 100644 Dockerfile delete mode 100644 action.py diff --git a/.github/workflows/poem.yml b/.github/workflows/poem.yml index afddd4f..34bc6b3 100644 --- a/.github/workflows/poem.yml +++ b/.github/workflows/poem.yml @@ -13,7 +13,7 @@ jobs: steps: - name: PR Poet id: poet - uses: mkly/pr-poet@v1.1.0 + uses: mkly/pr-poet@main with: message: ${{ github.event.pull_request.title }} - name: Post comment to PR diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 8d62aa4..0000000 --- a/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM python:3.11-slim -RUN apt-get update && apt-get install -y curl -RUN pip --no-cache-dir install ctransformers - -WORKDIR /action -ADD action.py /action -RUN curl -LO https://huggingface.co/TheBloke/orca_mini_3B-GGML/resolve/main/orca-mini-3b.ggmlv3.q4_0.bin -o /action/orca-mini-3b.ggmlv3.q4_0.bin - -ENV TRANSFORMERS_OFFLINE=1 - -ENTRYPOINT ["python", "-u", "/action/action.py"] diff --git a/README.md b/README.md index 792366b..a51ce9f 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ A Github action to turn commits and other comments into poetry +This action installs the [llama.cpp](https://github.com/ggml-org/llama.cpp) CLI in the workflow and runs [Gemma 4 E2B Q8_0](https://huggingface.co/ggml-org/gemma-4-E2B-it-GGUF). The CLI downloads the model when the action runs. + A PR title of **_Fix silly typo in readme_** would yield something similar to: > In reads that end with a whim,
@@ -33,7 +35,7 @@ jobs: steps: - name: PR Poet id: poet - uses: mkly/pr-poet@v1.0.9 + uses: mkly/pr-poet@main with: message: ${{ github.event.pull_request.title }} - name: Post comment to PR diff --git a/action.py b/action.py deleted file mode 100644 index b392919..0000000 --- a/action.py +++ /dev/null @@ -1,39 +0,0 @@ -from ctransformers import AutoModelForCausalLM, AutoConfig, Config -import re -import os - -config = AutoConfig( - model_type='llama', - config=Config( - max_new_tokens=89, - ) -) -llm = AutoModelForCausalLM.from_pretrained('/action/orca-mini-3b.ggmlv3.q4_0.bin', config=config) - -commit_message = os.getenv('INPUT_MESSAGE') - -prompt = f""" -COMMIT: Allow RSS feed to be cached if user is logged in. -POEM: -LINE_ONE: In feeds that dance on screens so bright, -LINE_TWO: A user logged, enjoys the sight, -LINE_THREE: Caching RSS, a seamless flow, -LINE_FOUR: Connection's embrace, a glow to show. - -COMMIT: Bring back try/catch for 5.1 -POEM: -LINE_ONE: In 5.1, a plea to mend, -LINE_TWO: Bring back try/catch, an old friend, -LINE_THREE: Errors caught, a graceful dance, -LINE_FOUR: Code's embrace in a second chance. - -COMMIT: {commit_message} -POEM: -""" - -result = str(llm(prompt)) -lines = result.split("\n") -poem = re.sub("LINE_ONE: |LINE_TWO: |LINE_THREE: |LINE_FOUR: ", "", "\n".join(lines[:4])) - -with open(os.getenv('GITHUB_OUTPUT', 'none.txt'), "w") as file: - file.write(f'poem<> "${GITHUB_OUTPUT}" From 15c6ca801e30e774b2fd40f436954a2a345511fa Mon Sep 17 00:00:00 2001 From: Mike Lay Date: Mon, 13 Jul 2026 20:05:24 -0700 Subject: [PATCH 2/6] Use pr token --- .github/workflows/poem.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/poem.yml b/.github/workflows/poem.yml index 34bc6b3..f71da38 100644 --- a/.github/workflows/poem.yml +++ b/.github/workflows/poem.yml @@ -19,7 +19,6 @@ jobs: - name: Post comment to PR uses: actions/github-script@v6 with: - github-token: ${{ secrets.PAT_TOKEN }} script: | await github.rest.issues.createComment({ issue_number: context.issue.number, From 4ca863f6826199dbf589761c0d6f38603827a894 Mon Sep 17 00:00:00 2001 From: Mike Lay Date: Mon, 13 Jul 2026 20:32:31 -0700 Subject: [PATCH 3/6] Smaller model --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 1e9d2e7..18b1001 100644 --- a/action.yml +++ b/action.yml @@ -55,7 +55,7 @@ runs: prompt="COMMIT: ${MESSAGE}"$'\nPOEM:\n' response="$( "${HOME}/.local/bin/llama" completion \ - -hf ggml-org/gemma-4-E2B-it-GGUF:Q8_0 \ + -hf bartowski/microsoft_Phi-4-mini-instruct-GGUF \ -sys "${system_prompt}" \ -p "${prompt}" \ --jinja \ From 73fb5b5a680c4c1dd5d31e4a5d8bbe2a81006601 Mon Sep 17 00:00:00 2001 From: Mike Lay Date: Mon, 13 Jul 2026 20:43:05 -0700 Subject: [PATCH 4/6] Log poem --- action.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/action.yml b/action.yml index 18b1001..336c201 100644 --- a/action.yml +++ b/action.yml @@ -68,6 +68,9 @@ runs: | sed 's/\[end of text\].*$//' \ | sed -nE 's/^[[:space:]]*LINE_(ONE|TWO|THREE|FOUR):[[:space:]]*//p' \ | head -n 4)" + echo "==== poem ====" + echo ${poem} + echo "==============" { echo 'poem< Date: Mon, 13 Jul 2026 20:52:22 -0700 Subject: [PATCH 5/6] Use JSON instead --- .github/workflows/poem.yml | 5 ++++- action.yml | 41 ++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/poem.yml b/.github/workflows/poem.yml index f71da38..a9cde99 100644 --- a/.github/workflows/poem.yml +++ b/.github/workflows/poem.yml @@ -18,11 +18,14 @@ jobs: message: ${{ github.event.pull_request.title }} - name: Post comment to PR uses: actions/github-script@v6 + env: + POEM_JSON: ${{ steps.poet.outputs.poem }} with: script: | + const poem = JSON.parse(process.env.POEM_JSON) await github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: `${{steps.poet.outputs.poem}}` + body: [poem.line_one, poem.line_two, poem.line_three, poem.line_four].join('\n') }) diff --git a/action.yml b/action.yml index 336c201..20317ed 100644 --- a/action.yml +++ b/action.yml @@ -10,7 +10,7 @@ inputs: required: true outputs: poem: - description: 'The poem' + description: 'The poem as a JSON object with line_one through line_four' value: ${{ steps.poet.outputs.poem }} runs: using: 'composite' @@ -37,22 +37,19 @@ runs: run: | system_prompt="$(cat <<'SYSTEM_PROMPT' COMMIT: Allow RSS feed to be cached if user is logged in. - POEM: - LINE_ONE: In feeds that dance on screens so bright, - LINE_TWO: A user logged, enjoys the sight, - LINE_THREE: Caching RSS, a seamless flow, - LINE_FOUR: Connection's embrace, a glow to show. + JSON: + {"line_one":"In feeds that dance on screens so bright,","line_two":"A user logged, enjoys the sight,","line_three":"Caching RSS, a seamless flow,","line_four":"Connection's embrace, a glow to show."} COMMIT: Bring back try/catch for 5.1 - POEM: - LINE_ONE: In 5.1, a plea to mend, - LINE_TWO: Bring back try/catch, an old friend, - LINE_THREE: Errors caught, a graceful dance, - LINE_FOUR: Code's embrace in a second chance. + JSON: + {"line_one":"In 5.1, a plea to mend,","line_two":"Bring back try/catch, an old friend,","line_three":"Errors caught, a graceful dance,","line_four":"Code's embrace in a second chance."} + + Return only a valid JSON object with string fields line_one, line_two, + line_three, and line_four. Do not use Markdown fences. SYSTEM_PROMPT )" - prompt="COMMIT: ${MESSAGE}"$'\nPOEM:\n' + prompt="COMMIT: ${MESSAGE}"$'\nJSON:\n' response="$( "${HOME}/.local/bin/llama" completion \ -hf bartowski/microsoft_Phi-4-mini-instruct-GGUF \ @@ -66,13 +63,13 @@ runs: final_response="${response##*}" poem="$(printf '%s\n' "${final_response}" \ | sed 's/\[end of text\].*$//' \ - | sed -nE 's/^[[:space:]]*LINE_(ONE|TWO|THREE|FOUR):[[:space:]]*//p' \ - | head -n 4)" - echo "==== poem ====" - echo ${poem} - echo "==============" - { - echo 'poem<> "${GITHUB_OUTPUT}" + | jq -ce ' + if type == "object" + and (.line_one | type == "string" and length > 0) + and (.line_two | type == "string" and length > 0) + and (.line_three | type == "string" and length > 0) + and (.line_four | type == "string" and length > 0) + then {line_one, line_two, line_three, line_four} + else error("response is not a four-line poem JSON object") + end')" + printf 'poem=%s\n' "${poem}" >> "${GITHUB_OUTPUT}" From a609fe4aac43fc36480711ebbbaf525f8b600e31 Mon Sep 17 00:00:00 2001 From: Mike Lay Date: Mon, 13 Jul 2026 20:53:22 -0700 Subject: [PATCH 6/6] Update instructions in HELLO.md Added a test note to the instructions for creating a PR. --- HELLO.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HELLO.md b/HELLO.md index 37bf6b3..29afed4 100644 --- a/HELLO.md +++ b/HELLO.md @@ -1,7 +1,7 @@ Hello! ------ -Use this file to edit and create a PR to get a poem. Feel free to get creative with the title of your pull request to help generate and exciting response. +Use this file to edit and create a PR to get a poem. Feel free to get creative with the title of your pull request to help generate and exciting response. Test. ``` __