Skip to content

Commit

Permalink
Schema in logging.md docs, closes #35
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jun 16, 2023
1 parent bcb0a4a commit 43f2cbd
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions docs/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,37 @@ You can also use [Datasette](https://datasette.io/) to browse your logs like thi
```bash
datasette "$(llm logs path)"
```
## SQL schema

Here's the SQL schema used by the `log.db` database:

<!-- [[[cog
import cog
from llm.migrations import migrate
import sqlite_utils
db = sqlite_utils.Database(memory=True)
migrate(db)
schema = db["log"].schema
def cleanup_sql(sql):
first_line = sql.split('(')[0]
inner = sql.split('(')[1].split(')')[0];
columns = [l.strip() for l in inner.split(',')]
return first_line + '(\n ' + ',\n '.join(columns) + '\n);'
cog.out(
"```sql\n{}\n```\n".format(cleanup_sql(schema))
)
]]] -->
```sql
CREATE TABLE "log" (
[id] INTEGER PRIMARY KEY,
[model] TEXT,
[timestamp] TEXT,
[prompt] TEXT,
[system] TEXT,
[response] TEXT,
[chat_id] INTEGER REFERENCES [log]
);
```
<!-- [[[end]]] -->

0 comments on commit 43f2cbd

Please sign in to comment.