Skip to content

Add R tool to build Gmail newsletter digests with local Ollama and README - #12

Open
charles-hebert wants to merge 1 commit into
mainfrom
codex/create-newsletter-digest-using-ollama
Open

Add R tool to build Gmail newsletter digests with local Ollama and README#12
charles-hebert wants to merge 1 commit into
mainfrom
codex/create-newsletter-digest-using-ollama

Conversation

@charles-hebert

Copy link
Copy Markdown
Owner

Motivation

  • Provide a lightweight, local workflow to pull newsletter-like emails from Gmail and generate a concise digest using a local Ollama model.
  • Enable user preference guidance and a recommended feedback loop to iteratively improve relevance while keeping data local/private.

Description

  • Add gmail_newsletter_digest.R, a CLI R script that fetches messages via gmailr, extracts text, builds a JSON prompt, and calls a local Ollama instance via httr2 to generate a digest.
  • Implement helper functions including fetch_newsletters, extract_text, build_prompt, and call_ollama, and add argument parsing with argparse and default flags like --query, --ollama-model, and --output.
  • Add NEWSLETTER_DIGEST_README.md with setup instructions, example Rscript run command, recommended Gmail queries, and a simple preference/rating feedback loop for matching improvements.
  • Document required packages and note use of credentials.json for Gmail OAuth and default Ollama host http://127.0.0.1:11434.

Testing

  • No automated tests were run for this change.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread gmail_newsletter_digest.R
if (length(ids) == 0) return(list())

out <- list()
for (id in ids$id) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment thread gmail_newsletter_digest.R
target <- plain_part %||% html_part
if (is.null(target)) return("")

raw <- base64urldecode(target$body$data)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant