Posoco LLM Extension - host-injected model slot router
Dependencies
let provider = make_provider_port()
let catalog = provider.model_catalog()
let router = @llm.RouterModelPort::from_catalogs(catalogs=[catalog])pub(open) trait ApiKeyFactory {
fn provider_id(Self) -> String
fn credential_id(Self) -> String
async fn login(Self, interaction : &AuthPromptInteraction) -> ApiKeyCredential raise OAuthError
}pub(open) trait OAuthFactory {
fn provider_id(Self) -> String
fn credential_id(Self) -> String
async fn login(Self, interaction : &AuthInteraction) -> Credential raise OAuthError
}pub(open) trait ProviderFactory {
fn provider_id(Self) -> String
fn credential_id(Self) -> String
fn build(Self, source : ProviderConfigSource) -> ProviderBuildResult raise CompositionError
}pub(open) trait RefreshableProviderFactory {
fn provider_id(Self) -> String
async fn refresh(Self, source : ProviderConfigSource) -> ProviderBuildResult raise CompositionError
}pub(all) struct ModelSlot {
id : String
label : String
provider_id : String
model_id : String
port : &ModelPort
oauth : &OAuthProvider?
api_key : &ApiKeyFactory?
thinking_efforts : Array[String]
context_window : Int?
capabilities : Array[String]
default_effort : String?
display_group : String?
rebuild_on_credential : (Credential) -> ModelSlot?
rebuild_on_api_key : (ApiKeyCredential) -> ModelSlot?
rebuild_on_effort : (String) -> ModelSlot?
}fn ModelSlot::ModelSlot(id~ : String, label~ : String, provider_id~ : String, model_id~ : String, port~ : &ModelPort, oauth? : &OAuthProvider?, api_key? : &ApiKeyFactory?, thinking_efforts? : Array[String], context_window? : Int?, capabilities? : Array[String], default_effort? : String?, display_group? : String?, rebuild_on_credential? : (Credential) -> ModelSlot?, rebuild_on_api_key? : (ApiKeyCredential) -> ModelSlot?, rebuild_on_effort? : (String) -> ModelSlot?) -> ModelSlotpub(all) struct ProviderConfigSource {
settings : Json?
provider_credential : ProviderCredential?
credential : Credential?
api_key_credential : ApiKeyCredential?
cached_models : Json?
credential_store : &ProviderCredentialStore?
}fn ProviderConfigSource::ProviderConfigSource(settings? : Json?, provider_credential? : ProviderCredential?, credential? : Credential?, api_key_credential? : ApiKeyCredential?, cached_models? : Json?, credential_store? : &ProviderCredentialStore?) -> ProviderConfigSourcefn ProviderConfigSource::effective_credential(self : ProviderConfigSource, provider_id : String) -> ProviderCredential? raise CompositionErrorfn ProviderConfigSource::setting(self : ProviderConfigSource, key : String) -> Json? raise CompositionErrorfn ProviderModelCatalog::ProviderModelCatalog(provider_id~ : String, slots~ : Array[ModelSlot], capabilities? : Array[String]) -> ProviderModelCatalog raise CompositionErrorpub(all) struct RouterModelPort {
slots : Map[String, ModelSlot]
slot_order : Array[String]
active_id : String
active_effort : String?
bus : EventBus?
context_states : Map[String, ContextState]
provider_credential_store : &ProviderCredentialStore?
cred_store : &CredentialStore?
auth_interaction : &AuthInteraction?
api_key_store : &ApiKeyStore?
auth_prompt : &AuthPromptInteraction?
credentials : Map[String, Credential]
api_key_credentials : Map[String, ApiKeyCredential]
extra_quota_sources : Map[String, &QuotaSource]
// private fields
}impl CommandPort for RouterModelPortasync fn invoke(self : RouterModelPort, id : String, args : Json) -> CommandOutcome raise CommandErrorimpl Extension for RouterModelPortimpl Lifecycle for RouterModelPortimpl ModelPort for RouterModelPortasync fn chat(self : RouterModelPort, scope : InvocationScope, messages : ArrayView[Message], tools : Array[ToolDef], options : ChatOptions, stream : StreamMode) -> ModelCallResult raise ModelErrorasync fn compact(self : RouterModelPort, scope : InvocationScope, messages : ArrayView[Message], options : ChatOptions, trigger : CompactTrigger) -> CompactResult raise ModelErrorimpl Observer for RouterModelPortimpl BusSubscriber for RouterModelPortfn RouterModelPort::RouterModelPort(slots~ : Array[ModelSlot], default_slot_id? : String, allow_missing_default? : Bool, bus? : EventBus?, provider_credential_store? : &ProviderCredentialStore?, cred_store? : &CredentialStore?, auth_interaction? : &AuthInteraction?, api_key_store? : &ApiKeyStore?, auth_prompt? : &AuthPromptInteraction?, extra_quota_sources? : Map[String, &QuotaSource]) -> RouterModelPort raise CompositionErrorasync fn RouterModelPort::chat(self : RouterModelPort, scope : InvocationScope, messages : ArrayView[Message], tools : Array[ToolDef], options : ChatOptions, stream : StreamMode) -> ModelCallResult raise ModelErrorasync fn RouterModelPort::compact(self : RouterModelPort, scope : InvocationScope, messages : ArrayView[Message], options : ChatOptions, trigger : CompactTrigger) -> CompactResult raise ModelErrorfn RouterModelPort::from_catalogs(catalogs : Array[ProviderModelCatalog], default_slot_id? : String, allow_missing_default? : Bool, bus? : EventBus?, provider_credential_store? : &ProviderCredentialStore?, cred_store? : &CredentialStore?, auth_interaction? : &AuthInteraction?, api_key_store? : &ApiKeyStore?, auth_prompt? : &AuthPromptInteraction?, extra_quota_sources? : Map[String, &QuotaSource], transient_retry? : TransientRetryPolicy?) -> RouterModelPort raise CompositionErrorasync fn RouterModelPort::invoke(self : RouterModelPort, id : String, args : Json) -> CommandOutcome raise CommandErrorfn RouterModelPort::on_compose(self : RouterModelPort, ctx : CompositionView) -> Unit raise CompositionErrorfn RouterModelPort::on_event_at(self : RouterModelPort, scope : EventScope?, event : TurnEvent) -> Unitfn RouterModelPort::replace_provider_slots(self : RouterModelPort, provider_id : String, slots : Array[ModelSlot]) -> Unit raise CompositionErrorfn RouterModelPort::select_effort(self : RouterModelPort, slot_id : String, effort : String) -> Unit raise CommandErrorfn RouterModelPort::switch_slot(self : RouterModelPort, slot_id : String) -> Unit raise CompositionErrortype TransientRetryModelPortimpl ModelPort for TransientRetryModelPortasync fn chat(self : TransientRetryModelPort, scope : InvocationScope, messages : ArrayView[Message], tools : Array[ToolDef], options : ChatOptions, stream : StreamMode) -> ModelCallResult raise ModelErrorasync fn compact(self : TransientRetryModelPort, scope : InvocationScope, messages : ArrayView[Message], options : ChatOptions, trigger : CompactTrigger) -> CompactResult raise ModelErrorasync fn TransientRetryModelPort::chat(self : TransientRetryModelPort, scope : InvocationScope, messages : ArrayView[Message], tools : Array[ToolDef], options : ChatOptions, stream : StreamMode) -> ModelCallResult raise ModelErrorasync fn TransientRetryModelPort::compact(self : TransientRetryModelPort, scope : InvocationScope, messages : ArrayView[Message], options : ChatOptions, trigger : CompactTrigger) -> CompactResult raise ModelErrorInstall
Download zipPosoco LLM Extension - host-injected model slot router
Dependencies