Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

register_embedding_models() missing from plugin-hooks docs page #627

Open
simonw opened this issue Nov 13, 2024 · 0 comments
Open

register_embedding_models() missing from plugin-hooks docs page #627

simonw opened this issue Nov 13, 2024 · 0 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@simonw
Copy link
Owner

simonw commented Nov 13, 2024

https://llm.datasette.io/en/stable/plugins/plugin-hooks.html

## register_commands(cli)
This hook adds new commands to the `llm` CLI tool - for example `llm extra-command`.
This example plugin adds a new `hello-world` command that prints "Hello world!":
```python
from llm import hookimpl
import click
@hookimpl
def register_commands(cli):
@cli.command(name="hello-world")
def hello_world():
"Print hello world"
click.echo("Hello world!")
```
This new command will be added to `llm --help` and can be run using `llm hello-world`.
## register_models(register)
This hook can be used to register one or more additional models.
```python
import llm
@llm.hookimpl
def register_models(register):
register(HelloWorld())
class HelloWorld(llm.Model):
model_id = "helloworld"
def execute(self, prompt, stream, response):
return ["hello world"]
```
{ref}`tutorial-model-plugin` describes how to use this hook in detail.

But there are three hooks:

llm/llm/hookspecs.py

Lines 8 to 20 in d34eac5

@hookspec
def register_commands(cli):
"""Register additional CLI commands, e.g. 'llm mycommand ...'"""
@hookspec
def register_models(register):
"Register additional model instances representing LLM models that can be called"
@hookspec
def register_embedding_models(register):
"Register additional model instances that can be used for embedding"

register_embedding_models() is documented here but it should be in the list of hooks too. https://llm.datasette.io/en/stable/embeddings/writing-plugins.html

@simonw simonw added bug Something isn't working documentation Improvements or additions to documentation labels Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant