Add R tool to build Gmail newsletter digests with local Ollama and README - #12
Add R tool to build Gmail newsletter digests with local Ollama and README#12charles-hebert wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5b20d36128
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (length(ids) == 0) return(list()) | ||
|
|
||
| out <- list() | ||
| for (id in ids$id) { |
There was a problem hiding this comment.
Iterate with gm_id instead of ids$id
gm_messages() returns a gmail_messages collection, not a flat object with an id field, so ids$id is NULL and this loop never runs. In practice, fetch_newsletters() returns an empty list even when the query matches emails, which makes main() always emit "No messages found for this query." Extract message IDs first (e.g., via gm_id(ids, "message_id")) before calling gm_message().
Useful? React with 👍 / 👎.
| target <- plain_part %||% html_part | ||
| if (is.null(target)) return("") | ||
|
|
||
| raw <- base64urldecode(target$body$data) |
There was a problem hiding this comment.
Use supported base64 URL decoder
extract_text() calls base64urldecode(), which is not the current gmailr decode helper name, so decoding message bodies can fail at runtime with a missing-function error. Once any fetched message contains body data, digest generation breaks instead of producing output; switch to the supported decoder (base64url_decode/base64url_decode_to_char).
Useful? React with 👍 / 👎.
Motivation
Description
gmail_newsletter_digest.R, a CLI R script that fetches messages viagmailr, extracts text, builds a JSON prompt, and calls a local Ollama instance viahttr2to generate a digest.fetch_newsletters,extract_text,build_prompt, andcall_ollama, and add argument parsing withargparseand default flags like--query,--ollama-model, and--output.NEWSLETTER_DIGEST_README.mdwith setup instructions, exampleRscriptrun command, recommended Gmail queries, and a simple preference/rating feedback loop for matching improvements.credentials.jsonfor Gmail OAuth and default Ollama hosthttp://127.0.0.1:11434.Testing
Codex Task