Mnemosyne.LLM behaviour (mnemosyne v0.1.6)

Copy Markdown View Source

Behaviour for LLM chat completions.

Implementations must provide chat/2 and chat_structured/3 callbacks that take messages and options, returning a Response struct.

Summary

Types

message()

@type message() :: %{role: atom(), content: String.t()}

Callbacks

chat(messages, opts)

@callback chat(messages :: [message()], opts :: keyword()) ::
  {:ok, Mnemosyne.LLM.Response.t()}
  | {:error, Mnemosyne.Errors.Framework.AdapterError.t()}

chat_structured(messages, schema, opts)

@callback chat_structured(messages :: [message()], schema :: term(), opts :: keyword()) ::
  {:ok, Mnemosyne.LLM.Response.t()}
  | {:error, Mnemosyne.Errors.Framework.AdapterError.t()}