Class AbstractResponseMetadata

java.lang.Object
org.springframework.ai.model.AbstractResponseMetadata
Direct Known Subclasses:
ChatResponseMetadata, EmbeddingResponseMetadata, ModerationResponseMetadata

public class AbstractResponseMetadata extends Object
  • Field Details

  • Constructor Details

    • AbstractResponseMetadata

      public AbstractResponseMetadata()
  • Method Details

    • get

      @Nullable public <T> T get(String key)
      Gets an entry from the context. Returns null when entry is not present.
      Type Parameters:
      T - value type
      Parameters:
      key - key
      Returns:
      entry or null if not present
    • getRequired

      @NonNull public <T> T getRequired(Object key)
      Gets an entry from the context. Throws exception when entry is not present.
      Type Parameters:
      T - value type
      Parameters:
      key - key
      Returns:
      entry
      Throws:
      IllegalArgumentException - if not present
    • containsKey

      public boolean containsKey(Object key)
      Checks if context contains a key.
      Parameters:
      key - key
      Returns:
      true when the context contains the entry with the given key
    • getOrDefault

      public <T> T getOrDefault(Object key, T defaultObject)
      Returns an element or default if not present.
      Type Parameters:
      T - value type
      Parameters:
      key - key
      defaultObject - default object to return
      Returns:
      object or default if not present
    • entrySet

      public Set<Map.Entry<String,Object>> entrySet()
    • keySet

      public Set<String> keySet()
    • isEmpty

      public boolean isEmpty()