Let’s follow the complete flow of a request through Polyglot:

Request Processing

  1. Application creates an Inference object
  2. Application calls create() with parameters
  3. Inference creates an InferenceRequest.
  4. Inference creates a PendingInference object with the instances of request, driver and event dispatcher.
  5. Inference returns a PendingInference object to the application.

Response Processing

  1. Application accesses the PendingInference object content, e.g. via response() method.
  2. PendingInference checks if HTTP request has been already executed.
    • If already sent, it returns the cached response.
  3. PendingInference dispatches the InferenceRequested event
  4. PendingInference passes the request to the driver.
  5. Driver uses request adapter to create HTTP request
  6. Request adapter uses request body formatter and message formatter.
  7. Driver sends the HTTP request and returns it to PendingInference.
  8. PendingInference calls the driver to read and parse the response.
  9. Driver uses a response adapter to extract content into appropriate fields of InferenceResponse object
  10. PendingInference dispatches the InferenceResponseReceived event
  11. Result InferenceResponse object is returned to the application