Class SystemMessage
java.lang.Object
dev.langchain4j.data.message.SystemMessage
- All Implemented Interfaces:
ChatMessage
Represents a system message, typically defined by a developer.
This type of message usually provides instructions regarding the AI's actions, such as its behavior or response style.
Optionally, system message can contain custom attributes represented by a mutable
Optionally, system message can contain custom attributes represented by a mutable
Map.
Attributes are not sent to the model, but they are stored in the ChatMemory.-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionSystemMessage(SystemMessage.Builder builder) Creates aSystemMessagefrom a builder.SystemMessage(String text) Creates a new system message. -
Method Summary
Modifier and TypeMethodDescription<T> TReturns additional attribute by it's key.Returns additional attributes.static SystemMessage.Builderbuilder()booleanstatic List<SystemMessage> findAll(List<ChatMessage> messages) static Optional<SystemMessage> findFirst(List<ChatMessage> messages) static Optional<SystemMessage> findLast(List<ChatMessage> messages) static SystemMessageCreates a new system message.inthashCode()static SystemMessagesystemMessage(String text) Creates a new system message.text()Returns the message text.toString()type()The type of the message.
-
Constructor Details
-
SystemMessage
Creates a new system message.- Parameters:
text- the message text.
-
SystemMessage
Creates aSystemMessagefrom a builder.- Since:
- 1.21.0
-
-
Method Details
-
text
-
attributes
Returns additional attributes.- Since:
- 1.21.0
- See Also:
-
attribute
Returns additional attribute by it's key.- Since:
- 1.21.0
- See Also:
-
type
Description copied from interface:ChatMessageThe type of the message.- Specified by:
typein interfaceChatMessage- Returns:
- the type of the message
-
toBuilder
- Since:
- 1.21.0
-
equals
-
hashCode
-
toString
-
builder
- Since:
- 1.21.0
-
from
Creates a new system message.- Parameters:
text- the message text.- Returns:
- the system message.
-
systemMessage
Creates a new system message.- Parameters:
text- the message text.- Returns:
- the system message.
-
findFirst
-
findLast
-
findAll
-