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/settings.ex
defmodule LlmComposer.Settings do
@moduledoc """
Defines the settings for configuring chat interactions with a language model.
This module provides a struct that includes model configuration and prompt settings, enabling fine control over the chat flow and behavior.
"""
defstruct api_key: nil,
provider: nil,
provider_opts: nil,
providers: nil,
sse_middleware: nil,
stream_response: false,
system_prompt: nil,
track_costs: false,
user_prompt_prefix: ""
@typedoc """
Configuration for a chat request.
- `:api_key` — API key for the provider (not needed for all providers).
- `:provider` — provider module (e.g. `LlmComposer.Providers.OpenAI`). Used with `:provider_opts`.
- `:provider_opts` — keyword list of options forwarded to the single provider.
- `:providers` — list of `{module, opts}` tuples for multi-provider routing via `ProvidersRunner`.
- `:sse_middleware` — custom Tesla SSE middleware list to use instead of the default `Tesla.Middleware.SSE` when `stream_response: true`. Useful when the provider sends incomplete SSE chunks that would crash the default middleware.
- `:stream_response` — when `true`, the provider returns a streaming enumerable.
- `:system_prompt` — system prompt string sent to the model.
- `:track_costs` — when `true`, token usage and cost are computed and attached to the response.
- `:user_prompt_prefix` — string prepended to every user message content.
"""
@type t :: %__MODULE__{
api_key: String.t() | nil,
provider: module() | nil,
provider_opts: keyword() | nil,
providers: [{module(), keyword()}] | nil,
sse_middleware: [{module(), keyword()}] | nil,
stream_response: boolean(),
system_prompt: String.t() | nil,
track_costs: boolean(),
user_prompt_prefix: String.t()
}
end