mirror of
https://github.com/Hopiu/llm.git
synced 2026-04-01 04:10:24 +00:00
llm embed-db is now llm collections, refs #229
This commit is contained in:
parent
6012f31e36
commit
5ba34dbe36
4 changed files with 40 additions and 40 deletions
|
|
@ -74,7 +74,7 @@ llm embed phrases hound -m ada-002 -c 'my happy hound'
|
|||
```
|
||||
By default, the SQLite database used to store embeddings is the `embeddings.db` in the user content directory managed by LLM.
|
||||
|
||||
You can see the path to this directory by running `llm embed-db path`.
|
||||
You can see the path to this directory by running `llm collections path`.
|
||||
|
||||
You can store embeddings in a different SQLite database by passing a path to it using the `-d/--database` option to `llm embed`. If this file does not exist yet the command will create it:
|
||||
|
||||
|
|
@ -355,28 +355,28 @@ llm embed-models default --remove-default
|
|||
```
|
||||
When no default model is set, the `llm embed` and `llm embed-multi` commands will require that a model is specified using `-m/--model`.
|
||||
|
||||
## llm embed-db collections
|
||||
## llm collections list
|
||||
|
||||
To list all of the collections in the embeddings database, run this command:
|
||||
|
||||
```bash
|
||||
llm embed-db collections
|
||||
llm collections list
|
||||
```
|
||||
Add `--json` for JSON output:
|
||||
```bash
|
||||
llm embed-db collections --json
|
||||
llm collections list --json
|
||||
```
|
||||
Add `-d/--database` to specify a different database file:
|
||||
```bash
|
||||
llm embed-db collections -d my-embeddings.db
|
||||
llm collections list -d my-embeddings.db
|
||||
```
|
||||
## llm embed-db delete-collection
|
||||
## llm collections delete
|
||||
|
||||
To delete a collection from the database, run this:
|
||||
```bash
|
||||
llm embed-db delete-collection collection-name
|
||||
llm collections delete collection-name
|
||||
```
|
||||
Pass `-d` to specify a different database file:
|
||||
```bash
|
||||
llm embed-db delete-collection collection-name -d my-embeddings.db
|
||||
llm collections delete collection-name -d my-embeddings.db
|
||||
```
|
||||
38
docs/help.md
38
docs/help.md
|
|
@ -62,8 +62,8 @@ Commands:
|
|||
prompt* Execute a prompt
|
||||
aliases Manage model aliases
|
||||
chat Hold an ongoing chat with a model.
|
||||
collections View and manage collections of embeddings
|
||||
embed Embed text and store or return the result
|
||||
embed-db Manage the embeddings database
|
||||
embed-models Manage available embedding models
|
||||
embed-multi Store embeddings for multiple strings at once
|
||||
install Install packages from PyPI into the same environment as LLM
|
||||
|
|
@ -582,26 +582,26 @@ Options:
|
|||
--help Show this message and exit.
|
||||
```
|
||||
|
||||
(help-embed-db)=
|
||||
### llm embed-db --help
|
||||
(help-collections)=
|
||||
### llm collections --help
|
||||
```
|
||||
Usage: llm embed-db [OPTIONS] COMMAND [ARGS]...
|
||||
Usage: llm collections [OPTIONS] COMMAND [ARGS]...
|
||||
|
||||
Manage the embeddings database
|
||||
View and manage collections of embeddings
|
||||
|
||||
Options:
|
||||
--help Show this message and exit.
|
||||
|
||||
Commands:
|
||||
collections Output the path to the embeddings database
|
||||
delete-collection Delete the specified collection
|
||||
path Output the path to the embeddings database
|
||||
delete Delete the specified collection
|
||||
list View a list of collections
|
||||
path Output the path to the embeddings database
|
||||
```
|
||||
|
||||
(help-embed-db-path)=
|
||||
#### llm embed-db path --help
|
||||
(help-collections-path)=
|
||||
#### llm collections path --help
|
||||
```
|
||||
Usage: llm embed-db path [OPTIONS]
|
||||
Usage: llm collections path [OPTIONS]
|
||||
|
||||
Output the path to the embeddings database
|
||||
|
||||
|
|
@ -609,12 +609,12 @@ Options:
|
|||
--help Show this message and exit.
|
||||
```
|
||||
|
||||
(help-embed-db-collections)=
|
||||
#### llm embed-db collections --help
|
||||
(help-collections-list)=
|
||||
#### llm collections list --help
|
||||
```
|
||||
Usage: llm embed-db collections [OPTIONS]
|
||||
Usage: llm collections list [OPTIONS]
|
||||
|
||||
Output the path to the embeddings database
|
||||
View a list of collections
|
||||
|
||||
Options:
|
||||
-d, --database FILE Path to embeddings database
|
||||
|
|
@ -622,16 +622,16 @@ Options:
|
|||
--help Show this message and exit.
|
||||
```
|
||||
|
||||
(help-embed-db-delete-collection)=
|
||||
#### llm embed-db delete-collection --help
|
||||
(help-collections-delete)=
|
||||
#### llm collections delete --help
|
||||
```
|
||||
Usage: llm embed-db delete-collection [OPTIONS] COLLECTION
|
||||
Usage: llm collections delete [OPTIONS] COLLECTION
|
||||
|
||||
Delete the specified collection
|
||||
|
||||
Example usage:
|
||||
|
||||
llm embed-db delete-collection my-collection
|
||||
llm collections delete my-collection
|
||||
|
||||
Options:
|
||||
-d, --database FILE Path to embeddings database
|
||||
|
|
|
|||
18
llm/cli.py
18
llm/cli.py
|
|
@ -1407,17 +1407,17 @@ def embed_models_default(model, remove_default):
|
|||
|
||||
|
||||
@cli.group()
|
||||
def embed_db():
|
||||
"Manage the embeddings database"
|
||||
def collections():
|
||||
"View and manage collections of embeddings"
|
||||
|
||||
|
||||
@embed_db.command(name="path")
|
||||
def embed_db_path():
|
||||
@collections.command(name="path")
|
||||
def collections_path():
|
||||
"Output the path to the embeddings database"
|
||||
click.echo(user_dir() / "embeddings.db")
|
||||
|
||||
|
||||
@embed_db.command(name="collections")
|
||||
@collections.command(name="list")
|
||||
@click.option(
|
||||
"-d",
|
||||
"--database",
|
||||
|
|
@ -1427,7 +1427,7 @@ def embed_db_path():
|
|||
)
|
||||
@click.option("json_", "--json", is_flag=True, help="Output as JSON")
|
||||
def embed_db_collections(database, json_):
|
||||
"Output the path to the embeddings database"
|
||||
"View a list of collections"
|
||||
database = database or (user_dir() / "embeddings.db")
|
||||
db = sqlite_utils.Database(str(database))
|
||||
if not db["collections"].exists():
|
||||
|
|
@ -1457,7 +1457,7 @@ def embed_db_collections(database, json_):
|
|||
)
|
||||
|
||||
|
||||
@embed_db.command(name="delete-collection")
|
||||
@collections.command(name="delete")
|
||||
@click.argument("collection")
|
||||
@click.option(
|
||||
"-d",
|
||||
|
|
@ -1466,14 +1466,14 @@ def embed_db_collections(database, json_):
|
|||
envvar="LLM_EMBEDDINGS_DB",
|
||||
help="Path to embeddings database",
|
||||
)
|
||||
def embed_db_delete_collection(collection, database):
|
||||
def collections_delete(collection, database):
|
||||
"""
|
||||
Delete the specified collection
|
||||
|
||||
Example usage:
|
||||
|
||||
\b
|
||||
llm embed-db delete-collection my-collection
|
||||
llm collections delete my-collection
|
||||
"""
|
||||
database = database or (user_dir() / "embeddings.db")
|
||||
db = sqlite_utils.Database(str(database))
|
||||
|
|
|
|||
|
|
@ -125,9 +125,9 @@ def test_embed_store(user_path, metadata, metadata_error):
|
|||
"updated": ANY,
|
||||
}
|
||||
]
|
||||
# Should show up in 'llm embed-db collections'
|
||||
# Should show up in 'llm collections list'
|
||||
for is_json in (False, True):
|
||||
args = ["embed-db", "collections"]
|
||||
args = ["collections", "list"]
|
||||
if is_json:
|
||||
args.extend(["--json"])
|
||||
result2 = runner.invoke(cli, args)
|
||||
|
|
@ -140,7 +140,7 @@ def test_embed_store(user_path, metadata, metadata_error):
|
|||
assert result2.output == "items: embed-demo\n 1 embedding\n"
|
||||
|
||||
# And test deleting it too
|
||||
result = runner.invoke(cli, ["embed-db", "delete-collection", "items"])
|
||||
result = runner.invoke(cli, ["collections", "delete", "items"])
|
||||
assert result.exit_code == 0
|
||||
assert db["collections"].count == 0
|
||||
assert db["embeddings"].count == 0
|
||||
|
|
@ -154,7 +154,7 @@ def test_collection_delete_errors(user_path):
|
|||
assert db["embeddings"].count == 1
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(
|
||||
cli, ["embed-db", "delete-collection", "does-not-exist"], catch_exceptions=False
|
||||
cli, ["collections", "delete", "does-not-exist"], catch_exceptions=False
|
||||
)
|
||||
assert result.exit_code == 1
|
||||
assert "Collection does not exist" in result.output
|
||||
|
|
|
|||
Loading…
Reference in a new issue