The index.py module#

Summary#

ApiEntry

One row of api_objects.json.

ApiSearchHit

One search hit from the index.

ApiIndex

Lightweight searchable index over PyFluent’s api_objects.json.

get_default_api_index

Return the default API index.

reset_default_api_index

Test hook that drops the cached index so that the next call rebuilds.

Description#

Lexical fallback over the PyFluent API catalog (the default in practice).

This module is the SOLE actively-running retriever for every default install.

It reads ansys/fluent/core/generated/api_tree/api_objects.json (shipped with ansys-fluent-core) and offers three operations used by orchestration:

  • ApiIndex.search(): BM25 ranking over the union of path tokens and PyFluent class docstring tokens. (See ansys.fluent.mcp.common.api_help). Cheap, dependency free, and much stronger than the previous token-overlap scorer for free-text queries. For example, “temperature of incoming gas” → velocity_inlet.thermal.t now works because the leaf class’s docstring contains the word temperature.

  • ApiIndex.lookup(): Exact dotted-path resolution.

  • ApiIndex.children_of(): Immediate API children of a path For example, used to walk a boundary condition kind to enumerate its property leaves.

The scoring formula follows. Also see _score_entry()):

bm25(query_tokens, entry_tokens)
  + 0.25 * (#query_token substring matches in path)
  - 0.05 * (path depth in dots)

The substring bonus preserves the historic behavior where exact segment matches (energysetup.models.energy) outrank deeper family matches. The depth penalty discourages picking generic ancestors over leaf parameters.

Module detail#

index.get_default_api_index() ApiIndex#

Return the default API index.

Returns:
ApiIndex

API index produced by the operation.

index.reset_default_api_index() None#

Test hook that drops the cached index so that the next call rebuilds.

Returns:
None

The function completes through its side effects.