Skip to main content

agrag.ingestion.resolve.candidate_source.read_candidates

read_candidates(source:GraphCandidateSource, mention:ExtractedEntity, *, error_policy:ErrorPolicy) -> tuple[list[tuple[Entity, float]], StageFailure | None]

Read the persisted candidates for one mention, or report the failure.

A failed read is not an empty result: a mention with no candidates would become a new entity, so the caller must skip a mention whose read failed.

Parameters:

  • source (GraphCandidateSource) – The candidate source to read.
  • mention (ExtractedEntity) – The mention to find persisted candidates for.
  • error_policy (ErrorPolicy) – RAISE propagates the failure; any other policy returns it as a StageFailure.

Returns:

  • list[tuple[Entity, float]] – The (Entity, score) pairs and None when the read succeeded, or
  • StageFailure | None – an empty list and the StageFailure when it failed.

Raises:

  • Exception – The read failed and error_policy is RAISE.