Class BaseInferenceActionRequest

All Implemented Interfaces:
Writeable, RefCounted, TaskAwareRequest, TransportRequest
Direct Known Subclasses:
EmbeddingAction.Request, InferenceAction.Request, RerankAction.Request, UnifiedCompletionAction.Request

public abstract class BaseInferenceActionRequest extends UntypedActionRequest
Base class for inference action requests. Tracks request routing state to prevent potential routing loops and supports both streaming and non-streaming inference operations.
  • Field Details

    • INFERENCE_REQUEST_PER_TASK_TIMEOUT_ADDED

      public static final TransportVersion INFERENCE_REQUEST_PER_TASK_TIMEOUT_ADDED
    • TIMEOUT_NOT_DETERMINED

      public static final TimeValue TIMEOUT_NOT_DETERMINED
      Used as a non-null marker for cases where the timeout has not been determined yet. Safe to use in this way because a timeout of 0 would otherwise lead to requests instantly timing out, which is not a valid use case
    • OLD_DEFAULT_TIMEOUT

      public static final TimeValue OLD_DEFAULT_TIMEOUT
      The default timeout used for all task types prior to INFERENCE_REQUEST_PER_TASK_TIMEOUT_ADDED
  • Constructor Details

  • Method Details

    • resolveTimeoutForTaskType

      public static TimeValue resolveTimeoutForTaskType(TaskType taskType, @Nullable TimeValue existingTimeout)
      Returns the default timeout for the task type if the timeout has not been explicitly set. If the timeout has been set (i.e. it is not equal to TIMEOUT_NOT_DETERMINED or null) then the unmodified timeout is returned.

      Passing TaskType.ANY returns TIMEOUT_NOT_DETERMINED so that the appropriate timeout can be resolved after parsing the task type from the request body or model.

      Parameters:
      taskType - The task type for which the default timeout should be returned
      existingTimeout - The currently set timeout, which may be TIMEOUT_NOT_DETERMINED or null
    • getDefaultTimeoutForTaskType

      public static TimeValue getDefaultTimeoutForTaskType(TaskType taskType)
      Returns the default timeout based on the task type.

      Passing TaskType.ANY returns TIMEOUT_NOT_DETERMINED so that the appropriate timeout can be resolved later after parsing the task type from the request body or model.

      Parameters:
      taskType - The task type for which the default timeout should be returned
    • isStreaming

      public abstract boolean isStreaming()
    • getTaskType

      public abstract TaskType getTaskType()
    • getInferenceEntityId

      public abstract String getInferenceEntityId()
    • getContext

      public InferenceContext getContext()
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Specified by:
      writeTo in interface Writeable
      Overrides:
      writeTo in class ActionRequest
      Throws:
      IOException
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object