trustgraph-base 0.13.1__tar.gz → 0.14.0__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.
Files changed (49) hide show
  1. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/PKG-INFO +2 -2
  2. trustgraph-base-0.14.0/trustgraph/base_version.py +1 -0
  3. trustgraph-base-0.14.0/trustgraph/clients/prompt_client.py +172 -0
  4. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/schema/prompt.py +12 -11
  5. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph_base.egg-info/PKG-INFO +2 -2
  6. trustgraph-base-0.13.1/trustgraph/base_version.py +0 -1
  7. trustgraph-base-0.13.1/trustgraph/clients/prompt_client.py +0 -100
  8. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/README.md +0 -0
  9. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/setup.cfg +0 -0
  10. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/setup.py +0 -0
  11. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/base/__init__.py +0 -0
  12. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/base/base_processor.py +0 -0
  13. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/base/consumer.py +0 -0
  14. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/base/consumer_producer.py +0 -0
  15. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/base/producer.py +0 -0
  16. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/clients/__init__.py +0 -0
  17. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/clients/base.py +0 -0
  18. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/clients/document_embeddings_client.py +0 -0
  19. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/clients/document_rag_client.py +0 -0
  20. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/clients/embeddings_client.py +0 -0
  21. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/clients/graph_embeddings_client.py +0 -0
  22. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/clients/graph_rag_client.py +0 -0
  23. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/clients/llm_client.py +0 -0
  24. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/clients/triples_query_client.py +0 -0
  25. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/exceptions.py +0 -0
  26. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/knowledge/__init__.py +0 -0
  27. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/knowledge/defs.py +0 -0
  28. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/knowledge/document.py +0 -0
  29. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/knowledge/identifier.py +0 -0
  30. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/knowledge/organization.py +0 -0
  31. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/knowledge/publication.py +0 -0
  32. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/log_level.py +0 -0
  33. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/objects/__init__.py +0 -0
  34. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/objects/field.py +0 -0
  35. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/objects/object.py +0 -0
  36. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/rdf.py +0 -0
  37. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/schema/__init__.py +0 -0
  38. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/schema/documents.py +0 -0
  39. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/schema/graph.py +0 -0
  40. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/schema/metadata.py +0 -0
  41. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/schema/models.py +0 -0
  42. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/schema/object.py +0 -0
  43. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/schema/retrieval.py +0 -0
  44. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/schema/topic.py +0 -0
  45. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph/schema/types.py +0 -0
  46. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph_base.egg-info/SOURCES.txt +0 -0
  47. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph_base.egg-info/dependency_links.txt +0 -0
  48. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph_base.egg-info/requires.txt +0 -0
  49. {trustgraph-base-0.13.1 → trustgraph-base-0.14.0}/trustgraph_base.egg-info/top_level.txt +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: trustgraph-base
3
- Version: 0.13.1
3
+ Version: 0.14.0
4
4
  Summary: TrustGraph provides a means to run a pipeline of flexible AI processing components in a flexible means to achieve a processing pipeline.
5
5
  Home-page: https://github.com/trustgraph-ai/trustgraph
6
6
  Author: trustgraph.ai
7
7
  Author-email: security@trustgraph.ai
8
8
  License: UNKNOWN
