Packages
llm_composer
0.20.1
0.20.2
0.20.1
0.20.0
0.19.6
0.19.5
0.19.4
0.19.3
0.19.2
0.19.1
0.19.0
0.18.2
0.18.1
0.18.0
0.17.1
0.17.0
0.16.2
0.16.1
0.16.0
0.15.0
0.14.2
0.14.1
0.14.0
0.13.1
0.13.0
0.12.3
0.12.2
0.12.0
0.11.2
0.11.1
0.11.0
0.10.0
0.8.0
0.7.0
0.6.0
0.5.5
0.5.4
0.5.3
0.5.2
0.5.1
0.5.0
0.4.0
0.3.6
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.0
0.1.0
LlmComposer is an Elixir library that facilitates chat interactions with language models, providing tools to handle user messages, generate responses, and execute functions automatically based on model outputs.
Current section
Files
Jump to
Current section
Files
lib/llm_composer/agent/result.ex
defmodule LlmComposer.Agent.Result do
@moduledoc """
Result of a completed `LlmComposer.Agent` run.
Returned as `{:ok, %LlmComposer.Agent.Result{}}` by `LlmComposer.Agent.run/3` when the loop
reaches a final, tool-free assistant response. It bundles the final response together with the
full conversation, the executed tool calls, and accumulated cost information so callers can
inspect, persist, or display the entire run.
## Fields
- `:response` — the final `LlmComposer.LlmResponse.t()` (the tool-free assistant answer).
- `:messages` — the full conversation, including the user message(s), assistant tool-call
messages and `:tool_result` messages appended on each iteration. Suitable for persistence or
for continuing the conversation.
- `:iterations` — number of model turns performed (each call to the provider counts as one).
- `:cost_infos` — list of `LlmComposer.CostInfo.t()`, one per model turn that reported cost
information, in turn order (turns without cost info are omitted). Requires `track_costs: true`
in settings. Each entry is also emitted on the per-iteration telemetry event, so callers can
record costs incrementally rather than only at the end of the run.
- `:function_calls` — every executed `LlmComposer.FunctionCall.t()` across all iterations, in
execution order, each carrying its `:result`.
"""
alias LlmComposer.CostInfo
alias LlmComposer.FunctionCall
alias LlmComposer.LlmResponse
alias LlmComposer.Message
@type t() :: %__MODULE__{
response: LlmResponse.t(),
messages: [Message.t()],
iterations: non_neg_integer(),
cost_infos: [CostInfo.t()],
function_calls: [FunctionCall.t()]
}
@enforce_keys [:response, :messages, :iterations]
defstruct response: nil,
messages: [],
iterations: 0,
cost_infos: [],
function_calls: []
end