ExLLM.Types (ex_llm v0.8.1)

View Source

Shared type definitions used across ExLLM modules.

This module contains struct definitions and types that are used by multiple modules, helping to avoid circular dependencies.

Summary

Types

content_part()

@type content_part() :: text_content() | image_content()

cost_result()

@type cost_result() :: %{
  provider: String.t(),
  model: String.t(),
  input_tokens: non_neg_integer(),
  output_tokens: non_neg_integer(),
  total_tokens: non_neg_integer(),
  input_cost: float(),
  output_cost: float(),
  total_cost: float(),
  currency: String.t(),
  pricing: %{input: float(), output: float()}
}

image_content()

@type image_content() :: %{
  type: :image_url | :image,
  image_url: image_url() | nil,
  image: image_data() | nil
}

image_data()

@type image_data() :: %{data: String.t(), media_type: String.t()}

image_url()

@type image_url() :: %{url: String.t(), detail: :auto | :low | :high | nil}

message()

@type message() :: %{
  :role => String.t(),
  :content => String.t() | [content_part()],
  optional(:timestamp) => DateTime.t(),
  optional(atom()) => any()
}

pricing()

@type pricing() :: %{
  input_cost_per_token: float() | nil,
  output_cost_per_token: float() | nil,
  currency: String.t()
}

provider_options()

@type provider_options() :: keyword()

stream()

@type stream() :: Enumerable.t()

text_content()

@type text_content() :: %{type: :text, text: String.t()}

token_usage()

@type token_usage() :: %{
  input_tokens: non_neg_integer(),
  output_tokens: non_neg_integer()
}