system.py — langchain Source File
Architecture documentation for system.py, a python file in the langchain codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 917acef8_cb58_963a_19d6_78c620915ba0["system.py"] 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] 917acef8_cb58_963a_19d6_78c620915ba0 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"] 917acef8_cb58_963a_19d6_78c620915ba0 --> d758344f_537f_649e_f467_b9d7442e86df a1369c93_b21f_2edb_d15c_ec3e09ac1e42["langchain_core.messages.base"] 917acef8_cb58_963a_19d6_78c620915ba0 --> a1369c93_b21f_2edb_d15c_ec3e09ac1e42 style 917acef8_cb58_963a_19d6_78c620915ba0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""System message."""
from typing import Any, Literal, cast, overload
from langchain_core.messages import content as types
from langchain_core.messages.base import BaseMessage, BaseMessageChunk
class SystemMessage(BaseMessage):
"""Message for priming AI behavior.
The system message is usually passed in as the first of a sequence
of input messages.
Example:
```python
from langchain_core.messages import HumanMessage, SystemMessage
messages = [
SystemMessage(content="You are a helpful assistant! Your name is Bob."),
HumanMessage(content="What is your name?"),
]
# Define a chat model and invoke it with the messages
print(model.invoke(messages))
```
"""
type: Literal["system"] = "system"
"""The type of the message (used for serialization)."""
@overload
def __init__(
self,
content: str | list[str | dict],
**kwargs: Any,
) -> None: ...
@overload
def __init__(
self,
content: str | list[str | dict] | None = None,
content_blocks: list[types.ContentBlock] | None = None,
**kwargs: Any,
) -> None: ...
def __init__(
self,
content: str | list[str | dict] | None = None,
content_blocks: list[types.ContentBlock] | None = None,
**kwargs: Any,
) -> None:
"""Specify `content` as positional arg or `content_blocks` for typing."""
if content_blocks is not None:
super().__init__(
content=cast("str | list[str | dict]", content_blocks),
**kwargs,
)
else:
super().__init__(content=content, **kwargs)
class SystemMessageChunk(SystemMessage, BaseMessageChunk):
"""System Message chunk."""
# Ignoring mypy re-assignment here since we're overriding the value
# to make sure that the chunk variant can be discriminated from the
# non-chunk variant.
type: Literal["SystemMessageChunk"] = "SystemMessageChunk" # type: ignore[assignment]
"""The type of the message (used for serialization)."""
Domain
Subdomains
Classes
Dependencies
- langchain_core.messages
- langchain_core.messages.base
- typing
Source
Frequently Asked Questions
What does system.py do?
system.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What does system.py depend on?
system.py imports 3 module(s): langchain_core.messages, langchain_core.messages.base, typing.
Where is system.py in the architecture?
system.py is located at libs/core/langchain_core/messages/system.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/core/langchain_core/messages).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free