MCPcopy
hub / github.com/langchain-ai/langchain / SystemMessage

Class SystemMessage

libs/core/langchain_core/messages/system.py:6–43  ·  view source on GitHub ↗

Message for priming AI behavior. The system message is usually passed in as the first of a sequence of input messages. Example: .. code-block:: python from langchain_core.messages import HumanMessage, SystemMessage messages = [ SystemM

Source from the content-addressed store, hash-verified

4
5
6class SystemMessage(BaseMessage):
7 """Message for priming AI behavior.
8
9 The system message is usually passed in as the first of a sequence
10 of input messages.
11
12 Example:
13
14 .. code-block:: python
15
16 from langchain_core.messages import HumanMessage, SystemMessage
17
18 messages = [
19 SystemMessage(
20 content="You are a helpful assistant! Your name is Bob."
21 ),
22 HumanMessage(
23 content="What is your name?"
24 )
25 ]
26
27 # Define a chat model and invoke it with the messages
28 print(model.invoke(messages))
29
30 """
31
32 type: Literal["system"] = "system"
33
34 @classmethod
35 def get_lc_namespace(cls) -> List[str]:
36 """Get the namespace of the langchain object."""
37 return ["langchain", "schema", "messages"]
38
39 def __init__(
40 self, content: Union[str, List[Union[str, Dict]]], **kwargs: Any
41 ) -> None:
42 """Pass in content as positional arg."""
43 super().__init__(content=content, **kwargs)
44
45
46SystemMessage.update_forward_refs()

Callers 15

agent.pyFile · 0.90
agent.pyFile · 0.90
web.pyFile · 0.90
chain.pyFile · 0.90
chain.pyFile · 0.90
web.pyFile · 0.90
chain.pyFile · 0.90
_convert_dict_to_messageFunction · 0.90
test_system_messageFunction · 0.90
_convert_dict_to_messageFunction · 0.90

Calls

no outgoing calls