Skip to main content
Version: Next

mellea.stdlib.components.intrinsic.intrinsic

Intrinsic component for invoking fine-tuned adapter capabilities.

An Intrinsic component references a named adapter from Mellea's intrinsic catalog and transforms a chat completion request — typically by injecting new messages, modifying model parameters, or applying structured output constraints. It must be paired with a backend that supports adapter loading (e.g. LocalHFBackend with a composed Adapter — see mellea.backends.adapters — attached via add_adapter).

Classes​

CLASS Intrinsic ​

A component representing an intrinsic fine-tuned adapter capability.

Intrinsics transform a chat completion request by injecting messages, modifying model parameters, or applying structured output constraints. Must be paired with a backend that supports adapter loading.

Args:

  • intrinsic_name: The user-visible name of the intrinsic. For a name outside Mellea's intrinsics catalog (a custom, non-catalog adapter function), adapter_types must be provided explicitly — this is what lets a custom Intrinsic construct without a catalog entry, replacing the deprecated CustomIntrinsicAdapter shim's catalog monkey-patch (Epic #929, issue #1144).
  • intrinsic_kwargs: Optional keyword arguments required by the intrinsic at invocation time.
  • adapter_types: Adapter types this intrinsic supports. Required for a name outside the catalog; optional (defaults to the catalog entry's own types) otherwise.

Attributes:

  • metadata: The intrinsic metadata fetched from the catalog, or a synthetic entry for a name outside it (see adapter_types above). For that synthetic entry, metadata.repo_id is "" and metadata.revision is "not-a-catalog-entry" — this class never reads either field itself, but code that does (e.g. after reaching in via intrinsic.metadata.repo_id) should treat an empty repo_id as "no catalog entry", not as a real value.
  • intrinsic_kwargs: Keyword arguments passed to the intrinsic.
  • intrinsic_name: User-visible name of this intrinsic (property).
  • adapter_types: Available adapter types that implement this intrinsic (property). Defaults to values in self.metadata.

Raises:

  • ValueError: intrinsic_name is not in the catalog and adapter_types was not provided — there is no way to know which adapter realities to look up without either.

Methods:

FUNC intrinsic_name ​

intrinsic_name(self)

User-visible name of this intrinsic.

FUNC adapter_types ​

adapter_types(self) -> tuple[AdapterType, ...]

Tuple of available adapter types that implement this intrinsic.

FUNC parts ​

parts(self) -> list[Span]

Return the constituent parts of this intrinsic component.

Will need to be implemented by subclasses since not all intrinsics produce text or message output.

Returns:

  • list[Span]: Always an empty list for the base class.

FUNC format_for_llm ​

format_for_llm(self) -> TemplateRepresentation | str

Not implemented for the base Intrinsic class.

Intrinsic components are intended to be used as the action passed directly to the backend, not as a part of the context rendered by the formatter.

Returns:

  • TemplateRepresentation | str: Never returns; always raises.

Raises:

  • NotImplementedError: Always, because Intrinsic does not implement format_for_llm by default.