View Source LlmComposer.FunctionCallHelpers (llm_composer v0.13.0)
Helpers for building assistant messages and tool-result messages when handling function (tool) calls returned by LLM providers.
This module provides a default implementation for composing the assistant
message that preserves the original assistant response and attaches the
tool_calls metadata. Providers can optionally implement
build_assistant_with_tools/3 to customize behavior.
Summary
Functions
Build an assistant message that preserves the original assistant response and
attaches tool_calls so it can be sent back to the provider along with
tool result messages.
Convert executed function-call results into :tool_result messages which
include the mapping back to the tool call id in metadata["tool_call_id"].
Functions
build_assistant_with_tools(provider_mod, resp, user_msg, opts \\ [])
View Source@spec build_assistant_with_tools( module(), LlmComposer.LlmResponse.t(), LlmComposer.Message.t(), keyword() ) :: LlmComposer.Message.t()
Build an assistant message that preserves the original assistant response and
attaches tool_calls so it can be sent back to the provider along with
tool result messages.
If provider_mod exports build_assistant_with_tools/3, this function will
delegate to that implementation; otherwise it uses a sensible default.
@spec build_tool_result_messages(list()) :: [LlmComposer.Message.t()]
Convert executed function-call results into :tool_result messages which
include the mapping back to the tool call id in metadata["tool_call_id"].