Suggest Similar • AI Agent SDK

suggest_similar: Find the most similar string from candidates using Levenshtein distance.

suggest_similar

Function

</div>

This function is defined in the parse_utils module.

Find the most similar string from candidates using Levenshtein distance.

This function is ONLY called on error paths, never on happy paths.

Signature

python
def suggest_similar(value: str, candidates: Iterable[str], max_distance: int) -> Optional[str]

Parameters

ParamField str

The invalid value

ParamField Iterable[str]

Valid options to compare against

ParamField int

Maximum edit distance to consider a match

Returns

ResponseField Optional[str]

Most similar candidate if within max_distance, None otherwise

Used By

Source

View on GitHub

praisonaiagents/config/parse_utils.py at line 103