Interface SamplingRequest

All Known Implementing Classes:
SamplingRequestImpl

public interface SamplingRequest
A request from the server to sample an LLM.
  • Method Details

    • maxTokens

      long maxTokens()
      Returns:
      the maximum number of tokens to sample
    • messages

      List<SamplingMessage> messages()
      Returns:
      the sampling messages (not null)
    • stopSequences

      List<String> stopSequences()
      Returns:
      the stop sequences
    • systemPrompt

      String systemPrompt()
      Returns:
      the system prompt the server wants to use for sampling
    • temperature

      BigDecimal temperature()
      Returns:
      the temperature
    • includeContext

      Returns:
      the request to include the context
    • modelPreferences

      ModelPreferences modelPreferences()
      Returns:
      the model preferences
    • metadata

      Map<String,Object> metadata()
      Returns:
      the optional metadata
    • send

      io.smallrye.mutiny.Uni<SamplingResponse> send()
      Send a message to the client.

      If the client does not respond before the timeout expires then the returned Uni fails with TimeoutException. The default timeout is configured with the quarkus.mcp.server.sampling.default-timeout config property.

      Returns:
      a new Uni that completes with a SamplingResponse
    • sendAndAwait

      default SamplingResponse sendAndAwait()
      Send a message to the client and wait for the result.

      Note that this method will block until the client sends the response.

      If the client does not respond before the timeout expires then a TimeoutException is thrown. The default timeout is configured with the quarkus.mcp.server.sampling.default-timeout config property.

      Returns:
      the response