Record Class SourceExtract

java.lang.Object
java.lang.Record
com.vaadin.flow.component.ai.common.SourceExtract
Record Components:
text - the snippet as the model reports it, not null
location - where the snippet sits inside the source document, or null when the source has no position to point at (for example pasted text)
All Implemented Interfaces:
Serializable

public record SourceExtract(String text, SourceLocation location) extends Record implements Serializable
One snippet the LLM says it read to produce a value. The text is what the model reports, not a verified quote: the controller never sees the source document, so the snippet records what the AI said its source was rather than proof that the value is correct.

The location says where the snippet sits inside its source document, but not which document. Sources are unambiguous only when a single document is attached per prompt.

Since:
25.3
Author:
Vaadin Ltd
See Also:
  • Constructor Details

    • SourceExtract

      public SourceExtract(String text, SourceLocation location)
      Creates a new source extract.
      Parameters:
      text - the snippet as the model reports it, not null
      location - where the snippet sits inside the source document, or null when the source has no position to point at
      Throws:
      NullPointerException - if text is null
  • Method Details

    • 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.
    • text

      public String text()
      Returns the value of the text record component.
      Returns:
      the value of the text record component
    • location

      public SourceLocation location()
      Returns the value of the location record component.
      Returns:
      the value of the location record component