Rename log.db to logs.db, closes #41

This commit is contained in:
Simon Willison 2023-06-17 09:29:36 +01:00
parent b12e28c4ec
commit b27c2cdac9
4 changed files with 11 additions and 11 deletions

View file

@ -54,7 +54,7 @@ Options:
Commands:
prompt* Execute a prompt
init-db Ensure the log.db SQLite database exists
init-db Ensure the logs.db SQLite database exists
keys Manage stored API keys for different models
logs Tools for exploring logged prompts and responses
templates Manage stored prompt templates
@ -83,7 +83,7 @@ Options:
```
Usage: llm init-db [OPTIONS]
Ensure the log.db SQLite database exists
Ensure the logs.db SQLite database exists
All subsequent prompts will be logged to this database.
@ -138,13 +138,13 @@ Options:
Commands:
list* Show recent logged prompts and their responses
path Output the path to the log.db file
path Output the path to the logs.db file
```
#### llm logs path --help
```
Usage: llm logs path [OPTIONS]
Output the path to the log.db file
Output the path to the logs.db file
Options:
--help Show this message and exit.

View file

@ -14,7 +14,7 @@ llm logs path
```
On my Mac that outputs:
```
/Users/simon/Library/Application Support/io.datasette.llm/log.db
/Users/simon/Library/Application Support/io.datasette.llm/logs.db
```
This will differ for other operating systems.
@ -55,7 +55,7 @@ datasette "$(llm logs path)"
```
## SQL schema
Here's the SQL schema used by the `log.db` database:
Here's the SQL schema used by the `logs.db` database:
<!-- [[[cog
import cog

View file

@ -177,7 +177,7 @@ def prompt(
@cli.command()
def init_db():
"""
Ensure the log.db SQLite database exists
Ensure the logs.db SQLite database exists
All subsequent prompts will be logged to this database.
"""
@ -246,7 +246,7 @@ def logs():
@logs.command(name="path")
def logs_path():
"Output the path to the log.db file"
"Output the path to the logs.db file"
click.echo(log_db_path())
@ -391,7 +391,7 @@ def log_db_path():
if llm_log_path:
return pathlib.Path(llm_log_path)
else:
return user_dir() / "log.db"
return user_dir() / "logs.db"
def log(no_log, system, prompt, response, model, chat_id=None, debug=None, start=None):
@ -446,7 +446,7 @@ def get_history(chat_id):
log_path = log_db_path()
if not log_path.exists():
raise click.ClickException(
"This feature requires logging. Run `llm init-db` to create log.db"
"This feature requires logging. Run `llm init-db` to create logs.db"
)
db = sqlite_utils.Database(log_path)
migrate(db)

View file

@ -45,7 +45,7 @@ def test_logs(n, log_path):
assert len(logs) == expected_length
@pytest.mark.parametrize("env", ({}, {"LLM_LOG_PATH": "/tmp/log.db"}))
@pytest.mark.parametrize("env", ({}, {"LLM_LOG_PATH": "/tmp/logs.db"}))
def test_logs_path(monkeypatch, env, log_path):
for key, value in env.items():
monkeypatch.setenv(key, value)