Class HttpLlmResponseActionHandler

java.lang.Object
org.mockserver.mock.action.http.HttpLlmResponseActionHandler

public class HttpLlmResponseActionHandler extends Object
  • Constructor Details

    • HttpLlmResponseActionHandler

      public HttpLlmResponseActionHandler(MockServerLogger mockServerLogger)
  • Method Details

    • handle

      public HttpResponse handle(HttpLlmResponse httpLlmResponse, HttpRequest request)
    • streamingFormatFor

      public StreamingFormat streamingFormatFor(Provider provider)
      Returns the streaming wire format for the given provider. Used by the action handler dispatch to choose between SSE and NDJSON framing.
      Parameters:
      provider - the LLM provider
      Returns:
      the streaming format (defaults to StreamingFormat.SSE)
    • handleStreaming

      public List<SseEvent> handleStreaming(HttpLlmResponse httpLlmResponse, HttpRequest request)
      Handle streaming LLM response by producing a list of SSE events. Called by HttpActionHandler when streaming is detected.
      Parameters:
      httpLlmResponse - the LLM response action
      request - the original HTTP request
      Returns:
      list of SSE events to be sent through the SSE handler
    • chaosErrorResponseOrNull

      public HttpResponse chaosErrorResponseOrNull(HttpLlmResponse httpLlmResponse)
      Returns an error HttpResponse (status + optional Retry-After) when the chaos profile triggers a probabilistic error, or null otherwise. An errorStatus with no errorProbability always fires; a fractional probability draws once (reproducible via seed). Applies to both streaming and non-streaming responses — a provider error is a normal HTTP response, not an SSE stream.