Package com.tnsai.llm
Record Class ModelInfo
java.lang.Object
java.lang.Record
com.tnsai.llm.ModelInfo
- Record Components:
id- The model identifier (e.g., "gpt-4o", "llama3.2")provider- The provider name (e.g., "openai", "ollama")ownedBy- The model owner (e.g., "openai", "meta")created- The creation/modification timestampdescription- Optional description of the modelcontextLength- Optional context window size in tokenssizeBytes- Optional model size in bytes (for local models)family- Optional model family (e.g., "llama", "gpt")capabilities- Optional capabilities info
public record ModelInfo(String id, String provider, String ownedBy, Instant created, Optional<String> description, Optional<Integer> contextLength, Optional<Long> sizeBytes, Optional<String> family, Optional<LLMCapabilities> capabilities)
extends Record
Represents information about an LLM model from a provider's API.
This record is used by LLMClient.listModels() to return
available models from providers like OpenAI, Ollama, etc.
Example Usage
List<ModelInfo> models = client.listModels();
for (ModelInfo model : models) {
System.out.printf("%s (%s) - %s%n",
model.id(), model.provider(), model.description().orElse(""));
}
- Author:
- TnsAI Team
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ModelInfo.BuilderBuilder for creating ModelInfo with all optional fields.Returns the value of thecapabilitiesrecord component.Returns the value of thecontextLengthrecord component.created()Returns the value of thecreatedrecord component.Returns the value of thedescriptionrecord component.final booleanIndicates whether some other object is "equal to" this one.family()Returns the value of thefamilyrecord component.static ModelInfoforCloudModel(String id, String provider, String ownedBy, Instant created, int contextLength) Creates a ModelInfo for cloud models with context length.static ModelInfoforLocalModel(String id, String provider, long sizeBytes, Instant modified, String family) Creates a ModelInfo with full details for local models (Ollama).final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.static ModelInfoCreates a simple ModelInfo with just id and provider.static ModelInfoCreates a ModelInfo with id, provider, and owner.ownedBy()Returns the value of theownedByrecord component.provider()Returns the value of theproviderrecord component.Returns the value of thesizeBytesrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ModelInfo
public ModelInfo(String id, String provider, String ownedBy, Instant created, Optional<String> description, Optional<Integer> contextLength, Optional<Long> sizeBytes, Optional<String> family, Optional<LLMCapabilities> capabilities) Creates an instance of aModelInforecord class.- Parameters:
id- the value for theidrecord componentprovider- the value for theproviderrecord componentownedBy- the value for theownedByrecord componentcreated- the value for thecreatedrecord componentdescription- the value for thedescriptionrecord componentcontextLength- the value for thecontextLengthrecord componentsizeBytes- the value for thesizeBytesrecord componentfamily- the value for thefamilyrecord componentcapabilities- the value for thecapabilitiesrecord component
-
-
Method Details
-
of
Creates a simple ModelInfo with just id and provider. -
of
Creates a ModelInfo with id, provider, and owner. -
forLocalModel
public static ModelInfo forLocalModel(String id, String provider, long sizeBytes, Instant modified, String family) Creates a ModelInfo with full details for local models (Ollama). -
forCloudModel
public static ModelInfo forCloudModel(String id, String provider, String ownedBy, Instant created, int contextLength) Creates a ModelInfo for cloud models with context length. -
builder
Builder for creating ModelInfo with all optional fields. -
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). -
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
provider
Returns the value of theproviderrecord component.- Returns:
- the value of the
providerrecord component
-
ownedBy
Returns the value of theownedByrecord component.- Returns:
- the value of the
ownedByrecord component
-
created
Returns the value of thecreatedrecord component.- Returns:
- the value of the
createdrecord component
-
description
Returns the value of thedescriptionrecord component.- Returns:
- the value of the
descriptionrecord component
-
contextLength
Returns the value of thecontextLengthrecord component.- Returns:
- the value of the
contextLengthrecord component
-
sizeBytes
Returns the value of thesizeBytesrecord component.- Returns:
- the value of the
sizeBytesrecord component
-
family
Returns the value of thefamilyrecord component.- Returns:
- the value of the
familyrecord component
-
capabilities
Returns the value of thecapabilitiesrecord component.- Returns:
- the value of the
capabilitiesrecord component
-