The index.py module#
Summary#
One row of |
|
One search hit from the index. |
|
Lightweight searchable index over PyFluent’s |
Return the 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. (Seeansys.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.tnow 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 (energy → setup.models.energy) outrank deeper
family matches. The depth penalty discourages picking generic
ancestors over leaf parameters.