Convert an example into a list of messages that can be fed into an LLM.
This code is an adapter that converts a single example to a list of messages that can be fed into a chat model.
The list of messages per example by default corresponds to:
HumanMessage: contains the content from which content should be extracted.AIMessage: contains the extracted information from the modelToolMessage: contains confirmation to the model that the model requested a
tool correctly.If ai_response is specified, there will be a final AIMessage with that
response.
The ToolMessage is required because some chat models are hyper-optimized for
agents rather than for an extraction use case.
Tool call outputs.
Does not need to be provided.
If not provided, a placeholder value will be inserted.
If provided, content for a final AIMessage.