Class FieldsInput

java.lang.Object
dev.langchain4j.model.decision.request.FieldsInput
All Implemented Interfaces:
DecisionInput

@Experimental public final class FieldsInput extends Object implements DecisionInput
A DecisionInput made of named fields, for example a support ticket together with the customer's plan: Map.of("ticket", ticket, "plan", "enterprise").

The values can be strings, numbers, booleans, nulls, maps and lists. The value of a field can also be a Content or a list of Contents, for example a named image (Map.of("comment", comment, "photo", ImageContent.from(...))); which kinds of contents are supported depends on the decision model, and decision models must send them as contents (never as JSON text) or throw an UnsupportedFeatureException. Other objects are rejected: convert them to a Map that holds only what the decision needs.

Since:
1.23.0
  • Method Details

    • from

      public static FieldsInput from(Map<String,?> fields)
      Creates the input from a copy of the given fields.
      Throws:
      IllegalArgumentException - if fields is null or empty, or contains a value that is not supported (see the class description)
    • fields

      public Map<String,Object> fields()
      The fields, keyed by name, in the iteration order of the map they were created from. The map and the maps and lists inside it are unmodifiable.
    • type

      public DecisionInputType type()
      Description copied from interface: DecisionInput
      The type of this input.
      Specified by:
      type in interface DecisionInput
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object