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 the ToolMessage schema, and do not contain the tool_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.

Pass in content as positional arg.

Parameters:
  • content – The string contents of the message.

  • kwargs – Additional fields to pass to the

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.

param name: str [Required]#

The name of the function that was executed.

param response_metadata: dict [Optional]#

Response metadata. For example: response headers, logprobs, token counts.

param type: Literal['function'] = 'function'#

The type of the message (used for serialization). Defaults to β€œfunction”.

pretty_print() β†’ None#
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

Examples using FunctionMessage