mirror of
https://github.com/Hopiu/llm.git
synced 2026-04-18 20:21:03 +00:00
Show SQL schema for embeddings in docs
This commit is contained in:
parent
73a9043108
commit
b7e6c1675b
4 changed files with 43 additions and 3 deletions
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
|
|
@ -31,7 +31,7 @@ jobs:
|
|||
run: |
|
||||
cog --check \
|
||||
-p "import sys, os; sys._called_from_test=True; os.environ['LLM_USER_PATH'] = '/tmp'" \
|
||||
docs/*.md
|
||||
docs/**/*.md
|
||||
- name: Run Black
|
||||
run: |
|
||||
black --check .
|
||||
|
|
|
|||
2
Justfile
2
Justfile
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
# Rebuild docs with cog
|
||||
@cog:
|
||||
pipenv run cog -r -p "import sys, os; sys._called_from_test=True; os.environ['LLM_USER_PATH'] = '/tmp'" docs/*.md
|
||||
pipenv run cog -r -p "import sys, os; sys._called_from_test=True; os.environ['LLM_USER_PATH'] = '/tmp'" docs/**/*.md
|
||||
|
||||
# Serve live docs on localhost:8000
|
||||
@docs: cog
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@ This will start a live preview server, using [sphinx-autobuild](https://pypi.org
|
|||
|
||||
The CLI `--help` examples in the documentation are managed using [Cog](https://github.com/nedbat/cog). Update those files like this:
|
||||
|
||||
cog -r docs/*.md
|
||||
just cog
|
||||
|
||||
You'll need [Just](https://github.com/casey/just) installed to run this command.
|
||||
|
||||
## Release process
|
||||
|
||||
|
|
|
|||
|
|
@ -135,3 +135,41 @@ for id, score in collection.similar_by_id("cat"):
|
|||
print(id, score)
|
||||
```
|
||||
The item itself is excluded from the results.
|
||||
|
||||
(embeddings-sql-schema)=
|
||||
## SQL schema
|
||||
|
||||
Here's the SQL schema used by the embeddings database:
|
||||
|
||||
<!-- [[[cog
|
||||
import cog
|
||||
from llm.embeddings_migrations import embeddings_migrations
|
||||
import sqlite_utils
|
||||
import re
|
||||
db = sqlite_utils.Database(memory=True)
|
||||
embeddings_migrations.apply(db)
|
||||
|
||||
cog.out("```sql\n")
|
||||
for table in ("collections", "embeddings"):
|
||||
schema = db[table].schema
|
||||
cog.out(format(schema))
|
||||
cog.out("\n")
|
||||
cog.out("```\n")
|
||||
]]] -->
|
||||
```sql
|
||||
CREATE TABLE [collections] (
|
||||
[id] INTEGER PRIMARY KEY,
|
||||
[name] TEXT,
|
||||
[model] TEXT
|
||||
)
|
||||
CREATE TABLE "embeddings" (
|
||||
[collection_id] INTEGER REFERENCES [collections]([id]),
|
||||
[id] TEXT,
|
||||
[embedding] BLOB,
|
||||
[content] TEXT,
|
||||
[metadata] TEXT,
|
||||
[updated] INTEGER,
|
||||
PRIMARY KEY ([collection_id], [id])
|
||||
)
|
||||
```
|
||||
<!-- [[[end]]] -->
|
||||
Loading…
Reference in a new issue