Record Class LLMConnection

java.lang.Object
java.lang.Record
com.amalgamasimulation.llm.LLMConnection
Record Components:
uri - the URI of the LLM API endpoint
healthCheckUri - the URI of the LLM API health check
apiKey - the API key used for authentication with the LLM service
model - the specific model identifier to be used with the LLM service

public record LLMConnection(URI uri, URI healthCheckUri, String apiKey, String model) extends Record
Connection to a Large Language Model (LLM) API service. This record encapsulates the necessary information to connect to an LLM API endpoint.
  • Constructor Details

    • LLMConnection

      public LLMConnection(URI uri, URI healthCheckUri, String apiKey, String model)
      Creates an instance of a LLMConnection record class.
      Parameters:
      uri - the value for the uri record component
      healthCheckUri - the value for the healthCheckUri record component
      apiKey - the value for the apiKey record component
      model - the value for the model record component
  • Method Details

    • defaultConnection

      public static LLMConnection defaultConnection()
      Returns a default LLMConnection instance configured with DeepSeek API. The default connection uses DeepSeek's chat completion endpoint with a predefined API key and the "deepseek-chat" model.
      Returns:
      a default LLMConnection instance configured for DeepSeek API
    • isAvailable

      public CompletableFuture<Boolean> isAvailable(Duration duration)
      Checks the availability of the LLM service by performing a HEAD request to the service's base URL. This method asynchronously checks if the service is responding with a successful HTTP status code (2xx or 3xx).
      Parameters:
      duration - the maximum time to wait for the connection and response
      Returns:
      a CompletableFuture that will complete with true if the service is available, or false otherwise
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • uri

      public URI uri()
      Returns the value of the uri record component.
      Returns:
      the value of the uri record component
    • healthCheckUri

      public URI healthCheckUri()
      Returns the value of the healthCheckUri record component.
      Returns:
      the value of the healthCheckUri record component
    • apiKey

      public String apiKey()
      Returns the value of the apiKey record component.
      Returns:
      the value of the apiKey record component
    • model

      public String model()
      Returns the value of the model record component.
      Returns:
      the value of the model record component