First-party dirsql plugin: semantic search via an OpenAI-compatible embeddings endpoint.
Project description
dirsql-plugin-embeddings
A first-party dirsql plugin that
adds semantic search over a directory of Markdown files and PDFs. It is the worked
implementation behind the Search documents by
meaning how-to,
swapping that guide's local model2vec model for any OpenAI-compatible
/v1/embeddings endpoint.
uvx --with dirsql-plugin-embeddings dirsql
Deliberately minimal (v0.1): one embedding provider shape, one table, no chunking, no config surface beyond three environment variables.
How it works
The plugin ships a dirsql.toml fragment that dirsql discovers when the package
is installed alongside it. The fragment declares:
- the
sqlite-vecextension, forvec_distance_cosine(); - a
documentstable whoseon-filehook embeds each**/*.{md,pdf}file into a TEXTembeddingcolumn; - a
pre-queryhook that embeds the incoming question and emits the nearest-neighbor SQL.
Both hooks are console scripts that call the same embedder.
Markdown is read as UTF-8 text; a .pdf is read with
pypdf, whose per-page extracted text is joined
and embedded like any other document. The extension check is case-insensitive
(.PDF is a PDF), though the glob above is not — globset matches case-sensitively,
so an uppercase-suffixed file needs its own glob entry to be picked up at all.
A PDF that cannot be parsed aborts the scan rather than being skipped: the hook
exits non-zero and dirsql reports the path and the pypdf reason. A scanned,
image-only PDF is not a failure — pypdf yields no text, and the file is indexed
with an empty text, exactly like an empty .md.
Configuration
The embedder reads three environment variables (point them at any hosted or self-managed OpenAI-compatible inference server):
| Variable | Meaning |
|---|---|
DIRSQL_EMBEDDINGS_BASE_URL |
Base URL; /v1/embeddings is appended. |
DIRSQL_EMBEDDINGS_MODEL |
Model name sent in the request. |
DIRSQL_EMBEDDINGS_API_KEY |
Bearer token for Authorization. |
Console scripts
| Script | Hook | Input | Output |
|---|---|---|---|
dirsql-embeddings-on-file |
on-file |
a file's absolute path (argv[1]), text or PDF |
one-line JSON row array with path, text, embedding |
dirsql-embeddings-pre-query |
pre-query |
a raw request body (argv[1]) |
nearest-neighbor SQL over documents |
pre-query accepts both a verbatim server body ({"q": ...}) and the CLI
query subcommand's {"sql": <arg>} wrapper, so dirsql query '{"q": ...}' and
a real POST /query both work.
Tests
Three tiers, per the dirsql testing conventions:
- unit (colocated, mocked seams) —
src/dirsql_plugin_embeddings/*_test.py - integration (
tests/integration/) — each console script as a real subprocess against a local stub/v1/embeddingsserver - e2e (
tests/e2e/) — the full loop through the real launcher +dirsqlbinary +sqlite-vec, nothing mocked but the embedding endpoint
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dirsql_plugin_embeddings-0.1.7.tar.gz.
File metadata
- Download URL: dirsql_plugin_embeddings-0.1.7.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a65f62d34c2676de317f9f53602d1f0915c54b3220d870f2474bb96e775feb6
|
|
| MD5 |
7d61e4a664068a1ab5b46d4f2da1a62b
|
|
| BLAKE2b-256 |
136f0a51040cc4353873d0cfd7bf5ac731053718ccc3404516452b5348d00f58
|
Provenance
The following attestation bundles were made for dirsql_plugin_embeddings-0.1.7.tar.gz:
Publisher:
release.yml on thekevinscott/dirsql
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dirsql_plugin_embeddings-0.1.7.tar.gz -
Subject digest:
1a65f62d34c2676de317f9f53602d1f0915c54b3220d870f2474bb96e775feb6 - Sigstore transparency entry: 2281127526
- Sigstore integration time:
-
Permalink:
thekevinscott/dirsql@1f016b3323bba75bede63c97acd7f589c1ccd72e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/thekevinscott
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1f016b3323bba75bede63c97acd7f589c1ccd72e -
Trigger Event:
push
-
Statement type:
File details
Details for the file dirsql_plugin_embeddings-0.1.7-py3-none-any.whl.
File metadata
- Download URL: dirsql_plugin_embeddings-0.1.7-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcdea77156f1c9075156db172e133638e11b7231b847772fd3ed48645c79544c
|
|
| MD5 |
621080ffedfe68d964cca94adc3d2d64
|
|
| BLAKE2b-256 |
4d122ea14381b364991e95cd5bb485c51074d4d910e79cf099036ea7372df2ac
|
Provenance
The following attestation bundles were made for dirsql_plugin_embeddings-0.1.7-py3-none-any.whl:
Publisher:
release.yml on thekevinscott/dirsql
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dirsql_plugin_embeddings-0.1.7-py3-none-any.whl -
Subject digest:
bcdea77156f1c9075156db172e133638e11b7231b847772fd3ed48645c79544c - Sigstore transparency entry: 2281127543
- Sigstore integration time:
-
Permalink:
thekevinscott/dirsql@1f016b3323bba75bede63c97acd7f589c1ccd72e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/thekevinscott
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1f016b3323bba75bede63c97acd7f589c1ccd72e -
Trigger Event:
push
-
Statement type: