[docs]classFunctionMessage(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. """name:str"""The name of the function that was executed."""type:Literal["function"]="function""""The type of the message (used for serialization). Defaults to "function"."""@classmethoddefget_lc_namespace(cls)->List[str]:"""Get the namespace of the langchain object. Default is ["langchain", "schema", "messages"]."""return["langchain","schema","messages"]
FunctionMessage.update_forward_refs()
[docs]classFunctionMessageChunk(FunctionMessage,BaseMessageChunk):"""Function 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["FunctionMessageChunk"]="FunctionMessageChunk"# type: ignore[assignment]"""The type of the message (used for serialization). Defaults to "FunctionMessageChunk"."""@classmethoddefget_lc_namespace(cls)->List[str]:"""Get the namespace of the langchain object. Default is ["langchain", "schema", "messages"]."""return["langchain","schema","messages"]def__add__(self,other:Any)->BaseMessageChunk:# type: ignoreifisinstance(other,FunctionMessageChunk):ifself.name!=other.name:raiseValueError("Cannot concatenate FunctionMessageChunks with different names.")returnself.__class__(name=self.name,content=merge_content(self.content,other.content),additional_kwargs=merge_dicts(self.additional_kwargs,other.additional_kwargs),response_metadata=merge_dicts(self.response_metadata,other.response_metadata),id=self.id,)returnsuper().__add__(other)