registry
¤
Registry for LLMs and Operators.
Classes:
Name | Description |
---|---|
LLMRegistry |
Registry for LLMs. |
OperatorRegistry |
Registry for Operators. |
Functions:
Name | Description |
---|---|
register_llm |
A decorator that registers an LLM class to the LLM registry. |
register_operator |
A decorator that registers an operator class to the operator registry. |
Attributes:
Name | Type | Description |
---|---|---|
llm_registry |
The global LLM registry. |
|
operator_registry |
The global Operator registry. |
operator_registry
module-attribute
¤
operator_registry = OperatorRegistry()
The global Operator registry.
LLMRegistry
¤
LLMRegistry()
Registry for LLMs. The registry will have a nested structure: {provider: {model: llm_cls}} But it will also support a direct provider-to-llm_cls mapping for generic LLMs. But it will also support a direct provider-to-llm_cls mapping for generic LLMs.
Methods:
Name | Description |
---|---|
register |
Registers an LLM. |
resolve |
Resolves an LLM. If the model is not specified, the default model of the given provider will be used. |
Source code in src/declarai/operators/registry.py
19 20 |
|
register
¤
Registers an LLM. Args: provider: the name of the LLM provider. llm_cls: the LLM class to register. model: the specific model name.
Returns:
Type | Description |
---|---|
None |
Source code in src/declarai/operators/registry.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
resolve
¤
Resolves an LLM. If the model is not specified, the default model of the given provider will be used. Args: provider: the name of the LLM provider. model: the specific model name. **kwargs: Additional keyword arguments to pass to the LLM initialization.
Returns:
Type | Description |
---|---|
LLM
|
An LLM instance. |
Source code in src/declarai/operators/registry.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|
OperatorRegistry
¤
OperatorRegistry()
Registry for Operators. The registry will have a nested structure: {provider: {operator_type: {model: operator_cls}}} It will support a direct provider-to-operator_cls mapping for generic Operators.
Methods:
Name | Description |
---|---|
register |
Registers an operator. |
resolve |
Resolves an operator. |
Source code in src/declarai/operators/registry.py
88 89 |
|
register
¤
register(
provider: str,
operator_type: str,
operator_cls: Type[BaseOperator],
model: str = "default",
)
Registers an operator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
provider |
str
|
the name of the operator provider. |
required |
operator_type |
str
|
the type of the operator. |
required |
operator_cls |
Type[BaseOperator]
|
the operator class to register. |
required |
model |
str
|
the specific model name that the operator is registered to. |
'default'
|
Returns:
Type | Description |
---|---|
None |
Source code in src/declarai/operators/registry.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
resolve
¤
resolve(
llm_instance: LLM, operator_type: str
) -> Type[BaseOperator]
Resolves an operator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
llm_instance |
LLM
|
An LLM instance. |
required |
operator_type |
str
|
A string representing the type of the operator. |
required |
Returns:
Type | Description |
---|---|
Type[BaseOperator]
|
An operator class. |
Source code in src/declarai/operators/registry.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
register_llm
¤
A decorator that registers an LLM class to the LLM registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
provider |
str
|
the name of the LLM provider. |
required |
model |
Optional[str]
|
the specific model name. |
'default'
|
Returns:
Type | Description |
---|---|
A decorator that registers the decorated LLM class to the LLM registry. |
Source code in src/declarai/operators/registry.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
register_operator
¤
A decorator that registers an operator class to the operator registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
provider |
str
|
the name of the operator provider. |
required |
operator_type |
str
|
the string representing the type of the operator. |
required |
model |
Optional[str]
|
the specific model name. |
'default'
|
Returns:
Type | Description |
---|---|
A decorator that registers the decorated operator class to the operator registry. |
Source code in src/declarai/operators/registry.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
|