falaw.refresh#
Refresh fal.ai docs locally with conditional GETs.
Three layers, cheapest first:
is_stale(source)— HEAD withIf-None-Match; near-zero cost.fetch_if_changed(source)— conditional GET; saves and snapshots if changed.refresh_llms()/refresh_full_docs()— coordinate fetches across the doc set, save previous-version snapshots for diffing, journal results.
State (per-source ETag and Last-Modified) is kept under
$FALAW_DATA_DIR/refresh/state.json (default ~/.config/falaw/refresh/);
previous-version snapshots live alongside as <source>.prev so a successful
refresh can be diffed against the prior content.
For scheduled / remote runs, set FALAW_DATA_DIR to a path inside the
repo (e.g. misc/falaw_state) so journal entries and refresh state are
committed back to the repo on each run.
Functions
|
|
|
Unified diff: previous snapshot vs current local file. |
|
Conditional GET. |
|
Cheap HEAD: True iff the upstream ETag differs from saved state. |
|
Re-crawl per-page docs and rebuild |
|
Refresh |
Return the saved per-source refresh state (etags, last fetch times). |
Classes
|
A single document mirrored locally. |
- class falaw.refresh.DocSource(*, name, url, local_path)[source]#
Bases:
objectA single document mirrored locally.
- falaw.refresh.diff_against_previous(source, *, n_context=3)[source]#
Unified diff: previous snapshot vs current local file.
- Return type:
- falaw.refresh.fetch_if_changed(source, *, save_snapshot=True)[source]#
Conditional GET. Updates the local file and saved state on a real change.
Returns
(changed, body):changedis False on 304 (or any non-200);bodyis the new text only when changed.
- falaw.refresh.is_stale(source, *, state=None)[source]#
Cheap HEAD: True iff the upstream ETag differs from saved state.
- Return type:
- falaw.refresh.refresh_full_docs(*, docs_dir=None, max_workers=16, force=False, journal=True)[source]#
Re-crawl per-page docs and rebuild
fal_ai_docs_full.md.- Return type: