AxiomAi.Provider behaviour (AxiomAI v0.1.4)

View Source

Provider behavior and dispatcher for different AI providers.

Summary

Functions

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 streaming chat requests to the appropriate provider.

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

Callbacks

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()}

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

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.

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.