Interface LedgerClient


public interface LedgerClient
Client for fetching records from the ledger, the log of recorded agent interactions and their evaluations.

A LedgerClient can be injected into any component. An Evaluator uses it to fetch the interaction referenced by its Subject.interactionId().

Not for user extension.

  • Method Details

    • getInteraction

      InteractionRecord getInteraction(String interactionId)
      Fetch the full record for the interaction with the given (globally unique) interactionId.

      Blocks the calling thread until the record has been fetched. Safe to call on a virtual thread. Use getInteractionAsync(String) for the non-blocking variant.

      Parameters:
      interactionId - the globally unique id of the interaction to fetch
      Returns:
      the interaction record
      Throws:
      NoSuchElementException - if no interaction exists with that id
    • getInteractionAsync

      CompletionStage<InteractionRecord> getInteractionAsync(String interactionId)
      Async variant of getInteraction(String).
      Parameters:
      interactionId - the globally unique id of the interaction to fetch
      Returns:
      a stage that completes with the interaction record, or fails with NoSuchElementException if no interaction exists with that id
    • getEvaluation

      EvaluationRecord getEvaluation(String evaluationId)
      Fetch the record for the evaluation with the given evaluationId. An evaluation is recorded when it terminates, so the record exists only once the evaluation has finished.

      Blocks the calling thread until the record has been fetched. Safe to call on a virtual thread. Use getEvaluationAsync(String) for the non-blocking variant.

      Parameters:
      evaluationId - the globally unique id of the evaluation to fetch
      Returns:
      the evaluation record
      Throws:
      NoSuchElementException - if no evaluation exists with that id
    • getEvaluationAsync

      CompletionStage<EvaluationRecord> getEvaluationAsync(String evaluationId)
      Async variant of getEvaluation(String).
      Parameters:
      evaluationId - the globally unique id of the evaluation to fetch
      Returns:
      a stage that completes with the evaluation record, or fails with NoSuchElementException if no evaluation exists with that id
    • getEvaluations

      List<EvaluationRecord> getEvaluations(String interactionId)
      Fetch the evaluations recorded about the interaction with the given interactionId, newest first.

      Blocks the calling thread until the records have been fetched. Safe to call on a virtual thread. Use getEvaluationsAsync(String) for the non-blocking variant.

      Parameters:
      interactionId - the id of the evaluated interaction, as carried by Agent.AgentReply.interactionId()
      Returns:
      the evaluations of that interaction, or an empty list when none are recorded
    • getEvaluationsAsync

      CompletionStage<List<EvaluationRecord>> getEvaluationsAsync(String interactionId)
      Async variant of getEvaluations(String).
      Parameters:
      interactionId - the id of the evaluated interaction
      Returns:
      a stage that completes with the evaluations of that interaction