FunctionMessage#
- class langchain_core.messages.function.FunctionMessage[source]#
Bases:
BaseMessage
Message for passing the result of executing a tool back to a model.
FunctionMessage
are an older version of theToolMessage
schema, and do not contain thetool_call_id
field.The
tool_call_id
field is used to associate the tool call request with the tool call response. This is useful in situations where a chat model is able to request multiple tool calls in parallel.Initialize
BaseMessage
.- Parameters:
content – The string contents of the message.
- param additional_kwargs: dict [Optional]#
Reserved for additional payload data associated with the message.
For example, for a message from an AI, this could include tool calls as encoded by the model provider.
- param content: str | list[str | dict] [Required]#
The string contents of the message.
- param id: str | None = None#
An optional unique identifier for the message.
This should ideally be provided by the provider/model which created the message.
- Constraints:
coerce_numbers_to_str = True
- param name: str [Required]#
The name of the function that was executed.
- param response_metadata: dict [Optional]#
Examples: response headers, logprobs, token counts, model name.
- param type: Literal['function'] = 'function'#
The type of the message (used for serialization). Defaults to
'function'
.
- pretty_print() None #
Print a pretty representation of the message.
- Return type:
None
- pretty_repr(html: bool = False) str #
Get a pretty representation of the message.
- Parameters:
html (bool) – Whether to format the message as HTML. If True, the message will be formatted with HTML tags. Default is False.
- Returns:
A pretty representation of the message.
- Return type:
str
- text() str #
Get the text
content
of the message.- Returns:
The text content of the message.
- Return type:
str
Examples using FunctionMessage