Interface BaseModelHandler<ParamT extends BaseModelParameters,InputT extends BaseInput,OutputT extends BaseResponse>
-
public interface BaseModelHandler<ParamT extends BaseModelParameters,InputT extends BaseInput,OutputT extends BaseResponse>Interface for model-specific handlers that perform remote inference operations.Implementations of this interface encapsulate all logic for communicating with a specific remote inference service. Each handler is responsible for:
- Initializing and managing client connections
- Converting Beam inputs to service-specific request formats
- Making inference API calls
- Converting service responses to Beam output types
- Handling errors and retries if applicable
Lifecycle
Handler instances follow this lifecycle:
- Instantiation via no-argument constructor
createClient(ParamT)called with parameters during setuprequest(java.util.List<InputT>)called for each batch of inputs
Handlers typically contain non-serializable client objects. Mark client fields as
transientand initialize them increateClient(ParamT)Batching Considerations
The
request(java.util.List<InputT>)method receives a list of inputs. Implementations should:- Batch inputs efficiently if the service supports batch inference
- Return results in the same order as inputs
- Maintain input-output correspondence in
PredictionResult
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcreateClient(ParamT parameters)Initializes the remote model client with the provided parameters.java.lang.Iterable<PredictionResult<InputT,OutputT>>request(java.util.List<InputT> input)Performs inference on a batch of inputs and returns the results.
-
-
-
Method Detail
-
createClient
void createClient(ParamT parameters)
Initializes the remote model client with the provided parameters.
-
request
java.lang.Iterable<PredictionResult<InputT,OutputT>> request(java.util.List<InputT> input)
Performs inference on a batch of inputs and returns the results.
-
-