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 timestamp
description - Optional description of the model
contextLength - Optional context window size in tokens
sizeBytes - 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:
  • Constructor Details

  • Method Details

    • of

      public static ModelInfo of(String id, String provider)
      Creates a simple ModelInfo with just id and provider.
    • of

      public static ModelInfo of(String id, String provider, String ownedBy)
      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

      public static ModelInfo.Builder builder(String id, String provider)
      Builder for creating ModelInfo with all optional fields.
    • 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.
    • id

      public String id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • provider

      public String provider()
      Returns the value of the provider record component.
      Returns:
      the value of the provider record component
    • ownedBy

      public String ownedBy()
      Returns the value of the ownedBy record component.
      Returns:
      the value of the ownedBy record component
    • created

      public Instant created()
      Returns the value of the created record component.
      Returns:
      the value of the created record component
    • description

      public Optional<String> description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component
    • contextLength

      public Optional<Integer> contextLength()
      Returns the value of the contextLength record component.
      Returns:
      the value of the contextLength record component
    • sizeBytes

      public Optional<Long> sizeBytes()
      Returns the value of the sizeBytes record component.
      Returns:
      the value of the sizeBytes record component
    • family

      public Optional<String> family()
      Returns the value of the family record component.
      Returns:
      the value of the family record component
    • capabilities

      public Optional<LLMCapabilities> capabilities()
      Returns the value of the capabilities record component.
      Returns:
      the value of the capabilities record component