Registry#
nlql.registry —— 统一能力注册中心:function / splitter / embedder / modality 走同一 Registry 协议,支持父子链作用域。GLOBAL_REGISTRY 在 import 时种入内置算子。
registry
#
Unified capability registry.
Importing this package seeds the built-in functions into :data:GLOBAL_REGISTRY.
CAPABILITY_KINDS
module-attribute
#
__all__
module-attribute
#
__all__ = ['Registry', 'Capability', 'CAPABILITY_KINDS', 'GLOBAL_REGISTRY', 'register_function', 'register_splitter']
Capability
dataclass
#
Capability(kind: str, name: str, impl: Any = None, signature: Signature | None = None, provides_score: bool = False, pushdownable: bool = False, doc: str | None = None)
A single registered extension point.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
kind
|
str
|
One of :data: |
必需 |
name
|
str
|
Display name (lookup is case-insensitive). |
必需 |
impl
|
Any
|
The implementation object (callable, splitter fn, embedder, …). May be
|
None
|
signature
|
Signature | None
|
Optional declared types, used for arity/type checks and pushdown. |
None
|
provides_score
|
bool
|
When |
False
|
pushdownable
|
bool
|
Hint to the Planner that this capability can be translated to an external store's native query (used in M2). |
False
|
doc
|
str | None
|
Human-readable description. |
None
|
Registry
#
Registry(parent: Registry | None = None)
A capability registry, optionally chained to a parent for scoped overrides.
源代码位于: src/nlql/registry/core.py
register
#
register(kind: str, name: str, impl: Any = None, *, signature: Signature | None = None, provides_score: bool = False, pushdownable: bool = False, doc: str | None = None, overwrite: bool = False) -> Capability
Register a capability into this registry.
引发:
| 类型 | 描述 |
|---|---|
NLQLRegistryError
|
on unknown |
源代码位于: src/nlql/registry/core.py
get
#
get(kind: str, name: str) -> Capability | None
Resolve a capability, checking this registry then its parent chain.
源代码位于: src/nlql/registry/core.py
has
#
names
#
All capability names of kind visible here (child shadows parent).
源代码位于: src/nlql/registry/core.py
function
#
function(name: str, *, signature: Signature | None = None, provides_score: bool = False, pushdownable: bool = False, doc: str | None = None, overwrite: bool = False) -> Callable[[Callable[..., Any]], Callable[..., Any]]
Decorator registering a scalar/predicate function.
源代码位于: src/nlql/registry/core.py
splitter
#
splitter(name: str, *, overwrite: bool = False) -> Callable[[Callable[..., Any]], Callable[..., Any]]
Decorator registering a text splitter (str -> list[str]).
源代码位于: src/nlql/registry/core.py
embedder
#
Decorator/registrar for an embedder instance or class.
源代码位于: src/nlql/registry/core.py
register_function
#
register_function(name: str, *, signature: Signature | None = None, provides_score: bool = False, pushdownable: bool = False, doc: str | None = None, overwrite: bool = False) -> Callable[[Callable[..., Any]], Callable[..., Any]]
Register a function into the process-wide :data:GLOBAL_REGISTRY.
源代码位于: src/nlql/registry/core.py
register_splitter
#
register_splitter(name: str, *, overwrite: bool = False) -> Callable[[Callable[..., Any]], Callable[..., Any]]
Register a splitter into the process-wide :data:GLOBAL_REGISTRY.