9
- Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.13.1.tar.gz
9
+ Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.14.0.tar.gz
10
10
  Platform: UNKNOWN
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
@@ -0,0 +1 @@
1
+ __version__ = "0.14.0"
@@ -0,0 +1,172 @@
1
+
2
+ import _pulsar
3
+ import json
4
+ import dataclasses
5
+
6
+ from .. schema import PromptRequest, PromptResponse
7
+ from .. schema import prompt_request_queue
8
+ from .. schema import prompt_response_queue
9
+ from . base import BaseClient
10
+
11
+ # Ugly
12
+ ERROR=_pulsar.LoggerLevel.Error
13
+ WARN=_pulsar.LoggerLevel.Warn
14
+ INFO=_pulsar.LoggerLevel.Info
15
+ DEBUG=_pulsar.LoggerLevel.Debug
16
+
17
+ @dataclasses.dataclass
18
+ class Definition:
19
+ name: str
20
+ definition: str
21
+
22
+ @dataclasses.dataclass
23
+ class Relationship:
24
+ s: str
25
+ p: str
26
+ o: str
27
+ o_entity: str
28
+
29
+ @dataclasses.dataclass
30
+ class Topic:
31
+ topic: str
32
+ definition: str
33
+
34
+ class PromptClient(BaseClient):
35
+
36
+ def __init__(
37
+ self, log_level=ERROR,
38
+ subscriber=None,
39
+ input_queue=None,
40
+ output_queue=None,
41
+ pulsar_host="pulsar://pulsar:6650",
42
+ ):
43
+
44
+ if input_queue == None:
45
+ input_queue = prompt_request_queue
46
+
47
+ if output_queue == None:
48
+ output_queue = prompt_response_queue
49
+
50
+ super(PromptClient, self).__init__(
51
+ log_level=log_level,
52
+ subscriber=subscriber,
53
+ input_queue=input_queue,
54
+ output_queue=output_queue,
55
+ pulsar_host=pulsar_host,
56
+ input_schema=PromptRequest,
57
+ output_schema=PromptResponse,
58
+ )
59
+
60
+ def request(self, id, terms, timeout=300):
61
+
62
+ resp = self.call(
63
+ id=id,
64
+ terms={
65
+ k: json.dumps(v)
66
+ for k, v in terms.items()
67
+ },
68
+ timeout=timeout
69
+ )
70
+
71
+ if resp.text: return resp.text
72
+
73
+ return json.loads(resp.object)
74
+
75
+ def request_definitions(self, chunk, timeout=300):
76
+
77
+ defs = self.request(
78
+ id="extract-definitions",
79
+ terms={
80
+ "text": chunk
81
+ },
82
+ timeout=timeout
83
+ )
84
+
85
+ return [
86
+ Definition(name=d["entity"], definition=d["definition"])
87
+ for d in defs
88
+ ]
89
+
90
+ def request_relationships(self, chunk, timeout=300):
91
+
92
+ rels = self.request(
93
+ id="extract-relationships",
94
+ terms={
95
+ "text": chunk
96
+ },
97
+ timeout=timeout
98
+ )
99
+
100
+ return [
101
+ Relationship(
102
+ s=d["subject"],
103
+ p=d["predicate"],
104
+ o=d["object"],
105
+ o_entity=d["object-entity"]
106
+ )
107
+ for d in rels
108
+ ]
109
+
110
+ def request_topics(self, chunk, timeout=300):
111
+
112
+ topics = self.request(
113
+ id="extract-topics",
114
+ terms={
115
+ "text": chunk
116
+ },
117
+ timeout=timeout
118
+ )
119
+
120
+ return [
121
+ Topic(topic=d["topic"], definition=d["definition"])
122
+ for d in topics
123
+ ]
124
+
125
+ def request_rows(self, schema, chunk, timeout=300):
126
+
127
+ return self.request(
128
+ id="extract-rows",
129
+ terms={
130
+ "chunk": chunk,
131
+ "row-schema": {
132
+ "name": schema.name,
133
+ "description": schema.description,
134
+ "fields": [
135
+ {
136
+ "name": f.name, "type": str(f.type),
137
+ "size": f.size, "primary": f.primary,
138
+ "description": f.description,
139
+ }
140
+ for f in schema.fields
141
+ ]
142
+ }
143
+ },
144
+ timeout=timeout
145
+ )
146
+
147
+ def request_kg_prompt(self, query, kg, timeout=300):
148
+
149
+ return self.request(
150
+ id="kg-prompt",
151
+ terms={
152
+ "query": query,
153
+ "knowledge": [
154
+ { "s": v[0], "p": v[1], "o": v[2] }
155
+ for v in kg
156
+ ]
157
+ },
158
+ timeout=timeout
159
+ )
160
+
161
+ def request_document_prompt(self, query, documents, timeout=300):
162
+
163
+ return self.request(
164
+ id="document-prompt",
165
+ terms={
166
+ "query": query,
167
+ "documents": documents,
168
+ },
169
+ timeout=timeout
170
+ )
171
+
172
+
@@ -39,20 +39,21 @@ class Fact(Record):
39
39
  # schema, chunk -> rows
40
40
 
41
41
  class PromptRequest(Record):
42
- kind = String()
43
- chunk = String()
44
- query = String()
45
- kg = Array(Fact())
46
- documents = Array(Bytes())
47
- row_schema = RowSchema()
42
+ id = String()
43
+
44
+ # JSON encoded values
45
+ terms = Map(String())
48
46
 
