pixelrag-langchain 0.2.1__tar.gz
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.
- pixelrag_langchain-0.2.1/.github/workflows/ci.yml +21 -0
- pixelrag_langchain-0.2.1/.github/workflows/publish.yml +113 -0
- pixelrag_langchain-0.2.1/.gitignore +9 -0
- pixelrag_langchain-0.2.1/LICENSE +202 -0
- pixelrag_langchain-0.2.1/PKG-INFO +181 -0
- pixelrag_langchain-0.2.1/README.md +152 -0
- pixelrag_langchain-0.2.1/examples/langgraph_node.py +66 -0
- pixelrag_langchain-0.2.1/examples/quickstart.py +48 -0
- pixelrag_langchain-0.2.1/pyproject.toml +52 -0
- pixelrag_langchain-0.2.1/runtime.txt +1 -0
- pixelrag_langchain-0.2.1/src/pixelrag_langchain/__init__.py +32 -0
- pixelrag_langchain-0.2.1/src/pixelrag_langchain/client.py +306 -0
- pixelrag_langchain-0.2.1/src/pixelrag_langchain/config.py +67 -0
- pixelrag_langchain-0.2.1/src/pixelrag_langchain/retriever.py +90 -0
- pixelrag_langchain-0.2.1/src/pixelrag_langchain/tool.py +119 -0
- pixelrag_langchain-0.2.1/tests/test_adapters.py +112 -0
- pixelrag_langchain-0.2.1/tests/test_client.py +335 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: ${{ matrix.python-version }}
|
|
19
|
+
- run: pip install -e ".[dev]"
|
|
20
|
+
- run: python -m pytest -v
|
|
21
|
+
- run: python -m pip wheel . --no-deps --wheel-dir dist
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
inputs:
|
|
8
|
+
tag:
|
|
9
|
+
description: "Existing release tag to publish (for example, v0.2.0)"
|
|
10
|
+
required: true
|
|
11
|
+
default: "v0.2.1"
|
|
12
|
+
|
|
13
|
+
concurrency:
|
|
14
|
+
group: pypi-${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.event.release.tag_name }}
|
|
15
|
+
cancel-in-progress: false
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
build:
|
|
19
|
+
name: Build and validate distributions
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
permissions:
|
|
22
|
+
contents: read
|
|
23
|
+
steps:
|
|
24
|
+
- name: Check out the release tag
|
|
25
|
+
uses: actions/checkout@v4
|
|
26
|
+
with:
|
|
27
|
+
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.event.release.tag_name }}
|
|
28
|
+
|
|
29
|
+
- name: Set up Python
|
|
30
|
+
uses: actions/setup-python@v5
|
|
31
|
+
with:
|
|
32
|
+
python-version: "3.12"
|
|
33
|
+
|
|
34
|
+
- name: Install build tooling
|
|
35
|
+
run: python -m pip install --upgrade build "twine>=7.0.0,<8.0.0"
|
|
36
|
+
|
|
37
|
+
- name: Verify tag matches package version
|
|
38
|
+
env:
|
|
39
|
+
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.event.release.tag_name }}
|
|
40
|
+
run: |
|
|
41
|
+
PACKAGE_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
|
|
42
|
+
test "$RELEASE_TAG" = "v$PACKAGE_VERSION"
|
|
43
|
+
|
|
44
|
+
- name: Build distributions
|
|
45
|
+
run: python -m build
|
|
46
|
+
|
|
47
|
+
- name: Validate distribution metadata
|
|
48
|
+
run: python -m twine check dist/*
|
|
49
|
+
|
|
50
|
+
- name: Validate distribution contents
|
|
51
|
+
run: |
|
|
52
|
+
python - <<'PY'
|
|
53
|
+
from email.parser import BytesParser
|
|
54
|
+
from email.policy import default
|
|
55
|
+
from pathlib import Path
|
|
56
|
+
import tarfile
|
|
57
|
+
import zipfile
|
|
58
|
+
|
|
59
|
+
forbidden = "handoff.md"
|
|
60
|
+
for artifact in Path("dist").iterdir():
|
|
61
|
+
if artifact.suffix == ".whl":
|
|
62
|
+
with zipfile.ZipFile(artifact) as archive:
|
|
63
|
+
names = archive.namelist()
|
|
64
|
+
metadata_name = next(name for name in names if name.endswith(".dist-info/METADATA"))
|
|
65
|
+
metadata_bytes = archive.read(metadata_name)
|
|
66
|
+
elif artifact.name.endswith(".tar.gz"):
|
|
67
|
+
with tarfile.open(artifact, "r:gz") as archive:
|
|
68
|
+
names = archive.getnames()
|
|
69
|
+
metadata_name = next(name for name in names if name.endswith("/PKG-INFO"))
|
|
70
|
+
metadata_file = archive.extractfile(metadata_name)
|
|
71
|
+
if metadata_file is None:
|
|
72
|
+
raise SystemExit(f"Could not read {metadata_name} from {artifact}")
|
|
73
|
+
metadata_bytes = metadata_file.read()
|
|
74
|
+
else:
|
|
75
|
+
continue
|
|
76
|
+
|
|
77
|
+
if any(Path(name).name.lower() == forbidden for name in names):
|
|
78
|
+
raise SystemExit(f"{forbidden} found in {artifact}")
|
|
79
|
+
|
|
80
|
+
metadata = BytesParser(policy=default).parsebytes(metadata_bytes)
|
|
81
|
+
for project_url in metadata.get_all("Project-URL", []):
|
|
82
|
+
label = project_url.split(",", 1)[0].strip()
|
|
83
|
+
if len(label) > 32:
|
|
84
|
+
raise SystemExit(
|
|
85
|
+
f"Project-URL label {label!r} in {artifact} exceeds 32 characters"
|
|
86
|
+
)
|
|
87
|
+
PY
|
|
88
|
+
|
|
89
|
+
- name: Upload distributions
|
|
90
|
+
uses: actions/upload-artifact@v4
|
|
91
|
+
with:
|
|
92
|
+
name: python-distributions
|
|
93
|
+
path: dist/
|
|
94
|
+
if-no-files-found: error
|
|
95
|
+
|
|
96
|
+
publish:
|
|
97
|
+
name: Publish distributions to PyPI
|
|
98
|
+
needs: build
|
|
99
|
+
runs-on: ubuntu-latest
|
|
100
|
+
environment:
|
|
101
|
+
name: pypi
|
|
102
|
+
url: https://pypi.org/project/pixelrag-langchain/
|
|
103
|
+
permissions:
|
|
104
|
+
id-token: write
|
|
105
|
+
steps:
|
|
106
|
+
- name: Download distributions
|
|
107
|
+
uses: actions/download-artifact@v4
|
|
108
|
+
with:
|
|
109
|
+
name: python-distributions
|
|
110
|
+
path: dist/
|
|
111
|
+
|
|
112
|
+
- name: Publish distributions to PyPI
|
|
113
|
+
uses: pypa/gh-action-pypi-publish@v1.14.2
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pixelrag-langchain
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: LangChain Tool + Retriever for PixelRAG (screenshot-native visual search) — unofficial community integration
|
|
5
|
+
Project-URL: Homepage, https://github.com/navneet-singh2907/pixelrag-langchain
|
|
6
|
+
Project-URL: Repository, https://github.com/navneet-singh2907/pixelrag-langchain
|
|
7
|
+
Project-URL: Upstream PixelRAG, https://github.com/StarTrail-org/PixelRAG
|
|
8
|
+
Project-URL: PixelRAG paper, https://papers.cool/arxiv/2606.28344
|
|
9
|
+
Author: Navneet Singh
|
|
10
|
+
License: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: agents,langchain,langgraph,pixelrag,rag,visual-search,vlm
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Requires-Dist: httpx<0.28.0,>=0.27.0
|
|
20
|
+
Requires-Dist: langchain-core<0.4.0,>=0.3.0
|
|
21
|
+
Requires-Dist: pydantic<3.0.0,>=2.7.0
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest-httpx<0.31.0,>=0.30.0; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest<9.0.0,>=8.0.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: respx<0.22.0,>=0.21.0; extra == 'dev'
|
|
26
|
+
Provides-Extra: render
|
|
27
|
+
Requires-Dist: playwright<2.0.0,>=1.45.0; extra == 'render'
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
[](https://app.deepsource.com/gh/navneet-singh2907/pixelrag-langchain/)
|
|
31
|
+
|
|
32
|
+
[](https://github.com/navneet-singh2907/pixelrag-langchain/actions/workflows/ci.yml)
|
|
33
|
+
|
|
34
|
+
# pixelrag-langchain
|
|
35
|
+
|
|
36
|
+
A LangChain `Tool` + `Retriever` for [PixelRAG](https://github.com/StarTrail-org/PixelRAG) — visual, screenshot-native search for AI agents.
|
|
37
|
+
|
|
38
|
+
**This is an unofficial, community-built integration.** It is not affiliated with, endorsed by, or maintained by StarTrail-org or the PixelRAG paper authors. All credit for the underlying research and the `pixelrag-serve` engine belongs to them — see [Credits](#credits).
|
|
39
|
+
|
|
40
|
+
## Why visual search
|
|
41
|
+
|
|
42
|
+
Most agent pipelines fetch a page, strip the HTML down to text, chunk it, and embed the chunks. That throws away tables, charts, and layout — information that's often exactly what answers the question. [PixelRAG](https://arxiv.org/abs/2606.28344) (Wang, Li, Wang, Teiletche, Jin, Zaharia, Gonzalez, Min — UC Berkeley, Princeton, EPFL, Databricks) skips the text step entirely: it renders documents to screenshot tiles, retrieves over the images directly, and hands the retrieved tiles to a vision-language model to read.
|
|
43
|
+
|
|
44
|
+
This package doesn't reimplement any of that. It just wraps the existing `pixelrag-serve` search API so it drops into a LangChain (or LangGraph) agent as a normal tool/retriever.
|
|
45
|
+
|
|
46
|
+
## Architecture
|
|
47
|
+
|
|
48
|
+
```mermaid
|
|
49
|
+
flowchart LR
|
|
50
|
+
A["Page / PDF"] --> B["pixelrag-render\n(screenshot tiles)"]
|
|
51
|
+
B --> C["pixelrag-embed\n(Qwen3-VL-Embedding)"]
|
|
52
|
+
C --> D["FAISS index\n(pixelrag-serve)"]
|
|
53
|
+
D -- "this package talks to D" --> E["PixelRAGRetriever /\nPixelRAGSearchTool"]
|
|
54
|
+
E --> F["Your LangChain / LangGraph agent"]
|
|
55
|
+
F --> G["VLM reader\n(your model of choice)"]
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Everything left of the dotted line (`render` → `embed` → `index` → `serve`) is upstream PixelRAG, run by you. This package is the box on the right: a client + LangChain adapters.
|
|
59
|
+
|
|
60
|
+
## Install
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install pixelrag-langchain
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
This installs only the LangChain adapter (`httpx`, `langchain-core`, `pydantic`) — no GPU, no `torch`, no CUDA. It talks to a `pixelrag-serve` instance over HTTP; it doesn't run embedding or indexing itself.
|
|
67
|
+
|
|
68
|
+
## Quickstart — zero setup
|
|
69
|
+
|
|
70
|
+
Upstream PixelRAG runs an official public production endpoint — no API key or index download required. Nothing to install beyond this package:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from pixelrag_langchain import PixelRAGRetriever, PixelRAGConfig
|
|
74
|
+
|
|
75
|
+
retriever = PixelRAGRetriever(config=PixelRAGConfig.hosted())
|
|
76
|
+
docs = retriever.invoke("What is the capital of France?")
|
|
77
|
+
|
|
78
|
+
for doc in docs:
|
|
79
|
+
print(doc.metadata["score"], doc.metadata["source"])
|
|
80
|
+
print(doc.metadata["image_url"]) # fetchable PNG URL
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`PixelRAGConfig.hosted()` points at `https://api.pixelrag.ai`, upstream's documented production endpoint. It uses their infrastructure and Wikipedia index, not your documents. PixelRAG does not publish throughput, latency, or rate-limit guarantees; self-host when you need guaranteed capacity or private data.
|
|
84
|
+
|
|
85
|
+
## Retrieving the actual tile images
|
|
86
|
+
|
|
87
|
+
Search results identify each screenshot with `article_id`, `tile_index`, and `chunk_index`. Version 0.2 turns those coordinates into the upstream-supported `/tile/...` URL; the server-relative `path` field is informational and should not be used to construct URLs.
|
|
88
|
+
|
|
89
|
+
Use the client when you want explicit control over image downloads:
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from pixelrag_langchain import PixelRAGClient, PixelRAGConfig
|
|
93
|
+
|
|
94
|
+
with PixelRAGClient(PixelRAGConfig.hosted()) as client:
|
|
95
|
+
tile = client.search("diagram of a transformer architecture", n_docs=1)[0]
|
|
96
|
+
print(client.tile_url(tile))
|
|
97
|
+
png_bytes = client.fetch_tile(tile)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The separate `GET /tile/{article_id}/{tile_index}/{chunk_index}` request is the recommended default because it keeps search responses small. If you need every image inline, explicitly request base64 data:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
with PixelRAGClient(PixelRAGConfig.hosted()) as client:
|
|
104
|
+
tiles = client.search("quarterly revenue chart", include_images=True)
|
|
105
|
+
print(tiles[0].image_base64)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`PixelRAGRetriever` exposes the coordinate URL in both `metadata["tile_url"]` and `metadata["image_url"]`. `PixelRAGSearchTool` provides `tile_image_url()` and `fetch_tile_bytes()` for structured LangGraph workflows. See [`examples/langgraph_node.py`](examples/langgraph_node.py) for a complete multimodal-message handoff.
|
|
109
|
+
|
|
110
|
+
The API is currently pre-1.0. Its authoritative machine-readable contract is served at [`/openapi.json`](https://api.pixelrag.ai/openapi.json); this package parses additive hit fields leniently.
|
|
111
|
+
|
|
112
|
+
For operational checks, `client.health()` returns a best-effort boolean and `client.status()` returns the server's current index diagnostics.
|
|
113
|
+
|
|
114
|
+
## Quickstart — your own documents
|
|
115
|
+
|
|
116
|
+
For real use — your own PDFs, internal docs, scraped pages — run `pixelrag serve` yourself:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
pip install 'pixelrag[serve]'
|
|
120
|
+
|
|
121
|
+
# Download a pre-built Wikipedia index, or build your own from `pip install 'pixelrag[index]'`
|
|
122
|
+
huggingface-cli download StarTrail-org/pixelrag-faiss-indexes \
|
|
123
|
+
--repo-type dataset --include "search_index_normed_v2/*" --local-dir ./index
|
|
124
|
+
|
|
125
|
+
pixelrag serve --index-dir ./index/search_index_normed_v2 --port 30001
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from pixelrag_langchain import PixelRAGRetriever, PixelRAGConfig
|
|
130
|
+
|
|
131
|
+
retriever = PixelRAGRetriever(config=PixelRAGConfig(base_url="http://localhost:30001"))
|
|
132
|
+
docs = retriever.invoke("What is the capital of France?")
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## As an agent tool
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
from langchain.agents import create_agent
|
|
139
|
+
from pixelrag_langchain import PixelRAGSearchTool, PixelRAGConfig
|
|
140
|
+
|
|
141
|
+
tool = PixelRAGSearchTool(config=PixelRAGConfig.hosted()) # or base_url="http://localhost:30001"
|
|
142
|
+
agent = create_agent(model="your-model", tools=[tool])
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Nothing here defaults to a single host silently — `PixelRAGConfig(base_url=...)` accepts any pixelrag-serve-compatible URL, including your own deployment; `.hosted()` is one explicit opt-in line, not a hidden default.
|
|
146
|
+
|
|
147
|
+
## What this package is *not*
|
|
148
|
+
|
|
149
|
+
- Not a reimplementation of PixelRAG's render/embed/index/serve pipeline — install the [upstream project](https://github.com/StarTrail-org/PixelRAG) for that.
|
|
150
|
+
- Not a hosted service itself. `PixelRAGConfig.hosted()` is a convenience pointer to *upstream's* public endpoint, not infrastructure we run.
|
|
151
|
+
- Not affiliated with StarTrail-org, Berkeley Sky Computing Lab, BAIR, or the Berkeley NLP Group, who built the actual PixelRAG engine and research this wraps.
|
|
152
|
+
|
|
153
|
+
## Benchmarks (from the upstream paper, not measured by this package)
|
|
154
|
+
|
|
155
|
+
Reported in [PIXELRAG: Web Screenshots Beat Text for Retrieval-Augmented Generation](https://arxiv.org/abs/2606.28344) (arXiv:2606.28344):
|
|
156
|
+
|
|
157
|
+
| Metric | Text-based RAG | PixelRAG | Context |
|
|
158
|
+
|---|---|---|---|
|
|
159
|
+
| Prompt tokens, agentic benchmark | 37.5M | 3.6M | MoNaCo multi-step agent benchmark |
|
|
160
|
+
| Accuracy gain | baseline | up to +18.1% | vs. text-based RAG baselines, across NQ/SimpleQA/MMSearch/LiveVQA |
|
|
161
|
+
| Token cost via image compression | — | up to 3x reduction | lower-resolution tiles, accuracy preserved |
|
|
162
|
+
|
|
163
|
+
These are the paper's own reported numbers, not something we independently reproduced — treat them as a starting point for your own evaluation on your workload, not a guarantee.
|
|
164
|
+
|
|
165
|
+
## Development
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
git clone https://github.com/navneet-singh2907/pixelrag-langchain
|
|
169
|
+
cd pixelrag-langchain
|
|
170
|
+
pip install -e ".[dev]"
|
|
171
|
+
pytest
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Credits
|
|
175
|
+
|
|
176
|
+
- **PixelRAG** engine, paper, and research: Yichuan Wang, Zhifei Li, Zirui Wang, Paul Teiletche, Lesheng Jin, Matei Zaharia, Joseph E. Gonzalez, Sewon Min. [Paper](https://arxiv.org/abs/2606.28344) · [Code](https://github.com/StarTrail-org/PixelRAG) (Apache-2.0).
|
|
177
|
+
- This package: an independent, unofficial LangChain adapter around that work.
|
|
178
|
+
|
|
179
|
+
## License
|
|
180
|
+
|
|
181
|
+
Apache-2.0 — see [LICENSE](LICENSE). This is a new work built to talk to PixelRAG over HTTP; it does not vendor or redistribute any upstream PixelRAG code, so no NOTICE carryover is required, but attribution is given above regardless because it's their research this is built on.
|