mixle.inference.skill module

Package a fitted model or callable as a reusable skill.

skill wraps a model, subgraph, or plain callable as a named Skill and stores it in a SkillRegistry. Skills carry description, tags, provenance, and any estimation certificate inherited from the wrapped object, so reuse remains auditable.

find(query) ranks skills by lexical overlap against the skill name, description, and tags. SkillRegistry.index() can also mirror skills into a Substrate when a workflow wants retrieval over the same capability catalog.

The wrapped callable is resolved from the object: explicit call= wins, then predict or __call__, then sampler for generative models.

class Skill(name, call, description='', tags=(), certificate=None, provenance=<factory>)[source]

Bases: object

A named, described, provenanced callable derived from a fitted artifact (or a plain function).

Parameters:
name: str
call: Callable[[...], Any]
description: str = ''
tags: tuple[str, ...] = ()
certificate: Any | None = None
provenance: dict[str, Any]
property guarantee: Any | None

The inherited estimation guarantee, if this skill wraps a certified model.

score(query)[source]

Lexical overlap of query with this skill’s name/description/tags, in [0, 1].

Parameters:

query (str)

Return type:

float

class SkillRegistry[source]

Bases: object

A findable collection of skills – register once, retrieve by name or by query.

add(sk)[source]
Parameters:

sk (Skill)

Return type:

Skill

get(name)[source]
Parameters:

name (str)

Return type:

Skill

all()[source]
Return type:

list[Skill]

find(query, k=5)[source]

The best k skills for query by lexical overlap (highest score first, ties by name).

Parameters:
Return type:

list[Skill]

best(query)[source]

The single best-matching skill for query (or None if nothing overlaps).

Parameters:

query (str)

Return type:

Skill | None

index(substrate)[source]

Mirror every skill into a Substrate for embedding-grade recall.

The registry’s own find is a lexical matcher; when a corpus grows past that, index the skills as artifact items and retrieve through the substrate instead. Returns the item ids.

Parameters:

substrate (Any)

Return type:

list[str]

default_registry()[source]

The process-wide default registry skill() writes to when no registry is given.

Return type:

SkillRegistry

skill(name, obj, *, description='', tags=(), call=None, provenance=None, registry=None)[source]

Package obj (a fitted model, a CreatedModel, or a function) as a reusable Skill and register it (see module docstring).

The estimation certificate is inherited from obj.certificate when present (so a certified model yields a certified skill). call overrides how the skill is invoked; otherwise a model verb (predict / __call__ / sampler) is used. The skill is added to registry (or the process default) and returned.

Parameters:
Return type:

Skill