# This file is auto-generated by alef — DO NOT EDIT.
# alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
# To regenerate: alef generate
# To verify freshness: alef verify --exit-code
# Issues & docs: https://github.com/kreuzberg-dev/alef
defmodule Kreuzberg.LlmConfig do
  @moduledoc """
  Configuration for an LLM provider/model via liter-llm.

  Each feature (VLM OCR, VLM embeddings, structured extraction) carries
  its own `LlmConfig`, allowing different providers per feature.

  # Example

  ```toml
  [structured_extraction.llm]
  model = "openai/gpt-4o"
  api_key = "sk-..."  # or use KREUZBERG_LLM_API_KEY env var
  ```
  """

  @typedoc "Configuration for an LLM provider/model via liter-llm."
  @type t :: %__MODULE__{
          model: String.t() | nil,
          api_key: String.t() | nil,
          base_url: String.t() | nil,
          timeout_secs: non_neg_integer() | nil,
          max_retries: non_neg_integer() | nil,
          temperature: float() | nil,
          max_tokens: non_neg_integer() | nil
        }

  defstruct model: nil,
            api_key: nil,
            base_url: nil,
            timeout_secs: nil,
            max_retries: nil,
            temperature: nil,
            max_tokens: nil

  defimpl Jason.Encoder do
    @doc false
    def encode(value, opts) do
      value
      |> Map.from_struct()
      |> Enum.reject(fn {_k, v} -> v == nil end)
      |> Enum.into(%{})
      |> Jason.Encoder.encode(opts)
    end
  end
end
