# `LlmComposer.FunctionCallHelpers`
[🔗](https://github.com/doofinder/llm_composer/blob/master/lib/llm_composer/function_call_helpers.ex#L1)

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.

# `build_assistant_with_tools`

```elixir
@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.

# `build_tool_result_messages`

```elixir
@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"]`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
