Record Class LLMOverrides
LLMConfiguration.
Every field is optional so that "not overridden" is distinguishable from
"overridden to a falsy value". This matters: temperature = 0.0 and
maxTokens = 0 are legitimate settings that a plain float or
int cannot tell apart from "absent".
Overlays compose with overlay(LLMOverrides) (the argument wins,
field by field) and are materialised onto a base configuration with
applyTo(LLMConfiguration). Fields the overlay does not name keep the
base value.
- Since:
- 0.16.4
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classNames each field instead of relying on the positional record constructor. -
Constructor Summary
ConstructorsConstructorDescriptionLLMOverrides(Optional<String> provider, Optional<String> model, OptionalDouble temperature, OptionalInt maxTokens, Optional<String> endpoint, Optional<String> apiKeyEnv) Creates an instance of aLLMOverridesrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic LLMConfigurationThe configuration anLLMSpecthat declares nothing resolves to — that is,LLMSpec's own member defaults.Returns the value of theapiKeyEnvrecord component.applyTo(LLMConfiguration base) Materialises this overlay ontobase.static LLMOverrides.Builderbuilder()A builder, so that callers name each field instead of relying on the positional record constructor (four of whose six components areOptional<String>).describe()The names of the fields this overlay carries, for logging which settings an external source actually contributed — e.g.endpoint()Returns the value of theendpointrecord component.final booleanIndicates whether some other object is "equal to" this one.static LLMOverridesfromAnnotation(com.tnsai.annotations.LLMSpec spec) Reads the fields anLLMSpecactually declares.static LLMOverridesfromJson(org.json.JSONObject json) Decodes a trusted flat configuration object using the existing field-presence and builder validation rules.final inthashCode()Returns a hash code value for this object.booleanWhether this overlay names anyrouting()field.booleanisEmpty()Whether this overlay names no field at all.Returns the value of themaxTokensrecord component.model()Returns the value of themodelrecord component.static LLMOverridesnone()An overlay that names no field; applying it leaves a configuration untouched.overlay(LLMOverrides higher) Composes two overlays.provider()Returns the value of theproviderrecord component.routing()The fields that decide where a request goes and under whose credential:provider,model,endpoint,apiKeyEnv.Returns the value of thetemperaturerecord component.final StringtoString()Returns a string representation of this record class.tuning()The fields that only tune sampling:temperatureandmaxTokens.
-
Constructor Details
-
LLMOverrides
public LLMOverrides(Optional<String> provider, Optional<String> model, OptionalDouble temperature, OptionalInt maxTokens, Optional<String> endpoint, Optional<String> apiKeyEnv) Creates an instance of aLLMOverridesrecord class.- Parameters:
provider- the value for theproviderrecord componentmodel- the value for themodelrecord componenttemperature- the value for thetemperaturerecord componentmaxTokens- the value for themaxTokensrecord componentendpoint- the value for theendpointrecord componentapiKeyEnv- the value for theapiKeyEnvrecord component
-
-
Method Details
-
none
An overlay that names no field; applying it leaves a configuration untouched. -
builder
A builder, so that callers name each field instead of relying on the positional record constructor (four of whose six components areOptional<String>). -
fromJson
Decodes a trusted flat configuration object using the existing field-presence and builder validation rules. Absent fields stay absent; explicit null, unknown fields and numeric strings are errors. This does not read files, environment variables or credentials, or grant configuration authority.- Parameters:
json- fields supplied by the deployment's trusted configuration adapter- Returns:
- immutable partial settings, suitable for
overlay(LLMOverrides) - Throws:
LLMConfigurationException- if a field or value is invalid- Since:
- 0.17.5
-
annotationDefaults
The configuration anLLMSpecthat declares nothing resolves to — that is,LLMSpec's own member defaults. This is the base every overlay is applied onto, so a resolution in which no tier and no external source names a field yields exactly the annotation defaults. -
fromAnnotation
Reads the fields anLLMSpecactually declares.A member is treated as declared when its value differs from the default
LLMSpecdeclares for it. This is the only way to tell the two apart:@AgentSpec.llm()and@RoleSpec.llm()both default to@LLMSpec(), so every annotated class carries a full set of member values whether or not its author wrote any of them.Known blind spot: a member explicitly set to the value it already defaults to (
temperature = 0.7f,maxTokens = 4096,provider = OLLAMA) is indistinguishable from an undeclared one and is reported as absent.- Parameters:
spec- the annotation member to read;nullyieldsnone()
-
overlay
Composes two overlays. Fieldshighernames win; fields it leaves absent fall through to this overlay.- Parameters:
higher- the higher-precedence overlay
-
applyTo
Materialises this overlay ontobase. Fields this overlay does not name keep theirbasevalue. -
routing
The fields that decide where a request goes and under whose credential:provider,model,endpoint,apiKeyEnv.They are meaningful only as a set. A model belongs to a provider, an endpoint speaks one provider's wire format, and an API key is issued by one provider. Mixing them across authors produces a configuration nobody wrote — a local model name sent to a hosted endpoint under that host's key.
-
tuning
The fields that only tune sampling:temperatureandmaxTokens. These carry no routing meaning, so they compose across authors safely. -
hasRouting
public boolean hasRouting()Whether this overlay names anyrouting()field. -
isEmpty
public boolean isEmpty()Whether this overlay names no field at all. -
describe
The names of the fields this overlay carries, for logging which settings an external source actually contributed — e.g.{model, temperature}. -
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). -
provider
Returns the value of theproviderrecord component.- Returns:
- the value of the
providerrecord component
-
model
Returns the value of themodelrecord component.- Returns:
- the value of the
modelrecord component
-
temperature
Returns the value of thetemperaturerecord component.- Returns:
- the value of the
temperaturerecord component
-
maxTokens
Returns the value of themaxTokensrecord component.- Returns:
- the value of the
maxTokensrecord component
-
endpoint
Returns the value of theendpointrecord component.- Returns:
- the value of the
endpointrecord component
-
apiKeyEnv
Returns the value of theapiKeyEnvrecord component.- Returns:
- the value of the
apiKeyEnvrecord component
-