49
47
  class PromptResponse(Record):
48
+
49
+ # Error case
50
50
  error = Error()
51
- answer = String()
52
- definitions = Array(Definition())
53
- topics = Array(Topic())
54
- relationships = Array(Relationship())
55
- rows = Array(Map(String()))
51
+
52
+ # Just plain text
53
+ text = String()
54
+
55
+ # JSON encoded
56
+ object = String()
56
57
 
57
58
  prompt_request_queue = topic(
58
59
  'prompt', kind='non-persistent', namespace='request'
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: trustgraph-base
3
- Version: 0.13.1
3
+ Version: 0.14.0
4
4
  Summary: TrustGraph provides a means to run a pipeline of flexible AI processing components in a flexible means to achieve a processing pipeline.
5
5
  Home-page: https://github.com/trustgraph-ai/trustgraph
6
6
  Author: trustgraph.ai
7
7
  Author-email: security@trustgraph.ai
8
8
  License: UNKNOWN
9
- Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.13.1.tar.gz
9
+ Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.14.0.tar.gz
10
10
  Platform: UNKNOWN
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
@@ -1 +0,0 @@
1
- __version__ = "0.13.1"
@@ -1,100 +0,0 @@
1
-
2
- import _pulsar
3
-
4
- from .. schema import PromptRequest, PromptResponse, Fact, RowSchema, Field
5
- from .. schema import prompt_request_queue
6
- from .. schema import prompt_response_queue
7
- from . base import BaseClient
8
-
9
- # Ugly
10
- ERROR=_pulsar.LoggerLevel.Error
11
- WARN=_pulsar.LoggerLevel.Warn
12
- INFO=_pulsar.LoggerLevel.Info
13
- DEBUG=_pulsar.LoggerLevel.Debug
14
-
15
- class PromptClient(BaseClient):
16
-
17
- def __init__(
18
- self, log_level=ERROR,
19
- subscriber=None,
20
- input_queue=None,
21
- output_queue=None,
22
- pulsar_host="pulsar://pulsar:6650",
23
- ):
24
-
25
- if input_queue == None:
26
- input_queue = prompt_request_queue
27
-
28
- if output_queue == None:
29
- output_queue = prompt_response_queue
30
-
31
- super(PromptClient, self).__init__(
32
- log_level=log_level,
33
- subscriber=subscriber,
34
- input_queue=input_queue,
35
- output_queue=output_queue,
36
- pulsar_host=pulsar_host,
37
- input_schema=PromptRequest,
38
- output_schema=PromptResponse,
39
- )
40
-
41
- def request_definitions(self, chunk, timeout=300):
42
-
43
- return self.call(
44
- kind="extract-definitions", chunk=chunk,
45
- timeout=timeout
46
- ).definitions
47
-
48
- def request_topics(self, chunk, timeout=300):
49
-
50
- return self.call(
51
- kind="extract-topics", chunk=chunk,
52
- timeout=timeout
53
- ).topics
54
-
55
- def request_relationships(self, chunk, timeout=300):
56
-
57
- return self.call(
58
- kind="extract-relationships", chunk=chunk,
59
- timeout=timeout
60
- ).relationships
61
-
62
- def request_rows(self, schema, chunk, timeout=300):
63
-
64
- return self.call(
65
- kind="extract-rows", chunk=chunk,
66
- row_schema=RowSchema(
67
- name=schema.name,
68
- description=schema.description,
69
- fields=[
70
- Field(
71
- name=f.name, type=str(f.type), size=f.size,
72
- primary=f.primary, description=f.description,
73
- )
74
- for f in schema.fields
75
- ]
76
- ),
77
- timeout=timeout
78
- ).rows
79
-
80
- def request_kg_prompt(self, query, kg, timeout=300):
81
-
82
- return self.call(
83
- kind="kg-prompt",
84
- query=query,
85
- kg=[
86
- Fact(s=v[0], p=v[1], o=v[2])
87
- for v in kg
88
- ],
89
- timeout=timeout
90
- ).answer
91
-
92
- def request_document_prompt(self, query, documents, timeout=300):
93
-
94
- return self.call(
95
- kind="document-prompt",
96
- query=query,
97
- documents=documents,
98
- timeout=timeout
99
- ).answer
100
-