build_index_v2

Build the OnField Assistant RAG index from scratch.

Sources:
  1. OpenFOAM-13 tutorials, src headers, applications headers, etc/caseDicts - system/, 0/, constant/ files: whole-file (up to 16 KB), then split - .H source headers: 2000-char chunks

  2. 13 Municchi et al. arXiv papers (fetched from arxiv.org/html/…)

  3. Kestrel HPC system documentation (local markdown files)

Run on a GPU/compute node (not login node) for speed.

Functions

build()

chunk_text(text, size, overlap)

Split text into overlapping chunks, preferring newline breaks.

collect_kestrel_docs()

collect_of13()

Return (filepath, context) for all OF-13 files.

index_kestrel(model, collection)

index_of13(model, collection)

index_papers(model, collection)

is_case_dict_file(filepath)

True if file lives in system/, 0/, or constant/ under a tutorial case.

load_paper_text(arxiv_id)

Load paper text from local cache, falling back to arXiv HTML fetch.

make_of_prefix(filepath, context)

should_index_of_file(filepath, context)

should_skip_dir(name)

stable_id(*parts)

Create a stable, filesystem-safe ID from arbitrary string parts.

walk_of(root, context)

build_index_v2.should_skip_dir(name)[source]
Parameters:

name (str)

Return type:

bool

build_index_v2.chunk_text(text, size, overlap)[source]

Split text into overlapping chunks, preferring newline breaks.

Parameters:
Return type:

list[str]

build_index_v2.stable_id(*parts)[source]

Create a stable, filesystem-safe ID from arbitrary string parts.

Return type:

str

build_index_v2.is_case_dict_file(filepath)[source]

True if file lives in system/, 0/, or constant/ under a tutorial case.

Parameters:

filepath (Path)

Return type:

bool

build_index_v2.should_index_of_file(filepath, context)[source]
Parameters:
Return type:

bool

build_index_v2.walk_of(root, context)[source]
Parameters:
Return type:

list[Path]

build_index_v2.collect_of13()[source]

Return (filepath, context) for all OF-13 files.

Return type:

list[tuple[Path, str]]

build_index_v2.make_of_prefix(filepath, context)[source]
Parameters:
Return type:

str

build_index_v2.index_of13(model, collection)[source]
Return type:

int

build_index_v2.collect_kestrel_docs()[source]
Return type:

list[Path]

build_index_v2.index_kestrel(model, collection)[source]
Return type:

int

build_index_v2.load_paper_text(arxiv_id)[source]

Load paper text from local cache, falling back to arXiv HTML fetch.

Parameters:

arxiv_id (str)

Return type:

str | None

build_index_v2.index_papers(model, collection)[source]
Return type:

int

build_index_v2.build()[source]