trustgraph 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.
Potentially problematic release.
This version of trustgraph might be problematic. Click here for more details.
- trustgraph-0.2.1/LICENSE +202 -0
- trustgraph-0.2.1/PKG-INFO +454 -0
- trustgraph-0.2.1/README.md +420 -0
- trustgraph-0.2.1/scripts/chunker-recursive +6 -0
- trustgraph-0.2.1/scripts/embeddings-hf +6 -0
- trustgraph-0.2.1/scripts/embeddings-vectorize +6 -0
- trustgraph-0.2.1/scripts/graph-rag +6 -0
- trustgraph-0.2.1/scripts/graph-show +45 -0
- trustgraph-0.2.1/scripts/graph-to-turtle +37 -0
- trustgraph-0.2.1/scripts/graph-write-cassandra +6 -0
- trustgraph-0.2.1/scripts/kg-extract-definitions +6 -0
- trustgraph-0.2.1/scripts/kg-extract-relationships +6 -0
- trustgraph-0.2.1/scripts/llm-azure-text +6 -0
- trustgraph-0.2.1/scripts/llm-claude-text +6 -0
- trustgraph-0.2.1/scripts/llm-ollama-text +6 -0
- trustgraph-0.2.1/scripts/llm-vertexai-text +6 -0
- trustgraph-0.2.1/scripts/loader +128 -0
- trustgraph-0.2.1/scripts/pdf-decoder +6 -0
- trustgraph-0.2.1/scripts/query +21 -0
- trustgraph-0.2.1/scripts/run-processing +6 -0
- trustgraph-0.2.1/scripts/vector-write-milvus +6 -0
- trustgraph-0.2.1/setup.cfg +4 -0
- trustgraph-0.2.1/setup.py +67 -0
- trustgraph-0.2.1/trustgraph/__init__.py +0 -0
- trustgraph-0.2.1/trustgraph/chunker/__init__.py +0 -0
- trustgraph-0.2.1/trustgraph/chunker/recursive/__init__.py +3 -0
- trustgraph-0.2.1/trustgraph/chunker/recursive/__main__.py +7 -0
- trustgraph-0.2.1/trustgraph/chunker/recursive/chunker.py +173 -0
- trustgraph-0.2.1/trustgraph/decoder/__init__.py +0 -0
- trustgraph-0.2.1/trustgraph/decoder/pdf/__init__.py +3 -0
- trustgraph-0.2.1/trustgraph/decoder/pdf/__main__.py +7 -0
- trustgraph-0.2.1/trustgraph/decoder/pdf/pdf_decoder.py +174 -0
- trustgraph-0.2.1/trustgraph/edge_map.py +102 -0
- trustgraph-0.2.1/trustgraph/embeddings/__init__.py +0 -0
- trustgraph-0.2.1/trustgraph/embeddings/hf/__init__.py +3 -0
- trustgraph-0.2.1/trustgraph/embeddings/hf/__main__.py +7 -0
- trustgraph-0.2.1/trustgraph/embeddings/hf/hf.py +165 -0
- trustgraph-0.2.1/trustgraph/embeddings/vectorize/__init__.py +3 -0
- trustgraph-0.2.1/trustgraph/embeddings/vectorize/__main__.py +6 -0
- trustgraph-0.2.1/trustgraph/embeddings/vectorize/vectorize.py +163 -0
- trustgraph-0.2.1/trustgraph/embeddings_client.py +71 -0
- trustgraph-0.2.1/trustgraph/graph/__init__.py +0 -0
- trustgraph-0.2.1/trustgraph/graph/cassandra_write/__init__.py +3 -0
- trustgraph-0.2.1/trustgraph/graph/cassandra_write/__main__.py +7 -0
- trustgraph-0.2.1/trustgraph/graph/cassandra_write/write.py +148 -0
- trustgraph-0.2.1/trustgraph/graph_rag.py +227 -0
- trustgraph-0.2.1/trustgraph/graph_rag_client.py +68 -0
- trustgraph-0.2.1/trustgraph/kg/__init__.py +0 -0
- trustgraph-0.2.1/trustgraph/kg/extract_definitions/__init__.py +3 -0
- trustgraph-0.2.1/trustgraph/kg/extract_definitions/__main__.py +7 -0
- trustgraph-0.2.1/trustgraph/kg/extract_definitions/extract.py +197 -0
- trustgraph-0.2.1/trustgraph/kg/extract_relationships/__init__.py +3 -0
- trustgraph-0.2.1/trustgraph/kg/extract_relationships/__main__.py +7 -0
- trustgraph-0.2.1/trustgraph/kg/extract_relationships/extract.py +253 -0
- trustgraph-0.2.1/trustgraph/llm/__init__.py +0 -0
- trustgraph-0.2.1/trustgraph/llm/azure_text/__init__.py +3 -0
- trustgraph-0.2.1/trustgraph/llm/azure_text/__main__.py +7 -0
- trustgraph-0.2.1/trustgraph/llm/azure_text/llm.py +213 -0
- trustgraph-0.2.1/trustgraph/llm/claude_text/__init__.py +3 -0
- trustgraph-0.2.1/trustgraph/llm/claude_text/__main__.py +7 -0
- trustgraph-0.2.1/trustgraph/llm/claude_text/llm.py +192 -0
- trustgraph-0.2.1/trustgraph/llm/ollama_text/__init__.py +3 -0
- trustgraph-0.2.1/trustgraph/llm/ollama_text/__main__.py +7 -0
- trustgraph-0.2.1/trustgraph/llm/ollama_text/llm.py +174 -0
- trustgraph-0.2.1/trustgraph/llm/vertexai_text/__init__.py +3 -0
- trustgraph-0.2.1/trustgraph/llm/vertexai_text/__main__.py +7 -0
- trustgraph-0.2.1/trustgraph/llm/vertexai_text/llm.py +258 -0
- trustgraph-0.2.1/trustgraph/llm_client.py +71 -0
- trustgraph-0.2.1/trustgraph/log_level.py +20 -0
- trustgraph-0.2.1/trustgraph/processing/__init__.py +3 -0
- trustgraph-0.2.1/trustgraph/processing/__main__.py +7 -0
- trustgraph-0.2.1/trustgraph/processing/processing.py +171 -0
- trustgraph-0.2.1/trustgraph/prompts.py +138 -0
- trustgraph-0.2.1/trustgraph/rag/__init__.py +0 -0
- trustgraph-0.2.1/trustgraph/rag/graph/__init__.py +3 -0
- trustgraph-0.2.1/trustgraph/rag/graph/__main__.py +7 -0
- trustgraph-0.2.1/trustgraph/rag/graph/rag.py +177 -0
- trustgraph-0.2.1/trustgraph/rdf.py +6 -0
- trustgraph-0.2.1/trustgraph/schema.py +67 -0
- trustgraph-0.2.1/trustgraph/trustgraph.py +108 -0
- trustgraph-0.2.1/trustgraph/vector/__init__.py +0 -0
- trustgraph-0.2.1/trustgraph/vector/milvus_write/__init__.py +3 -0
- trustgraph-0.2.1/trustgraph/vector/milvus_write/__main__.py +7 -0
- trustgraph-0.2.1/trustgraph/vector/milvus_write/write.py +140 -0
- trustgraph-0.2.1/trustgraph.egg-info/PKG-INFO +454 -0
- trustgraph-0.2.1/trustgraph.egg-info/SOURCES.txt +87 -0
- trustgraph-0.2.1/trustgraph.egg-info/dependency_links.txt +1 -0
- trustgraph-0.2.1/trustgraph.egg-info/requires.txt +19 -0
- trustgraph-0.2.1/trustgraph.egg-info/top_level.txt +1 -0
trustgraph-0.2.1/LICENSE
ADDED
|
@@ -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,454 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: trustgraph
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: trustgraph.ai
|
|
5
|
+
Home-page: https://github.com/trustgraph.ai/FIXME.git
|
|
6
|
+
Download-URL: https://github.com/trustgraph.ai/FIXME.git/archive/refs/tags/v0.2.1.tar.gz
|
|
7
|
+
Author: trustgraph.ai
|
|
8
|
+
Author-email: security@trustgraph.ai
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: torch
|
|
16
|
+
Requires-Dist: urllib3
|
|
17
|
+
Requires-Dist: transformers
|
|
18
|
+
Requires-Dist: sentence-transformers
|
|
19
|
+
Requires-Dist: rdflib
|
|
20
|
+
Requires-Dist: pymilvus
|
|
21
|
+
Requires-Dist: langchain
|
|
22
|
+
Requires-Dist: langchain-core
|
|
23
|
+
Requires-Dist: langchain-huggingface
|
|
24
|
+
Requires-Dist: langchain-text-splitters
|
|
25
|
+
Requires-Dist: langchain-community
|
|
26
|
+
Requires-Dist: huggingface-hub
|
|
27
|
+
Requires-Dist: requests
|
|
28
|
+
Requires-Dist: cassandra-driver
|
|
29
|
+
Requires-Dist: pulsar-client
|
|
30
|
+
Requires-Dist: pypdf
|
|
31
|
+
Requires-Dist: anthropic
|
|
32
|
+
Requires-Dist: google-cloud-aiplatform
|
|
33
|
+
Requires-Dist: pyyaml
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# TrustGraph
|
|
37
|
+
|
|
38
|
+
## Introduction
|
|
39
|
+
|
|
40
|
+
TrustGraph provides a means to run a pipeline of flexible AI processing
|
|
41
|
+
components in a flexible means to achieve a processing pipeline.
|
|
42
|
+
|
|
43
|
+
The processing components are interconnected with a pub/sub engine to
|
|
44
|
+
make it easier to switch different procesing components in and out, or
|
|
45
|
+
to construct different kinds of processing. The processing components
|
|
46
|
+
do things like, decode documents, chunk text, perform embeddings,
|
|
47
|
+
apply a local SLM/LLM, call an LLM API, and invoke LLM predictions.
|
|
48
|
+
|
|
49
|
+
The processing showcases Graph RAG algorithms which can be used to
|
|
50
|
+
produce a knowledge graph from documents, which can then be queried by
|
|
51
|
+
a Graph RAG query service.
|
|
52
|
+
|
|
53
|
+
Processing items are executed in containers. Processing can be scaled-up
|
|
54
|
+
by deploying multiple containers.
|
|
55
|
+
|
|
56
|
+
### Features
|
|
57
|
+
|
|
58
|
+
- PDF decoding
|
|
59
|
+
- Text chunking
|
|
60
|
+
- Invocation of LLMs hosted in Ollama
|
|
61
|
+
- Invocation of LLMs: Claude, VertexAI and Azure serverless endpoints
|
|
62
|
+
- Application of a HuggingFace embeddings algorithm
|
|
63
|
+
- Knowledge graph extraction
|
|
64
|
+
- Graph edge loading into Cassandra
|
|
65
|
+
- Storing embeddings in Milvus
|
|
66
|
+
- Embedding query service
|
|
67
|
+
- Graph RAG query service
|
|
68
|
+
- All procesing integrates with Apache Pulsar
|
|
69
|
+
- Containers, so can be deployed using Docker Compose or Kubernetes
|
|
70
|
+
- Plug'n'play, switch different LLM modules to suit your LLM options
|
|
71
|
+
|
|
72
|
+
## Architecture
|
|
73
|
+
|
|
74
|
+

