Class Interaction

java.lang.Object
org.opensearch.ml.common.conversation.Interaction
All Implemented Interfaces:
org.opensearch.core.common.io.stream.Writeable, org.opensearch.core.xcontent.ToXContent, org.opensearch.core.xcontent.ToXContentObject

public class Interaction extends Object implements org.opensearch.core.common.io.stream.Writeable, org.opensearch.core.xcontent.ToXContentObject
Class for dealing with Interactions
  • Constructor Details

  • Method Details

    • fromMap

      public static Interaction fromMap(String id, Map<String,Object> fields)
      Creates an Interaction object from a map of fields in the OS index
      Parameters:
      id - the Interaction id
      fields - the field mapping from the OS document
      Returns:
      a new Interaction object representing the OS document
    • fromSearchHit

      public static Interaction fromSearchHit(org.opensearch.search.SearchHit hit)
      Creates an Interaction object from a search hit
      Parameters:
      hit - the search hit from the interactions index
      Returns:
      a new Interaction object representing the search hit
    • fromStream

      public static Interaction fromStream(org.opensearch.core.common.io.stream.StreamInput in) throws IOException
      Creates a new Interaction object from a stream
      Parameters:
      in - stream to read from; assumes Interactions.writeTo was called on it
      Returns:
      a new Interaction
      Throws:
      IOException - if can't read or the stream isn't pointing to an intraction or something
    • writeTo

      public void writeTo(org.opensearch.core.common.io.stream.StreamOutput out) throws IOException
      Specified by:
      writeTo in interface org.opensearch.core.common.io.stream.Writeable
      Throws:
      IOException
    • toXContent

      public org.opensearch.core.xcontent.XContentBuilder toXContent(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.opensearch.core.xcontent.ToXContent
      Throws:
      IOException
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • builder

      public static Interaction.InteractionBuilder builder()
    • toBuilder

      public Interaction.InteractionBuilder toBuilder()
    • getId

      public String getId()
    • getCreateTime

      public Instant getCreateTime()
    • getConversationId

      public String getConversationId()
    • getInput

      public String getInput()
    • getPromptTemplate

      public String getPromptTemplate()
    • getResponse

      public String getResponse()
    • getOrigin

      public String getOrigin()
    • getAdditionalInfo

      public Map<String,String> getAdditionalInfo()
    • getParentInteractionId

      public String getParentInteractionId()
    • getTraceNum

      public Integer getTraceNum()