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 TypeMethodDescriptionaugmentUserMessage(String newUserText) Creates a copy of the prompt, replacing the text content of the last UserMessage with the provided text.augmentUserMessage(Function<UserMessage, UserMessage> userMessageAugmenter) static Prompt.Builderbuilder()copy()booleanRetrieves the instructions or input required by the AI model.Retrieves the customizable options for AI model interactions.Get the last user message in the prompt.inthashCode()mutate()toString()
-
Constructor Details
-
Prompt
-
Prompt
-
Prompt
-
Prompt
-
Prompt
-
Prompt
-
Prompt
-
-
Method Details
-
getContents
-
getOptions
Description copied from interface:ModelRequestRetrieves the customizable options for AI model interactions.- Specified by:
getOptionsin interfaceModelRequest<List<Message>>- Returns:
- the customizable options for AI model interactions
-
getInstructions
Description copied from interface:ModelRequestRetrieves the instructions or input required by the AI model.- Specified by:
getInstructionsin interfaceModelRequest<List<Message>>- Returns:
- the instructions or input required by the AI model
-
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
-
augmentUserMessage
- Parameters:
userMessageAugmenter- the function to augment the last user message.- Returns:
- a new prompt instance with the augmented user message.
-
augmentUserMessage
Creates a copy of the prompt, replacing the text content of the last UserMessage with the provided text. If no UserMessage exists, a new one with the given text is added.- Parameters:
newUserText- The new text content for the last user message.- Returns:
- A new Prompt instance with the augmented user message text.
-
mutate
-
builder
-