Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 1 addition & 33 deletions lux/lib/lux/llm.ex
Original file line number Diff line number Diff line change
@@ -1,33 +1 @@
defmodule Lux.LLM do
@moduledoc """
A module for interacting with LLMs. Defines the behaviours for LLMs and provides a default implementation.
"""

defmodule Response do
@moduledoc """
A response from an LLM.
"""

@type t :: %__MODULE__{
content: String.t() | nil,
tool_calls: [%{type: String.t(), name: String.t(), params: map()}],
finish_reason: String.t() | nil,
structured_output: map() | nil
}

defstruct content: nil,
tool_calls: [],
finish_reason: nil,
structured_output: nil
end

@type prompt :: String.t()
@type tools :: [Lux.Prism.t() | Lux.Beam.t() | Lux.Lens.t()]
@type options :: map() | keyword()

@callback call(prompt(), tools(), options()) :: {:ok, Response.t()} | {:error, String.t()}

@default_module Application.compile_env(:lux, [Lux.LLM, :default_module], Lux.LLM.OpenAI)

defdelegate call(prompt, tools, options), to: @default_module
end
FILE: lux/lib/lux/llm.ex