python-nlql 0.2.0__py3-none-any.whl → 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nlql/__init__.py +10 -16
- nlql/sdk/CLAUDE.md +1 -1
- nlql/sdk/engine.py +2 -1
- {python_nlql-0.2.0.dist-info → python_nlql-0.3.0.dist-info}/METADATA +34 -32
- {python_nlql-0.2.0.dist-info → python_nlql-0.3.0.dist-info}/RECORD +7 -7
- {python_nlql-0.2.0.dist-info → python_nlql-0.3.0.dist-info}/WHEEL +0 -0
- {python_nlql-0.2.0.dist-info → python_nlql-0.3.0.dist-info}/licenses/LICENSE +0 -0
nlql/__init__.py
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Quick start::
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
from nlql import Engine
|
|
6
|
+
from nlql.embed import FakeEmbedder # or OpenAIEmbedder(base_url=..., api_key=...)
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
engine = nlql.Engine(nlql.FakeEmbedder()) # or Engine(OpenAIEmbedder(base_url=..., api_key=...))
|
|
8
|
+
engine = Engine(FakeEmbedder())
|
|
9
9
|
engine.add_text("AI agents plan, use memory, and call tools.", metadata={"status": "published"})
|
|
10
10
|
|
|
11
11
|
results = engine.search('''
|
|
@@ -17,9 +17,12 @@ Quick start::
|
|
|
17
17
|
''')
|
|
18
18
|
for unit in results:
|
|
19
19
|
print(unit.scores.get("rel"), unit.content)
|
|
20
|
+
|
|
21
|
+
Backend implementations (embedders, stores, concrete rerankers) live in their
|
|
22
|
+
submodules: `from nlql.embed import OpenAIEmbedder`, `from nlql.store import
|
|
23
|
+
LocalStore`, `from nlql.rerank import CrossEncoderReranker`.
|
|
20
24
|
"""
|
|
21
25
|
|
|
22
|
-
from nlql.embed import CachedEmbedder, EmbeddingCache, FakeEmbedder, OpenAIEmbedder
|
|
23
26
|
from nlql.errors import (
|
|
24
27
|
NLQLError,
|
|
25
28
|
NLQLExecutionError,
|
|
@@ -33,7 +36,7 @@ from nlql.ir import Query, query_json_schema
|
|
|
33
36
|
from nlql.lang import parse
|
|
34
37
|
from nlql.model import Document, Modality, Payload, Unit
|
|
35
38
|
from nlql.registry import GLOBAL_REGISTRY, Registry, register_function, register_splitter
|
|
36
|
-
from nlql.rerank import
|
|
39
|
+
from nlql.rerank import Reranker
|
|
37
40
|
from nlql.sdk import (
|
|
38
41
|
Engine,
|
|
39
42
|
F,
|
|
@@ -46,7 +49,6 @@ from nlql.sdk import (
|
|
|
46
49
|
select,
|
|
47
50
|
similarity,
|
|
48
51
|
)
|
|
49
|
-
from nlql.store import LocalStore
|
|
50
52
|
from nlql.types import Signature, TypeTag
|
|
51
53
|
|
|
52
54
|
__version__ = "0.2.0"
|
|
@@ -72,17 +74,9 @@ __all__ = [
|
|
|
72
74
|
"parse",
|
|
73
75
|
"Query",
|
|
74
76
|
"query_json_schema",
|
|
75
|
-
#
|
|
76
|
-
"FakeEmbedder",
|
|
77
|
-
"OpenAIEmbedder",
|
|
78
|
-
"EmbeddingCache",
|
|
79
|
-
"CachedEmbedder",
|
|
80
|
-
# rerank
|
|
77
|
+
# rerank protocol (concrete rerankers in nlql.rerank)
|
|
81
78
|
"Reranker",
|
|
82
|
-
|
|
83
|
-
"CrossEncoderReranker",
|
|
84
|
-
# store & registry
|
|
85
|
-
"LocalStore",
|
|
79
|
+
# registry
|
|
86
80
|
"Registry",
|
|
87
81
|
"GLOBAL_REGISTRY",
|
|
88
82
|
"register_function",
|
nlql/sdk/CLAUDE.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
```python
|
|
15
15
|
import nlql
|
|
16
|
-
engine = nlql.Engine(nlql.FakeEmbedder()) # 或 OpenAIEmbedder(base_url=..., api_key=...)
|
|
16
|
+
engine = nlql.Engine(nlql.embed.FakeEmbedder()) # 或 OpenAIEmbedder(base_url=..., api_key=...)
|
|
17
17
|
engine.add_text("...", metadata={"status": "published"})
|
|
18
18
|
results = engine.search('SELECT SENTENCE LET rel = SIMILARITY(content, "x") WHERE rel >= 0.2 LIMIT 5')
|
|
19
19
|
```
|
nlql/sdk/engine.py
CHANGED
|
@@ -39,7 +39,8 @@ class Engine:
|
|
|
39
39
|
:class:`~nlql.embed.OpenAIEmbedder` parameterized by ``base_url``; any other provider
|
|
40
40
|
is just another :class:`~nlql.embed.base.Embedder` implementation::
|
|
41
41
|
|
|
42
|
-
from nlql import Engine
|
|
42
|
+
from nlql import Engine
|
|
43
|
+
from nlql.embed import FakeEmbedder, OpenAIEmbedder
|
|
43
44
|
|
|
44
45
|
Engine(OpenAIEmbedder(base_url="https://your-gateway/v1", api_key="sk-..."))
|
|
45
46
|
Engine(FakeEmbedder()) # deterministic, offline (tests/demos)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-nlql
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: SQL-style semantic query language and retrieval middleware for Agents & RAG
|
|
5
5
|
Project-URL: Repository, https://github.com/natural-language-query-language/python-nlql
|
|
6
6
|
Author: Okysu
|
|
@@ -57,16 +57,18 @@ Description-Content-Type: text/markdown
|
|
|
57
57
|
[](LICENSE)
|
|
58
58
|
[](https://natural-language-query-language.github.io/python-nlql/)
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
**English** · [简体中文](README.zh-CN.md) · [在线文档](https://natural-language-query-language.github.io/python-nlql/)
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
NLQL lets you do semantic search with SQL-style statements. Relevance scoring, filtering, and sorting live in one query — no more scattered embedding calls and post-processing code.
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
Built for Agent and RAG applications: the query itself is structured data, usable directly as an LLM tool-call payload.
|
|
65
|
+
|
|
66
|
+
## What it looks like
|
|
65
67
|
|
|
66
68
|
```python
|
|
67
69
|
import nlql
|
|
68
70
|
|
|
69
|
-
engine = nlql.Engine(nlql.FakeEmbedder()) #
|
|
71
|
+
engine = nlql.Engine(nlql.embed.FakeEmbedder()) # or OpenAIEmbedder, or any Embedder
|
|
70
72
|
engine.add_text("AI agents plan tasks and call tools.", metadata={"status": "published"})
|
|
71
73
|
engine.add_text("Banana bread needs flour and sugar.", metadata={"status": "draft"})
|
|
72
74
|
|
|
@@ -80,54 +82,54 @@ for unit in engine.search('''
|
|
|
80
82
|
print(f"{unit.scores['rel']:+.3f} {unit.content}")
|
|
81
83
|
```
|
|
82
84
|
|
|
83
|
-
|
|
85
|
+
The statement reads almost like SQL: `SELECT` sets the return granularity, `LET` computes relevance, `WHERE` filters, `ORDER BY` / `LIMIT` sort and cap.
|
|
84
86
|
|
|
85
|
-
##
|
|
87
|
+
## Features
|
|
86
88
|
|
|
87
|
-
-
|
|
88
|
-
-
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
89
|
+
- **One statement, full intent** — relevance, filtering, and sorting in one place, not scattered across business code
|
|
90
|
+
- **Three ways to write, identical results** — SQL statement, Python chained builder, or JSON IR; all compile to the same internal representation
|
|
91
|
+
- **Pluggable backends** — built-in store works out of the box; switch to Qdrant / Faiss / Chroma / HnswLib / pgvector with one line
|
|
92
|
+
- **Two-stage retrieval** — attach a reranker after recall for higher accuracy
|
|
93
|
+
- **Multimodal** — text and images share one vector space; retrieve images with text
|
|
94
|
+
- **Explainable** — `engine.explain()` prints the query plan
|
|
93
95
|
|
|
94
|
-
##
|
|
96
|
+
## Installation
|
|
95
97
|
|
|
96
98
|
```bash
|
|
97
99
|
pip install python-nlql
|
|
98
100
|
```
|
|
99
101
|
|
|
100
|
-
|
|
102
|
+
Optional extras:
|
|
101
103
|
|
|
102
|
-
|
|
|
104
|
+
| Command | Purpose |
|
|
103
105
|
|---|---|
|
|
104
|
-
| `pip install "python-nlql[faiss]"` | Faiss
|
|
105
|
-
| `pip install "python-nlql[hnsw]"` | HnswLib
|
|
106
|
-
| `pip install "python-nlql[qdrant]"` | Qdrant
|
|
107
|
-
| `pip install "python-nlql[chroma]"` | Chroma
|
|
108
|
-
| `pip install "python-nlql[pgvector]"` | Postgres + pgvector
|
|
109
|
-
| `pip install "python-nlql[local]"` |
|
|
110
|
-
| `pip install "python-nlql[loaders]"` |
|
|
106
|
+
| `pip install "python-nlql[faiss]"` | Faiss backend |
|
|
107
|
+
| `pip install "python-nlql[hnsw]"` | HnswLib backend (for large-scale data) |
|
|
108
|
+
| `pip install "python-nlql[qdrant]"` | Qdrant backend |
|
|
109
|
+
| `pip install "python-nlql[chroma]"` | Chroma backend |
|
|
110
|
+
| `pip install "python-nlql[pgvector]"` | Postgres + pgvector backend |
|
|
111
|
+
| `pip install "python-nlql[local]"` | local sentence-transformers / CLIP / cross-encoder |
|
|
112
|
+
| `pip install "python-nlql[loaders]"` | DOCX / PDF file loaders |
|
|
111
113
|
|
|
112
|
-
##
|
|
114
|
+
## Switching backends
|
|
113
115
|
|
|
114
|
-
|
|
116
|
+
One line; ingestion and query code stay the same:
|
|
115
117
|
|
|
116
118
|
```python
|
|
117
119
|
from nlql.store.qdrant_store import QdrantStore
|
|
118
120
|
engine = nlql.Engine(embedder, store=QdrantStore(location=":memory:"))
|
|
119
121
|
```
|
|
120
122
|
|
|
121
|
-
##
|
|
123
|
+
## Documentation
|
|
122
124
|
|
|
123
|
-
|
|
125
|
+
Full docs, tutorials, and API reference: **https://natural-language-query-language.github.io/python-nlql/en/**
|
|
124
126
|
|
|
125
|
-
- [
|
|
126
|
-
- [
|
|
127
|
-
- [API
|
|
128
|
-
- [
|
|
127
|
+
- [Quick start](https://natural-language-query-language.github.io/python-nlql/en/content/tutorials/quickstart/)
|
|
128
|
+
- [Design](https://natural-language-query-language.github.io/python-nlql/en/content/concepts/overview/)
|
|
129
|
+
- [API reference](https://natural-language-query-language.github.io/python-nlql/en/reference/sdk/)
|
|
130
|
+
- [中文文档](https://natural-language-query-language.github.io/python-nlql/)
|
|
129
131
|
|
|
130
|
-
|
|
132
|
+
More examples in the [`examples/`](examples/) directory.
|
|
131
133
|
|
|
132
134
|
## License
|
|
133
135
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
nlql/CLAUDE.md,sha256=ozLOpVSZKBKdIGRTmW3-Z0s1lRg2x5M-MXcym2SGz4s,2588
|
|
2
|
-
nlql/__init__.py,sha256=
|
|
2
|
+
nlql/__init__.py,sha256=sHsoP0lUOEq_wPi8SiT0XkyEI3AgVs6dfo5SpanRNfA,2253
|
|
3
3
|
nlql/errors.md,sha256=a8GWN-09pkhu8VFEDT5BsfLH1sN_8kDULH6YljfMiOw,304
|
|
4
4
|
nlql/errors.py,sha256=2qg39dYWL5SGtGNND6grj5ppOjqfcm1HtHKuopZ2ewY,1811
|
|
5
5
|
nlql/embed/CLAUDE.md,sha256=l7li7CdGcRsGAdbuJv15Jequ_yfvZRKYzpiUMs3UIs0,3434
|
|
@@ -56,10 +56,10 @@ nlql/rerank/CLAUDE.md,sha256=dEvFU7vREJB1_CTemomGkIQGtYPJpMlvWoGIV1RYqDE,1716
|
|
|
56
56
|
nlql/rerank/__init__.py,sha256=usS5iDG0xTi9koQraFdV2sM3p3LgiCBTtw8EcKMh0L0,273
|
|
57
57
|
nlql/rerank/base.py,sha256=Xo19JVIei1EgcCE8jmSA1-qJ_4KSnM3hV9PaH-i9tns,1997
|
|
58
58
|
nlql/rerank/cross_encoder.py,sha256=cunbcTFn-aWaAebEBj8gIVmOwT4lf9Sm4EWyOk-DaxI,1730
|
|
59
|
-
nlql/sdk/CLAUDE.md,sha256=
|
|
59
|
+
nlql/sdk/CLAUDE.md,sha256=MZ1X4K1qW3bz6iSMjJ9mPpYspkNHobxcSGBKtkq10co,3585
|
|
60
60
|
nlql/sdk/__init__.py,sha256=mzXS75JVpyqvfQFXePycm6J_W5WiFoinRGJzGRBka4M,414
|
|
61
61
|
nlql/sdk/builder.py,sha256=SPadR5a1HndofzekqlS32KHhVmWF1899iwI9pY-mQQM,5315
|
|
62
|
-
nlql/sdk/engine.py,sha256=
|
|
62
|
+
nlql/sdk/engine.py,sha256=3YGoVEmRMbijne2bfYz5lbz9MypGhQLaLO0IqM6Q2NY,12637
|
|
63
63
|
nlql/store/CLAUDE.md,sha256=ehnr8eJ2Icd2JH2pS5lwtHjH7sVY7Ie5Nb6DuOAKVMo,4681
|
|
64
64
|
nlql/store/__init__.py,sha256=YdV-Io_dJovRYKz83GXoUUaell_EcfdPeK_B6FJEVlQ,266
|
|
65
65
|
nlql/store/base.py,sha256=Vm4UIcLK_UfvvSr1_gbWVI1y8RJewttuY4c9WkBLxiY,2189
|
|
@@ -76,7 +76,7 @@ nlql/types/CLAUDE.md,sha256=U4_D5F54BtsxpKq67rX2z7PUJD26M4gs5GPUF_rFWnU,1721
|
|
|
76
76
|
nlql/types/__init__.py,sha256=36nkQVDZ22qdR0HdWKPb06kkUByX1voRYFVyA2QxVU0,143
|
|
77
77
|
nlql/types/coerce.py,sha256=lksqQekqyxBDRsxZkjBr77yp0-aZibKM-YDXmgtZwao,4039
|
|
78
78
|
nlql/types/core.py,sha256=XJxbWTZplCTOfzVmS7LTokyVnuk-4HEj3N5ZLNPgppM,1290
|
|
79
|
-
python_nlql-0.
|
|
80
|
-
python_nlql-0.
|
|
81
|
-
python_nlql-0.
|
|
82
|
-
python_nlql-0.
|
|
79
|
+
python_nlql-0.3.0.dist-info/METADATA,sha256=nkgYLUK1gZkQW9YeBI8Bd0QILc1Mia9y8EwGeUJoRTc,5747
|
|
80
|
+
python_nlql-0.3.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
81
|
+
python_nlql-0.3.0.dist-info/licenses/LICENSE,sha256=9YZVpGmnIp5KhayjWX5DGOjhSZz_ap_iTZe4mRC4nSY,1062
|
|
82
|
+
python_nlql-0.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|