Add OSFI speeches RAG ingestion pipeline (R script + docs) - #7
Add OSFI speeches RAG ingestion pipeline (R script + docs)#7charles-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: dfe7571f1a
ℹ️ 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".
| missing_content_urls <- existing_speeches |> | ||
| filter(status != "removed", is.na(text_path) | !file_exists(path(base_dir, text_path))) |> | ||
| pull(url) |
There was a problem hiding this comment.
Restrict missing-content refetches to listed URLs
missing_content_urls is computed from all non-removed historical rows, but it is not intersected with current_urls. If a previously active speech disappears from the live listing and its local text file is missing, its URL gets into urls_to_fetch, listing_tbl |> filter(url == !!url) returns zero rows, and process_new_speech() then calls safe_response() with an empty URL, aborting the run before removal status can be updated. This breaks unattended runs in the exact recovery scenario this branch is trying to handle.
Useful? React with 👍 / 👎.
| } | ||
|
|
||
| hash_file_sha256 <- function(path_to_file) { | ||
| digest::digest(file = path_to_file, algo = "sha256") |
There was a problem hiding this comment.
Validate digest package availability before hashing
The pipeline unconditionally calls digest::digest() when writing each speech record, but digest is neither loaded nor included in the declared required package list. On hosts where digest is not preinstalled, the job will fail at runtime after fetching content, causing partial outputs and making the script non-portable for unattended deployment.
Useful? React with 👍 / 👎.
Motivation
deletion_dateandremoved_detected_onfor downstream ingestion/upserts.Description
osfi_speeches_rag_pipeline.R, an Rscript that paginates the OSFI news index, extracts speech pages, saves raw HTML and cleaned text, chunks text into overlapping windows, and optionally requests OpenAI embeddings whenOSFI_EMBED_PROVIDER=openaiandOPENAI_API_KEYare set.metadata/speech_table.csv, a chunk table atvector/speech_chunks.csv, a JSONL hand-off atvector/speech_chunks.jsonl, and an optional Parquet atvector/speech_chunks.parquetwhen thearrowpackage is installed.httr2, speaker detection heuristics, sha256 checksums for text files, and status updates for speeches that disappear from the live index.osfi_speeches_rag_pipeline.mddocumenting outputs, deployment patterns (CRON/n8n), configuration flags/environment variables, and example usage.Testing
Codex Task