Class Prompt

java.lang.Object
dev.langchain4j.model.input.Prompt

public class Prompt extends Object
Represents a prompt (an input text sent to the LLM). A prompt usually contains instructions, contextual information, end-user input, etc. A Prompt is typically created by applying one or multiple values to a PromptTemplate.
  • Constructor Details

    • Prompt

      public Prompt(String text)
      Create a new Prompt.
      Parameters:
      text - the text of the prompt.
  • Method Details

    • text

      public String text()
      The text of the prompt.
      Returns:
      the text of the prompt.
    • toSystemMessage

      public SystemMessage toSystemMessage()
      Convert this prompt to a SystemMessage.
      Returns:
      the SystemMessage.
    • toUserMessage

      public UserMessage toUserMessage(String userName)
      Convert this prompt to a UserMessage with specified userName.
      Returns:
      the UserMessage.
    • toUserMessage

      public UserMessage toUserMessage()
      Convert this prompt to a UserMessage.
      Returns:
      the UserMessage.
    • toAiMessage

      public AiMessage toAiMessage()
      Convert this prompt to an AiMessage.
      Returns:
      the AiMessage.
    • 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
    • from

      public static Prompt from(String text)
      Create a new Prompt.
      Parameters:
      text - the text of the prompt.
      Returns:
      the new Prompt.