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 CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  Quick start::
4
4
 
5
- import nlql
5
+ from nlql import Engine
6
+ from nlql.embed import FakeEmbedder # or OpenAIEmbedder(base_url=..., api_key=...)
6
7
 
7
- # The embedder is injected — any OpenAI-compatible channel is one class + a base_url.
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 CrossEncoderReranker, FakeReranker, Reranker
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
- # embedders
76
- "FakeEmbedder",
77
- "OpenAIEmbedder",
78
- "EmbeddingCache",
79
- "CachedEmbedder",
80
- # rerank
77
+ # rerank protocol (concrete rerankers in nlql.rerank)
81
78
  "Reranker",
82
- "FakeReranker",
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, OpenAIEmbedder, FakeEmbedder
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.2.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: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
58
58
  [![Documentation](https://img.shields.io/badge/docs-online-blue.svg)](https://natural-language-query-language.github.io/python-nlql/)
59
59
 
60
- NLQL 让你用类似 SQL 的语句做语义检索。把"从文本里找相关内容"这件事,变得像查数据库一样直接——相关度计算、过滤、排序写在一条查询里,不再需要拼凑 embedding 调用和后处理代码。
60
+ **English** · [简体中文](README.zh-CN.md) · [在线文档](https://natural-language-query-language.github.io/python-nlql/)
61
61
 
62
- 适合 Agent RAG 应用:查询本身就是结构化数据,可以直接作为大模型的工具调用载体。
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()) # OpenAIEmbedder,以及任意 Embedder 实现
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
- 语句和 SQL 几乎一样:`SELECT` 指定返回粒度,`LET` 算相关度,`WHERE` 过滤,`ORDER BY` / `LIMIT` 排序限量。
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
- - **三种写法,结果一致** —— SQL 语句、Python 链式构造、JSON IR,都编译到同一份内部表示
89
- - **后端可插拔** —— 内置存储开箱即用;切换 Qdrant / Faiss / Chroma / HnswLib / pgvector 只需改一行
90
- - **召回 + 重排两段式** —— 向量召回后挂重排器,提升结果准确性
91
- - **多模态** —— 文本与图像在同一向量空间,用文字检索图像
92
- - **可解释** —— `engine.explain()` 输出查询的执行计划
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]"` | 本地 sentence-transformers / CLIP / cross-encoder |
110
- | `pip install "python-nlql[loaders]"` | 加载 DOCX / PDF 文件 |
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
- 完整文档、教程与 API 参考:**https://natural-language-query-language.github.io/python-nlql/**
125
+ Full docs, tutorials, and API reference: **https://natural-language-query-language.github.io/python-nlql/en/**
124
126
 
125
- - [快速开始](https://natural-language-query-language.github.io/python-nlql/content/tutorials/quickstart/)
126
- - [设计思路](https://natural-language-query-language.github.io/python-nlql/content/concepts/overview/)
127
- - [API 参考](https://natural-language-query-language.github.io/python-nlql/reference/sdk/)
128
- - [English docs](https://natural-language-query-language.github.io/python-nlql/en/)
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
- 更多示例见 [`examples/`](examples/) 目录。
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=_kcLGw6cvBoyruungWPgy_YGMUoaCou-aEbVTe6FK60,2379
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=QM9PoHRXkKgkJ4TDeKzzQ7o_EZzwftSXIyNF7G371Ss,3579
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=5QEQUYMukJi305zCg8YrHeDxbzgwuWNHF-wx62Ey9IE,12607
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.2.0.dist-info/METADATA,sha256=nA8Qj9v2h3UjKrILMUsiDsx4QifNAO4X45eyHQiW0V4,5618
80
- python_nlql-0.2.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
81
- python_nlql-0.2.0.dist-info/licenses/LICENSE,sha256=9YZVpGmnIp5KhayjWX5DGOjhSZz_ap_iTZe4mRC4nSY,1062
82
- python_nlql-0.2.0.dist-info/RECORD,,
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,,