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

Class HumanMessage

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

Message from a human. HumanMessages are messages that are passed in from a human to the model. Example: .. code-block:: python from langchain_core.messages import HumanMessage, SystemMessage messages = [ SystemMessage(

Source from the content-addressed store, hash-verified

4
5
6class HumanMessage(BaseMessage):
7 """Message from a human.
8
9 HumanMessages are messages that are passed in from a human to the model.
10
11 Example:
12
13 .. code-block:: python
14
15 from langchain_core.messages import HumanMessage, SystemMessage
16
17 messages = [
18 SystemMessage(
19 content="You are a helpful assistant! Your name is Bob."
20 ),
21 HumanMessage(
22 content="What is your name?"
23 )
24 ]
25
26 # Instantiate a chat model and invoke it with the messages
27 model = ...
28 print(model.invoke(messages))
29 """
30
31 example: bool = False
32 """Use to denote that a message is part of an example conversation.
33
34 At the moment, this is ignored by most models. Usage is discouraged.
35 """
36
37 type: Literal["human"] = "human"
38
39 @classmethod
40 def get_lc_namespace(cls) -> List[str]:
41 """Get the namespace of the langchain object."""
42 return ["langchain", "schema", "messages"]
43
44 def __init__(
45 self, content: Union[str, List[Union[str, Dict]]], **kwargs: Any
46 ) -> None:
47 """Pass in content as positional arg."""
48 super().__init__(content=content, **kwargs)
49
50
51HumanMessage.update_forward_refs()

Callers 15

_format_chat_historyFunction · 0.90
image_summarizeFunction · 0.90
img_prompt_funcFunction · 0.90
_format_chat_historyFunction · 0.90
image_summarizeFunction · 0.90
img_prompt_funcFunction · 0.90
_format_chat_historyFunction · 0.90
_format_chat_historyFunction · 0.90
img_prompt_funcFunction · 0.90
_format_chat_historyFunction · 0.90
_format_chat_historyFunction · 0.90
_format_chat_historyFunction · 0.90

Calls

no outgoing calls

Tested by 15

test_invokeFunction · 0.72
test_generateFunction · 0.72
test_agenerateFunction · 0.72
test_invoke_streamingFunction · 0.72
test_agenerate_streamingFunction · 0.72
test_system_messageFunction · 0.72
test_anthropic_callFunction · 0.72
test_anthropic_generateFunction · 0.72