LemonChannels. Adapters. ModelPolicyShared behaviour
(lemon_channels v0.1.0)
View Source
Shared ModelPolicyAdapter logic for all channel transports.
Provides model and thinking-level resolution with session overrides
(ephemeral) and persistent policy storage via LemonChannels.ModelPolicy.
Usage
defmodule MyAdapter do
use LemonChannels.Adapters.ModelPolicyShared
@impl true
def channel_name, do: "telegram"
@impl true
def build_route(account_id, chat_id, thread_id) do
thread_str = if is_integer(thread_id), do: to_string(thread_id), else: nil
Route.new("telegram", account_id, to_string(chat_id), thread_str)
end
@impl true
def session_get(session_key), do: ...
@impl true
def session_put(session_key, model), do: ...
@impl true
def format_source_labels, do: %{topic: "topic default", chat: "chat default"}
endOptional callbacks
session_delete/1— for channels that support clearing session overrideslegacy_model_fallback/3— for channels with pre-ModelPolicy datalegacy_thinking_fallback/3— for channels with pre-ModelPolicy thinking datachat_id_guard/1— override the default guard type check