-
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for custom template types to be provided by plugins
- Enhanced the Template class to allow dynamic retrieval of template classes based on type. - Introduced a new hook for registering additional template types. - Updated the load_template function to handle custom template types and raise appropriate errors for unknown types.
- Loading branch information
Showing
7 changed files
with
323 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
## Plugin hooks | ||
|
||
Plugins can implement any of the following hooks: | ||
|
||
### register_commands(cli) | ||
|
||
Register additional CLI commands, e.g. 'llm mycommand ...' | ||
|
||
### register_models(register) | ||
|
||
Register additional model instances representing LLM models that can be called | ||
|
||
### register_embedding_models(register) | ||
|
||
Register additional model instances that can be used for embedding | ||
|
||
### register_template_types() | ||
|
||
Register additional template types that can be used for prompt templates. The hook should return a dictionary mapping template type names to template classes. | ||
|
||
For example, to register a custom template type: | ||
|
||
```python | ||
@llm.hookimpl | ||
def register_template_types(): | ||
"""Register custom template types.""" | ||
return { | ||
"custom": CustomTemplate | ||
} | ||
``` | ||
|
||
The template class should inherit from `llm.Template` and implement the required methods. See the {ref}`prompt-templates` documentation for more details about template types. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.