Class Prompt
java.lang.Object
org.springframework.ai.chat.prompt.Prompt
- All Implemented Interfaces:
ModelRequest<List<Message>>
The Prompt class represents a prompt used in AI model requests. A prompt consists of
one or more messages and additional chat options.
- Author:
- Mark Pollack, luocongqiu, Thomas Vitale
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaugmentSystemMessage
(String newSystemText) Augments the last system message in the prompt with the provided text.augmentSystemMessage
(Function<SystemMessage, SystemMessage> systemMessageAugmenter) Augments the first system message in the prompt with the provided function.augmentUserMessage
(String newUserText) Augments the last user message in the prompt with the provided text.augmentUserMessage
(Function<UserMessage, UserMessage> userMessageAugmenter) Augments the last user message in the prompt with the provided function.static Prompt.Builder
builder()
copy()
boolean
Retrieves the instructions or input required by the AI model.Retrieves the customizable options for AI model interactions.Get the first system message in the prompt.Get the last user message in the prompt.int
hashCode()
mutate()
toString()
-
Constructor Details
-
Prompt
-
Prompt
-
Prompt
-
Prompt
-
Prompt
-
Prompt
-
Prompt
-
-
Method Details
-
getContents
-
getOptions
Description copied from interface:ModelRequest
Retrieves the customizable options for AI model interactions.- Specified by:
getOptions
in interfaceModelRequest<List<Message>>
- Returns:
- the customizable options for AI model interactions
-
getInstructions
Description copied from interface:ModelRequest
Retrieves the instructions or input required by the AI model.- Specified by:
getInstructions
in interfaceModelRequest<List<Message>>
- Returns:
- the instructions or input required by the AI model
-
getSystemMessage
Get the first system message in the prompt. If no system message is found, an empty SystemMessage is returned. -
getUserMessage
Get the last user message in the prompt. If no user message is found, an empty UserMessage is returned. -
toString
-
equals
-
hashCode
public int hashCode() -
copy
-
augmentSystemMessage
Augments the first system message in the prompt with the provided function. If no system message is found, a new one is created with the provided text.- Returns:
- a new
Prompt
instance with the augmented system message.
-
augmentSystemMessage
Augments the last system message in the prompt with the provided text. If no system message is found, a new one is created with the provided text.- Returns:
- a new
Prompt
instance with the augmented system message.
-
augmentUserMessage
Augments the last user message in the prompt with the provided function. If no user message is found, a new one is created with the provided text.- Returns:
- a new
Prompt
instance with the augmented user message.
-
augmentUserMessage
Augments the last user message in the prompt with the provided text. If no user message is found, a new one is created with the provided text.- Returns:
- a new
Prompt
instance with the augmented user message.
-
mutate
-
builder
-