Record Class EvaluationRequest

java.lang.Object
java.lang.Record
io.micronaut.langchain4j.evaluation.EvaluationRequest
Record Components:
userText - The original user text
context - The optional grounding context
response - The generated response

@Introspected public record EvaluationRequest(@NonNull String userText, @Nullable String context, @NonNull String response) extends Record
Captures the prompt, optional context, and generated response for an evaluation.
Since:
2.1.1
  • Constructor Summary

    Constructors
    Constructor
    Description
    EvaluationRequest(@NonNull String userText, @Nullable String context, @NonNull String response)
    Creates an instance of a EvaluationRequest record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable String
    Returns the value of the context record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    static @NonNull EvaluationRequest
    from(@NonNull String userText, @NonNull dev.langchain4j.service.Result<?> result)
    Creates an evaluation request from the user text and AI service result.
    static @NonNull EvaluationRequest
    from(@NonNull String userText, @NonNull List<dev.langchain4j.rag.content.Content> sources, @NonNull String response)
    Creates an evaluation request from the user text, retrieved sources, and generated response.
    final int
    Returns a hash code value for this object.
    @NonNull String
    Returns the value of the response record component.
    final String
    Returns a string representation of this record class.
    @NonNull String
    Returns the value of the userText record component.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • EvaluationRequest

      public EvaluationRequest(@NonNull String userText, @Nullable String context, @NonNull String response)
      Creates an instance of a EvaluationRequest record class.
      Parameters:
      userText - the value for the userText record component
      context - the value for the context record component
      response - the value for the response record component
  • Method Details

    • from

      public static @NonNull EvaluationRequest from(@NonNull String userText, @NonNull dev.langchain4j.service.Result<?> result)
      Creates an evaluation request from the user text and AI service result.
      Parameters:
      userText - The original user text
      result - The AI service result
      Returns:
      The evaluation request
      Since:
      2.1.1
    • from

      public static @NonNull EvaluationRequest from(@NonNull String userText, @NonNull List<dev.langchain4j.rag.content.Content> sources, @NonNull String response)
      Creates an evaluation request from the user text, retrieved sources, and generated response.
      Parameters:
      userText - The original user text
      sources - The retrieved sources
      response - The generated response
      Returns:
      The evaluation request
      Since:
      2.1.1
    • 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.
    • userText

      public @NonNull String userText()
      Returns the value of the userText record component.
      Returns:
      the value of the userText record component
    • context

      public @Nullable String context()
      Returns the value of the context record component.
      Returns:
      the value of the context record component
    • response

      public @NonNull String response()
      Returns the value of the response record component.
      Returns:
      the value of the response record component