Package com.amalgamasimulation.llm
Record Class LLMConnection
java.lang.Object
java.lang.Record
com.amalgamasimulation.llm.LLMConnection
- Record Components:
uri- the URI of the LLM API endpointhealthCheckUri- the URI of the LLM API health checkapiKey- the API key used for authentication with the LLM servicemodel- 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 Summary
ConstructorsConstructorDescriptionLLMConnection(URI uri, URI healthCheckUri, String apiKey, String model) Creates an instance of aLLMConnectionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionapiKey()Returns the value of theapiKeyrecord component.static LLMConnectionReturns a default LLMConnection instance configured with DeepSeek API.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thehealthCheckUrirecord component.isAvailable(Duration duration) Checks the availability of the LLM service by performing a HEAD request to the service's base URL.model()Returns the value of themodelrecord component.final StringtoString()Returns a string representation of this record class.uri()Returns the value of theurirecord component.
-
Constructor Details
-
LLMConnection
Creates an instance of aLLMConnectionrecord class.- Parameters:
uri- the value for theurirecord componenthealthCheckUri- the value for thehealthCheckUrirecord componentapiKey- the value for theapiKeyrecord componentmodel- the value for themodelrecord component
-
-
Method Details
-
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
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
trueif the service is available, orfalseotherwise
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
uri
Returns the value of theurirecord component.- Returns:
- the value of the
urirecord component
-
healthCheckUri
Returns the value of thehealthCheckUrirecord component.- Returns:
- the value of the
healthCheckUrirecord component
-
apiKey
Returns the value of theapiKeyrecord component.- Returns:
- the value of the
apiKeyrecord component
-
model
Returns the value of themodelrecord component.- Returns:
- the value of the
modelrecord component
-