Packages
llm_composer
0.17.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/llm_response.ex
defmodule LlmComposer.LlmResponse do
@moduledoc """
Normalized representation of a response coming from any provider.
Parser modules are responsible for translating provider-specific HTTP results into
this normalized struct so the rest of the library can stay provider-agnostic.
"""
alias LlmComposer.CostInfo
alias LlmComposer.Message
@type provider() :: :open_ai | :open_ai_responses | :ollama | :open_router | :bedrock | :google
@type t() :: %__MODULE__{
cached_tokens: non_neg_integer() | nil,
cost_info: CostInfo.t() | nil,
function_calls: [LlmComposer.FunctionCall.t()] | nil,
input_tokens: non_neg_integer() | nil,
main_response: Message.t() | nil,
metadata: map(),
output_tokens: non_neg_integer() | nil,
previous_response: map() | nil,
provider: provider(),
provider_model: String.t() | nil,
raw: any(),
reasoning_tokens: non_neg_integer() | nil,
response_id: String.t() | nil,
status: :ok | :error,
stream: nil | Enumerable.t()
}
defstruct [
:cached_tokens,
:cost_info,
:function_calls,
:input_tokens,
:main_response,
:metadata,
:output_tokens,
:previous_response,
:provider,
:provider_model,
:raw,
:reasoning_tokens,
:response_id,
:status,
:stream
]
@spec new(map()) :: t()
def new(attrs \\ %{}) when is_map(attrs) do
attrs = Map.put_new(attrs, :metadata, %{})
struct!(__MODULE__, attrs)
end
end