AxiomAi.Provider behaviour (AxiomAI v0.1.12)

View Source

Provider behavior and dispatcher for different AI providers.

Summary

Functions

Dispatches batch embedding requests to the appropriate provider.

Dispatches chat requests to the appropriate provider.

Dispatches chat requests with system prompt, history, and user prompt to the appropriate provider.

Dispatches completion requests to the appropriate provider.

Dispatches embedding requests to the appropriate provider.

Dispatches streaming chat requests to the appropriate provider.

Dispatches streaming chat requests with system prompt, history, and user prompt to the appropriate provider.

Dispatches streaming chat requests with system prompt, history, user prompt, and files to the appropriate provider.

Callbacks

batch_embed(config, texts, opts)

(optional)
@callback batch_embed(config :: map(), texts :: list(), opts :: map()) ::
  {:ok, map()} | {:error, any()}

chat(config, message)

@callback chat(config :: map(), message :: String.t()) :: {:ok, map()} | {:error, any()}

chat(config, system_prompt, history, prompt)

@callback chat(
  config :: map(),
  system_prompt :: String.t(),
  history :: list(),
  prompt :: String.t()
) :: {:ok, map()} | {:error, any()}

complete(config, prompt, options)

@callback complete(config :: map(), prompt :: String.t(), options :: map()) ::
  {:ok, map()} | {:error, any()}

embed(config, text, opts)

(optional)
@callback embed(config :: map(), text :: String.t(), opts :: map()) ::
  {:ok, map()} | {:error, any()}

stream(config, message)

@callback stream(config :: map(), message :: String.t()) :: {:ok, any()} | {:error, any()}

stream(config, system_prompt, history, prompt)

@callback stream(
  config :: map(),
  system_prompt :: String.t(),
  history :: list(),
  prompt :: String.t()
) :: {:ok, any()} | {:error, any()}

Functions

batch_embed(provider, config, texts, opts \\ %{})

@spec batch_embed(atom(), map(), list(), map()) :: {:ok, map()} | {:error, any()}

Dispatches batch embedding requests to the appropriate provider.

chat(provider, config, message)

@spec chat(atom(), map(), String.t()) :: {:ok, map()} | {:error, any()}

Dispatches chat requests to the appropriate provider.

chat(provider, config, system_prompt, history, prompt)

@spec chat(atom(), map(), String.t(), list(), String.t()) ::
  {:ok, map()} | {:error, any()}

Dispatches chat requests with system prompt, history, and user prompt to the appropriate provider.

complete(provider, config, prompt, options)

@spec complete(atom(), map(), String.t(), map()) :: {:ok, map()} | {:error, any()}

Dispatches completion requests to the appropriate provider.

embed(provider, config, text, opts \\ %{})

@spec embed(atom(), map(), String.t(), map()) :: {:ok, map()} | {:error, any()}

Dispatches embedding requests to the appropriate provider.

stream(provider, config, message)

@spec stream(atom(), map(), String.t()) :: {:ok, any()} | {:error, any()}

Dispatches streaming chat requests to the appropriate provider.

stream(provider, config, system_prompt, history, prompt)

@spec stream(atom(), map(), String.t(), list(), String.t()) ::
  {:ok, any()} | {:error, any()}

Dispatches streaming chat requests with system prompt, history, and user prompt to the appropriate provider.

stream(provider, config, system_prompt, history, prompt, files)

@spec stream(atom(), map(), String.t(), list(), String.t(), list()) ::
  {:ok, any()} | {:error, any()}

Dispatches streaming chat requests with system prompt, history, user prompt, and files to the appropriate provider.