Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/poem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ 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
uses: actions/github-script@v6
env:
POEM_JSON: ${{ steps.poet.outputs.poem }}
with:
github-token: ${{ secrets.PAT_TOKEN }}
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')
})
11 changes: 0 additions & 11 deletions Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion HELLO.md
Original file line number Diff line number Diff line change
@@ -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.

```
__
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,<br/>
Expand Down Expand Up @@ -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
Expand Down
39 changes: 0 additions & 39 deletions action.py

This file was deleted.

69 changes: 63 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'PR Poet'
description: 'Poestic musings for pull requests and other GitHub activity'
description: 'Poetic musings for pull requests and other GitHub activity'
author: 'Mike Lay'
branding:
icon: 'book-open'
Expand All @@ -10,9 +10,66 @@ 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: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.message }}
using: 'composite'
steps:
- name: Restore llama CLI and model caches
uses: actions/cache@v4
with:
path: |
~/.local/bin/llama
~/.cache/huggingface
~/.cache/llama.cpp
key: pr-poet-llama-${{ runner.os }}-${{ runner.arch }}-gemma-4-e2b-q8
- name: Install llama.cpp CLI
shell: bash
run: |
if [[ ! -x "${HOME}/.local/bin/llama" ]]; then
curl -LsSf https://llama.app/install.sh | sh
fi
- name: Write poem
id: poet
shell: bash
env:
MESSAGE: ${{ inputs.message }}
run: |
system_prompt="$(cat <<'SYSTEM_PROMPT'
COMMIT: Allow RSS feed to be cached if user is logged in.
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
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}"$'\nJSON:\n'
response="$(
"${HOME}/.local/bin/llama" completion \
-hf bartowski/microsoft_Phi-4-mini-instruct-GGUF \
-sys "${system_prompt}" \
-p "${prompt}" \
--jinja \
--single-turn \
--log-disable \
--no-display-prompt
)"
final_response="${response##*<channel|>}"
poem="$(printf '%s\n' "${final_response}" \
| sed 's/\[end of text\].*$//' \
| 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}"
Loading