View Source LlmComposer.FunctionCallHelpers (llm_composer v0.19.2)

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 its function calls. 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 its function 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

Link to this function

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 its function 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.

Link to this function

build_tool_result_messages(executed_calls)

View Source
@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"].