Record Class LlmClientFactoryContext

java.lang.Object
java.lang.Record
com.agentforge4j.llm.LlmClientFactoryContext
Record Components:
objectMapper - the JSON mapper used for response parsing and serialization; never null
configuration - the neutral provider configuration; never null
secretResolver - the resolver for the provider's credential reference; never null

public record LlmClientFactoryContext(com.fasterxml.jackson.databind.ObjectMapper objectMapper, LlmClientConfiguration configuration, LlmSecretResolver secretResolver) extends Record
Inputs passed to LlmClientFactory.create(LlmClientFactoryContext): the JSON mapper, the neutral provider LlmClientConfiguration, and the LlmSecretResolver a provider uses to resolve its credential reference. A context (rather than a widening parameter list) lets the SPI absorb future inputs without further create churn.
  • Constructor Details

    • LlmClientFactoryContext

      public LlmClientFactoryContext(com.fasterxml.jackson.databind.ObjectMapper objectMapper, LlmClientConfiguration configuration, LlmSecretResolver secretResolver)
      Creates an instance of a LlmClientFactoryContext record class.
      Parameters:
      objectMapper - the value for the objectMapper record component
      configuration - the value for the configuration record component
      secretResolver - the value for the secretResolver record component
  • Method Details

    • requireApiKey

      public LlmSecret requireApiKey()
      Resolves the configuration's credential reference into a live LlmSecret. Use this from a provider that requires an API key; the resolved value is held as an LlmSecret, never a raw String.
      Returns:
      the resolved credential
      Throws:
      LlmProviderConfigurationException - if no credential reference is configured (secret-safe message naming the provider)
    • apiKey

      public Optional<LlmSecret> apiKey()
      Resolves the configuration's credential reference if one is configured.
      Returns:
      the resolved credential, or empty when none is configured
    • 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.
    • objectMapper

      public com.fasterxml.jackson.databind.ObjectMapper objectMapper()
      Returns the value of the objectMapper record component.
      Returns:
      the value of the objectMapper record component
    • configuration

      public LlmClientConfiguration configuration()
      Returns the value of the configuration record component.
      Returns:
      the value of the configuration record component
    • secretResolver

      public LlmSecretResolver secretResolver()
      Returns the value of the secretResolver record component.
      Returns:
      the value of the secretResolver record component