|
|
75
|
+
|
|
76
|
+
A set of modules are executed which use Apache Pulsar as a pub/sub system.
|
|
77
|
+
This means that Pulsar provides input the modules and accept output.
|
|
78
|
+
|
|
79
|
+
Pulsar provides two types of connectivity:
|
|
80
|
+
- For processing flows, Pulsar accepts the output of a processing module
|
|
81
|
+
and queues it for input to the next module.
|
|
82
|
+
- For services such as LLMs and embeddings, Pulsar provides a client/server
|
|
83
|
+
model. A Pulsar queue is used as the input to the service. When
|
|
84
|
+
processed, the output is delivered to a separate queue so that the caller
|
|
85
|
+
can collect the data.
|
|
86
|
+
|
|
87
|
+
All the code is bundled into a single Python package which can be used to
|
|
88
|
+
use all the functionality. There is also a container image with the
|
|
89
|
+
package installed which can be used to run everything.
|
|
90
|
+
|
|
91
|
+
## Included modules
|
|
92
|
+
|
|
93
|
+
- `chunker-recursive` - Accepts text documents and uses LangChain recurse
|
|
94
|
+
chunking algorithm to produce smaller text chunks.
|
|
95
|
+
- `embeddings-hf` - A service which analyses text and returns a vector
|
|
96
|
+
embedding using one of the HuggingFace embeddings models.
|
|
97
|
+
- `embeddings-vectorize` - Uses an embeddings service to get a vector
|
|
98
|
+
embedding which is added to the processor payload.
|
|
99
|
+
- `graph-rag` - A query service which applies a Graph RAG algorithm to
|
|
100
|
+
provide a response to a text prompt.
|
|
101
|
+
- `graph-write-cassandra` - Takes knowledge graph edges and writes them to
|
|
102
|
+
a Cassandra store.
|
|
103
|
+
- `kg-extract-definitions` - knowledge extractor - examines text and
|
|
104
|
+
produces graph edges.
|
|
105
|
+
describing discovered terms and also their defintions. Definitions are
|
|
106
|
+
derived using the input documents.
|
|
107
|
+
- `kg-extract-relationships` - knowledge extractor - examines text and
|
|
108
|
+
produces graph edges describing the relationships between discovered
|
|
109
|
+
terms.
|
|
110
|
+
- `llm-azure-text` - An LLM service which uses an Azure serverless endpoint
|
|
111
|
+
to answer prompts.
|
|
112
|
+
- `llm-claude-text` - An LLM service which uses Anthropic Claude
|
|
113
|
+
to answer prompts.
|
|
114
|
+
- `llm-ollama-text` - An LLM service which uses an Ollama service to answer
|
|
115
|
+
prompts.
|
|
116
|
+
- `llm-vertexai-text` - An LLM service which uses VertexAI
|
|
117
|
+
to answer prompts.
|
|
118
|
+
- `loader` - Takes a document and loads into the processing pipeline. Used
|
|
119
|
+
e.g. to add PDF documents.
|
|
120
|
+
- `pdf-decoder` - Takes a PDF doc and emits text extracted from the document.
|
|
121
|
+
Text extraction from PDF is not a perfect science as PDF is a printable
|
|
122
|
+
format. For instance, the wrapping of text between lines in a PDF document
|
|
123
|
+
is not semantically encoded, so the decoder will see wrapped lines as
|
|
124
|
+
space-separated.
|
|
125
|
+
- `vector-write-milvus` - Takes vector-entity mappings and records them
|
|
126
|
+
in the vector embeddings store.
|
|
127
|
+
|
|
128
|
+
## Getting started
|
|
129
|
+
|
|
130
|
+
A good starting point is to try to run one of the Docker Compose files.
|
|
131
|
+
This can be run on Linux or a Macbook (maybe Windows - not tested).
|
|
132
|
+
|
|
133
|
+
There are 4 docker compose files to get you started with one of the
|
|
134
|
+
following LLM types:
|
|
135
|
+
- VertexAI on Google Cloud
|
|
136
|
+
- Claud Anthropic
|
|
137
|
+
- Azure serverless endpoint
|
|
138
|
+
- An Ollama-hosted LLM for an LLM running on local hardware
|
|
139
|
+
|
|
140
|
+
Using the Docker Compose you should be able to...
|
|
141
|
+
- Run enough components to start a Graph RAG indexing pipeline. This includes
|
|
142
|
+
stores, LLM interfaces and processing components.
|
|
143
|
+
- Check the logs to ensure that things started up correctly
|
|
144
|
+
- Load some test data and starting indexing
|
|
145
|
+
- Check the graph to see that some data has started to load
|
|
146
|
+
- Run a query which uses the vector and graph stores to produce a prompt
|
|
147
|
+
which is answered using an LLM.
|
|
148
|
+
|
|
149
|
+
If you get a Graph RAG response to the query, everything is working.
|
|
150
|
+
|
|
151
|
+
### Clone the Github repo
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
git clone https://github.com/trustgraph-ai/trustgraph trustgraph
|
|
155
|
+
cd trustgraph
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Docker compose files
|
|
159
|
+
|
|
160
|
+
There are 4 docker compose files to choose from depending on the LLM you
|
|
161
|
+
wish to use:
|
|
162
|
+
|
|
163
|
+
- `docker-compose-azure.yaml`. This is for a serverless AI endpoint
|
|
164
|
+
hosted on Azure. Set `AZURE_TOKEN` to the secret token and
|
|
165
|
+
`AZURE_ENDPOINT` to the endpoint address.
|
|
166
|
+
- `docker-compose-claude.yaml`. This is for using Anthropic Claude LLM.
|
|
167
|
+
Set `CLAUDE_KEY` to the API key.
|
|
168
|
+
- `docker-compose-ollama.yaml`. This is for a local LLM - gemma2 hosted
|
|
169
|
+
using Ollama. Set `OLLAMA_HOST` to the host running Ollama (e.g.
|
|
170
|
+
`localhost` to talk to a locally hosted Ollama.
|
|
171
|
+
- `docker-compose-vertexai.yaml`. This is for using Google Cloud VertexAI.
|
|
172
|
+
You need a private.json authentication file for your Google Cloud.
|
|
173
|
+
Should be at path `vertexai/private.json`.
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
#### docker-compose-azure.yaml
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
export AZURE_ENDPOINT=https://ENDPOINT.HOST.GOES.HERE/
|
|
180
|
+
export AZURE_TOKEN=TOKEN-GOES-HERE
|
|
181
|
+
docker-compose -f docker-compose-azure.yaml up -d
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### docker-compose-claude.yaml
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
export CLAUDE_KEY=TOKEN-GOES-HERE
|
|
188
|
+
docker-compose -f docker-compose-claude.yaml up -d
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
#### docker-compose-ollama.yaml
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
export OLLAMA_HOST=localhost # Set to hostname of Ollama host
|
|
195
|
+
docker-compose -f docker-compose-ollama.yaml up -d
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
#### docker-compose-azure.yaml
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
mkdir -p vertexai
|
|
202
|
+
cp {whatever} vertexai/private.json
|
|
203
|
+
docker-compose -f docker-compose-vertexai.yaml up -d
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
On Linux if running SELinux you may need to set the permissions on the
|
|
207
|
+
VertexAI directory so that the key file can be mounted on a docker
|
|
208
|
+
container...
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
chcon -Rt svirt_sandbox_file_t vertexai/
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Check things are running
|
|
215
|
+
|
|
216
|
+
Check that you have a set of containers running...
|
|
217
|
+
|
|
218
|
+
```
|
|
219
|
+
docker ps
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
You might want to look at containers which are down to see if any
|
|
223
|
+
have exited unexpectedly - look at the STATUS field.
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
docker ps -a
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Wait
|
|
230
|
+
|
|
231
|
+
Before proceeding, you should leave enough time for the system to
|
|
232
|
+
settle into a working state. On my Macbook, it takes about 30 seconds
|
|
233
|
+
for Pulsar to start, before which, nothing works.
|
|
234
|
+
|
|
235
|
+
The system uses Cassandra for a Graph store, takes around 60-70 seconds
|
|
236
|
+
to achieve a working state. For your first go, I would advise just letting
|
|
237
|
+
everything settle for a couple of minutes before doing anything else, so
|
|
238
|
+
that if there are errors you know it's not just that the system is starting
|
|
239
|
+
up.
|
|
240
|
+
|
|
241
|
+
### Install requirements
|
|
242
|
+
|
|
243
|
+
```
|
|
244
|
+
python3 -m venv env
|
|
245
|
+
. env/bin/activate
|
|
246
|
+
pip3 install pulsar-client
|
|
247
|
+
pip3 install cassandra-driver
|
|
248
|
+
export PYTHON_PATH=.
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Load some data
|
|
252
|
+
|
|
253
|
+
Create a sources directory and get a test file...
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
mkdir sources
|
|
257
|
+
curl -o sources/Challenger-Report-Vol1.pdf https://sma.nasa.gov/SignificantIncidents/assets/rogers_commission_report.pdf
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Then load the file...
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
scripts/loader -f sources/Challenger-Report-Vol1.pdf
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
You get some output on the screen, if nothing looks like errors (has the
|
|
267
|
+
ERROR tag) you should be good.
|
|
268
|
+
|
|
269
|
+
### Check logs
|
|
270
|
+
|
|
271
|
+
Look at the PDF decoder...
|
|
272
|
+
|
|
273
|
+
```
|
|
274
|
+
docker logs trustgraph-pdf-decoder-1
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
which should contain some text like...
|
|
278
|
+
```
|
|
279
|
+
Decoding 1f7b7055...
|
|
280
|
+
Done.
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Look at the chunker output...
|
|
284
|
+
|
|
285
|
+
```
|
|
286
|
+
docker logs trustgraph-chunker-1
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
You will see similar output, except many entries instead of 1.
|
|
290
|
+
|
|
291
|
+
Look at the vectorizer output...
|
|
292
|
+
|
|
293
|
+
```
|
|
294
|
+
docker logs trustgraph-vectorize-1
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
You will see similar output, except many entries instead of 1.
|
|
298
|
+
|
|
299
|
+
Look at the LLM output...
|
|
300
|
+
|
|
301
|
+
```
|
|
302
|
+
docker logs trustgraph-llm-1
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
You will see output like this...
|
|
306
|
+
```
|
|
307
|
+
Handling prompt fa1b98ae-70ef-452b-bcbe-21a867c5e8e2...
|
|
308
|
+
Send response...
|
|
309
|
+
Done.
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
Two more log outputs to look at...
|
|
313
|
+
|
|
314
|
+
```
|
|
315
|
+
docker logs trustgraph-kg-extract-definitions-1
|
|
316
|
+
docker logs trustgraph-kg-extract-relationships-1
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Definitions output similar to this should be visible
|
|
320
|
+
|
|
321
|
+
```
|
|
322
|
+
Indexing 1f7b7055-p11-c1...
|
|
323
|
+
[
|
|
324
|
+
{
|
|
325
|
+
"entity": "Orbiter",
|
|
326
|
+
"definition": "A spacecraft designed for spaceflight."
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"entity": "flight deck",
|
|
330
|
+
"definition": "The top level of the crew compartment, typically where flight controls are located."
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
"entity": "middeck",
|
|
334
|
+
"definition": "The lower level of the crew compartment, used for sleeping, working, and storing equipment."
|
|
335
|
+
}
|
|
336
|
+
]
|
|
337
|
+
Done.
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
and Relationships output...
|
|
341
|
+
|
|
342
|
+
```
|
|
343
|
+
Indexing 1f7b7055-p11-c3...
|
|
344
|
+
[
|
|
345
|
+
{
|
|
346
|
+
"subject": "Space Shuttle",
|
|
347
|
+
"predicate": "carry",
|
|
348
|
+
"object": "16 tons of cargo",
|
|
349
|
+
"object-entity": false
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
"subject": "friction",
|
|
353
|
+
"predicate": "generated by",
|
|
354
|
+
"object": "atmosphere",
|
|
355
|
+
"object-entity": true
|
|
356
|
+
}
|
|
357
|
+
]
|
|
358
|
+
Done.
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Check graph is loading
|
|
362
|
+
|
|
363
|
+
```
|
|
364
|
+
scripts/graph-show
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
You should see some output along the lines of a load of lines like this...
|
|
368
|
+
|
|
369
|
+
```
|
|
370
|
+
http://trustgraph.ai/e/enterprise http://trustgraph.ai/e/was-carried to altitude and released for a gliding approach and landing at the Mojave Desert test center
|
|
371
|
+
http://trustgraph.ai/e/enterprise http://www.w3.org/2000/01/rdf-schema#label Enterprise
|
|
372
|
+
http://trustgraph.ai/e/enterprise http://www.w3.org/2004/02/skos/core#definition A prototype space shuttle orbiter used for atmospheric flight testing.
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
Any output at all is a good sign - indicates the graph is loading.
|
|
376
|
+
|
|
377
|
+
### Query time
|
|
378
|
+
|
|
379
|
+
With the graph loading, you should be able to see the number of graph edges
|
|
380
|
+
loaded...
|
|
381
|
+
```
|
|
382
|
+
scripts/graph-show | wc -l
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
You need a good few hundred edges to be loaded for the query to work on that
|
|
386
|
+
particular document, because it's the point where the indexer has passed
|
|
387
|
+
the mundane intro parts of the document and got into the interesting
|
|
388
|
+
parts.
|
|
389
|
+
|
|
390
|
+
```
|
|
391
|
+
tests/graph/rag
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
You should give the command at least a minute to run before being
|
|
395
|
+
concerned. The output should look like this...
|
|
396
|
+
|
|
397
|
+
```
|
|
398
|
+
Here are 20 facts from the provided knowledge graph about the Space Shuttle disaster:
|
|
399
|
+
|
|
400
|
+
1. **Space Shuttle Challenger was a Space Shuttle spacecraft.**
|
|
401
|
+
2. **The third Spacelab mission was carried by Orbiter Challenger.**
|
|
402
|
+
3. **Francis R. Scobee was the Commander of the Challenger crew.**
|
|
403
|
+
4. **Earth-to-orbit systems are designed to transport payloads and humans from Earth's surface into orbit.**
|
|
404
|
+
5. **The Space Shuttle program involved the Space Shuttle.**
|
|
405
|
+
6. **Orbiter Challenger flew on mission 41-B.**
|
|
406
|
+
7. **Orbiter Challenger was used on STS-7 and STS-8 missions.**
|
|
407
|
+
8. **Columbia completed the orbital test.**
|
|
408
|
+
9. **The Space Shuttle flew 24 successful missions.**
|
|
409
|
+
10. **One possibility for the Space Shuttle was a winged but unmanned recoverable liquid-fuel vehicle based on the Saturn 5 rocket.**
|
|
410
|
+
11. **A Commission was established to investigate the space shuttle Challenger accident.**
|
|
411
|
+
12. **Judit h Arlene Resnik was Mission Specialist Two.**
|
|
412
|
+
13. **Mission 51-L was originally scheduled for December 1985 but was delayed until January 1986.**
|
|
413
|
+
14. **The Corporation's Space Transportation Systems Division was responsible for the design and development of the Space Shuttle Orbiter.**
|
|
414
|
+
15. **Michael John Smith was the Pilot of the Challenger crew.**
|
|
415
|
+
16. **The Space Shuttle is composed of two recoverable Solid Rocket Boosters.**
|
|
416
|
+
17. **The Space Shuttle provides for the broadest possible spectrum of civil/military missions.**
|
|
417
|
+
18. **Mission 51-L consisted of placing one satellite in orbit, deploying and retrieving Spartan, and conducting six experiments.**
|
|
418
|
+
19. **The Space Shuttle became the focus of NASA's near-term future.**
|
|
419
|
+
20. **The Commission focused its attention on safety aspects of future flights.**
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
If it looks like something isn't working, try following the graph-rag
|
|
423
|
+
logs:
|
|
424
|
+
|
|
425
|
+
```
|
|
426
|
+
docker logs -f trustgraph-graph-rag-1
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
If you get an answer to your query, Graph RAG is working!
|
|
430
|
+
|
|
431
|
+
If you want to try different queries try modifying the
|
|
432
|
+
script you ran at `tests/test-graph-rag`.
|
|
433
|
+
|
|
434
|
+
### Clearing everything down
|
|
435
|
+
|
|
436
|
+
```
|
|
437
|
+
docker-compose -f docker-compose-ollama.yaml down
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
You should also clean out unwanted volumes...
|
|
441
|
+
|
|
442
|
+
```
|
|
443
|
+
docker volume ls
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
And delete anything you don't need...
|
|
447
|
+
|
|
448
|
+
```
|
|
449
|
+
docker volume rm -f <id>
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
If you want to experiment with your own data set, it would be best
|
|
453
|
+
to clear down everything created so far and start from scratch.
|
|
454
|
+
|