java.lang.Object
java.lang.Record
com.agentforge4j.llm.LlmClientFactoryContext
- Record Components:
objectMapper- the JSON mapper used for response parsing and serialization; nevernullconfiguration- the neutral provider configuration; nevernullsecretResolver- the resolver for the provider's credential reference; nevernull
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 Summary
ConstructorsConstructorDescriptionLlmClientFactoryContext(com.fasterxml.jackson.databind.ObjectMapper objectMapper, LlmClientConfiguration configuration, LlmSecretResolver secretResolver) Creates an instance of aLlmClientFactoryContextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionapiKey()Resolves the configuration's credential reference if one is configured.Returns the value of theconfigurationrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.com.fasterxml.jackson.databind.ObjectMapperReturns the value of theobjectMapperrecord component.Resolves the configuration's credential reference into a liveLlmSecret.Returns the value of thesecretResolverrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
LlmClientFactoryContext
public LlmClientFactoryContext(com.fasterxml.jackson.databind.ObjectMapper objectMapper, LlmClientConfiguration configuration, LlmSecretResolver secretResolver) Creates an instance of aLlmClientFactoryContextrecord class.- Parameters:
objectMapper- the value for theobjectMapperrecord componentconfiguration- the value for theconfigurationrecord componentsecretResolver- the value for thesecretResolverrecord component
-
-
Method Details
-
requireApiKey
Resolves the configuration's credential reference into a liveLlmSecret. Use this from a provider that requires an API key; the resolved value is held as anLlmSecret, never a rawString.- Returns:
- the resolved credential
- Throws:
LlmProviderConfigurationException- if no credential reference is configured (secret-safe message naming the provider)
-
apiKey
Resolves the configuration's credential reference if one is configured.- Returns:
- the resolved credential, or empty when none is configured
-
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). -
objectMapper
public com.fasterxml.jackson.databind.ObjectMapper objectMapper()Returns the value of theobjectMapperrecord component.- Returns:
- the value of the
objectMapperrecord component
-
configuration
Returns the value of theconfigurationrecord component.- Returns:
- the value of the
configurationrecord component
-
secretResolver
Returns the value of thesecretResolverrecord component.- Returns:
- the value of the
secretResolverrecord component
-