trustgraph-base 0.21.19__tar.gz → 0.22.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 (58) hide show
  1. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/PKG-INFO +2 -2
  2. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/api/api.py +30 -0
  3. trustgraph-base-0.22.0/trustgraph/base_version.py +1 -0
  4. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/clients/base.py +8 -5
  5. trustgraph-base-0.22.0/trustgraph/clients/config_client.py +161 -0
  6. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/schema/__init__.py +1 -0
  7. trustgraph-base-0.22.0/trustgraph/schema/config.py +71 -0
  8. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph_base.egg-info/PKG-INFO +2 -2
  9. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph_base.egg-info/SOURCES.txt +2 -0
  10. trustgraph-base-0.21.19/trustgraph/base_version.py +0 -1
  11. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/README.md +0 -0
  12. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/setup.cfg +0 -0
  13. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/setup.py +0 -0
  14. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/api/__init__.py +0 -0
  15. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/base/__init__.py +0 -0
  16. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/base/base_processor.py +0 -0
  17. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/base/consumer.py +0 -0
  18. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/base/consumer_producer.py +0 -0
  19. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/base/producer.py +0 -0
  20. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/base/publisher.py +0 -0
  21. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/base/subscriber.py +0 -0
  22. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/clients/__init__.py +0 -0
  23. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/clients/agent_client.py +0 -0
  24. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/clients/document_embeddings_client.py +0 -0
  25. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/clients/document_rag_client.py +0 -0
  26. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/clients/embeddings_client.py +0 -0
  27. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/clients/graph_embeddings_client.py +0 -0
  28. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/clients/graph_rag_client.py +0 -0
  29. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/clients/llm_client.py +0 -0
  30. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/clients/prompt_client.py +0 -0
  31. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/clients/triples_query_client.py +0 -0
  32. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/exceptions.py +0 -0
  33. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/knowledge/__init__.py +0 -0
  34. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/knowledge/defs.py +0 -0
  35. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/knowledge/document.py +0 -0
  36. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/knowledge/identifier.py +0 -0
  37. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/knowledge/organization.py +0 -0
  38. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/knowledge/publication.py +0 -0
  39. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/log_level.py +0 -0
  40. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/objects/__init__.py +0 -0
  41. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/objects/field.py +0 -0
  42. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/objects/object.py +0 -0
  43. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/rdf.py +0 -0
  44. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/schema/agent.py +0 -0
  45. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/schema/documents.py +0 -0
  46. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/schema/graph.py +0 -0
  47. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/schema/library.py +0 -0
  48. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/schema/lookup.py +0 -0
  49. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/schema/metadata.py +0 -0
  50. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/schema/models.py +0 -0
  51. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/schema/object.py +0 -0
  52. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/schema/prompt.py +0 -0
  53. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/schema/retrieval.py +0 -0
  54. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/schema/topic.py +0 -0
  55. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph/schema/types.py +0 -0
  56. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph_base.egg-info/dependency_links.txt +0 -0
  57. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph_base.egg-info/requires.txt +0 -0
  58. {trustgraph-base-0.21.19 → trustgraph-base-0.22.0}/trustgraph_base.egg-info/top_level.txt +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: trustgraph-base
3
- Version: 0.21.19
3
+ Version: 0.22.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
- Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.21.19.tar.gz
6
+ Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.22.0.tar.gz
7
7
  Author: trustgraph.ai
8
8
  Author-email: security@trustgraph.ai
9
9
  Classifier: Programming Language :: Python :: 3
@@ -382,3 +382,33 @@ class Api:
382
382
  if resp.status_code != 200:
383
383
  raise ProtocolException(f"Status code {resp.status_code}")
384
384
 
385
+ def get_config(self):
386
+
387
+ # The input consists of system and prompt strings
388
+ input = {
389
+ "operation": "config"
390
+ }
391
+
392
+ url = f"{self.url}config"
393
+
394
+ # Invoke the API, input is passed as JSON
395
+ resp = requests.post(url, json=input)
396
+
397
+ # Should be a 200 status code
398
+ if resp.status_code != 200:
399
+ raise ProtocolException(f"Status code {resp.status_code}")
400
+
401
+ try:
402
+ # Parse the response as JSON
403
+ object = resp.json()
404
+ except:
405
+ raise ProtocolException(f"Expected JSON response")
406
+
407
+ self.check_error(resp)
408
+
409
+ try:
410
+ return object["config"], object["version"]
411
+ except:
412
+ raise ProtocolException(f"Response not formatted correctly")
413
+
414
+
@@ -0,0 +1 @@
1
+ __version__ = "0.22.0"
@@ -28,6 +28,7 @@ class BaseClient:
28
28
  output_schema=None,
29
29
  pulsar_host="pulsar://pulsar:6650",
30
30
  pulsar_api_key=None,
31
+ listener=None,
31
32
  ):
32
33
 
33
34
  if input_queue == None: raise RuntimeError("Need input_queue")
@@ -41,14 +42,16 @@ class BaseClient:
41
42
  if pulsar_api_key:
42
43
  auth = pulsar.AuthenticationToken(pulsar_api_key)
43
44
  self.client = pulsar.Client(
44
- pulsar_host,
45
- logger=pulsar.ConsoleLogger(log_level),
46
- authentication=auth,
45
+ pulsar_host,
46
+ logger=pulsar.ConsoleLogger(log_level),
47
+ authentication=auth,
48
+ listener=listener,
47
49
  )
48
50
  else:
49
51
  self.client = pulsar.Client(
50
- pulsar_host,
51
- logger=pulsar.ConsoleLogger(log_level)
52
+ pulsar_host,
53
+ logger=pulsar.ConsoleLogger(log_level),
54
+ listener_name=listener,
52
55
  )
53
56
 
54
57
  self.producer = self.client.create_producer(
@@ -0,0 +1,161 @@
1
+
2
+ import _pulsar
3
+ import json
4
+ import dataclasses
5
+
6
+ from .. schema import ConfigRequest, ConfigResponse, ConfigKey, ConfigValue
7
+ from .. schema import config_request_queue
8
+ from .. schema import config_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
+ name: str
32
+ definition: str
33
+
34
+ class ConfigClient(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
+ listener=None,
43
+ pulsar_api_key=None,
44
+ ):
45
+
46
+ if input_queue == None:
47
+ input_queue = config_request_queue
48
+
49
+ if output_queue == None:
50
+ output_queue = config_response_queue
51
+
52
+ super(ConfigClient, self).__init__(
53
+ log_level=log_level,
54
+ subscriber=subscriber,
55
+ input_queue=input_queue,
56
+ output_queue=output_queue,
57
+ pulsar_host=pulsar_host,
58
+ pulsar_api_key=pulsar_api_key,
59
+ input_schema=ConfigRequest,
60
+ output_schema=ConfigResponse,
61
+ listener=listener,
62
+ )
63
+
64
+ def request_get(self, keys, timeout=300):
65
+
66
+ resp = self.call(
67
+ id=id,
68
+ operation="get",
69
+ keys=[
70
+ ConfigKey(
71
+ type = k["type"],
72
+ key = k["key"]
73
+ )
74
+ for k in keys
75
+ ],
76
+ timeout=timeout
77
+ )
78
+
79
+ return [
80
+ {
81
+ "type": v.type,
82
+ "key": v.key,
83
+ "value": v.value
84
+ }
85
+ for v in resp.values
86
+ ]
87
+
88
+ def request_list(self, type, timeout=300):
89
+
90
+ resp = self.call(
91
+ id=id,
92
+ operation="list",
93
+ type=type,
94
+ timeout=timeout
95
+ )
96
+
97
+ return resp.directory
98
+
99
+ def request_getvalues(self, type, timeout=300):
100
+
101
+ resp = self.call(
102
+ id=id,
103
+ operation="getvalues",
104
+ type=type,
105
+ timeout=timeout
106
+ )
107
+
108
+ return [
109
+ {
110
+ "type": v.type,
111
+ "key": v.key,
112
+ "value": v.value
113
+ }
114
+ for v in resp.values
115
+ ]
116
+
117
+ def request_delete(self, keys, timeout=300):
118
+
119
+ resp = self.call(
120
+ id=id,
121
+ operation="delete",
122
+ keys=[
123
+ ConfigKey(
124
+ type = k["type"],
125
+ key = k["key"]
126
+ )
127
+ for k in keys
128
+ ],
129
+ timeout=timeout
130
+ )
131
+
132
+ return None
133
+
134
+ def request_put(self, value, timeout=300):
135
+
136
+ resp = self.call(
137
+ id=id,
138
+ operation="put",
139
+ values=[
140
+ ConfigValue(
141
+ type = k["type"],
142
+ key = k["key"],
143
+ value = k["value"]
144
+ )
145
+ for k in keys
146
+ ],
147
+ timeout=timeout
148
+ )
149
+
150
+ return None
151
+
152
+ def request_config(self, timeout=300):
153
+
154
+ resp = self.call(
155
+ id=id,
156
+ operation="config",
157
+ timeout=timeout
158
+ )
159
+
160
+ return resp.config
161
+
@@ -11,5 +11,6 @@ from . metadata import *
11
11
  from . agent import *
12
12
  from . lookup import *
13
13
  from . library import *
14
+ from . config import *
14
15
 
15
16
 
@@ -0,0 +1,71 @@
1
+
2
+ from pulsar.schema import Record, Bytes, String, Boolean, Array, Map, Integer
3
+
4
+ from . topic import topic
5
+ from . types import Error, RowSchema
6
+
7
+ ############################################################################
8
+
9
+ # Config service:
10
+ # get(keys) -> (version, values)
11
+ # list(type) -> (version, values)
12
+ # getvalues(type) -> (version, values)
13
+ # put(values) -> ()
14
+ # delete(keys) -> ()
15
+ # config() -> (version, config)
16
+ class ConfigKey(Record):
17
+ type = String()
18
+ key = String()
19
+
20
+ class ConfigValue(Record):
21
+ type = String()
22
+ key = String()
23
+ value = String()
24
+
25
+ # Prompt services, abstract the prompt generation
26
+ class ConfigRequest(Record):
27
+
28
+ operation = String() # get, list, getvalues, delete, put, config
29
+
30
+ # get, delete
31
+ keys = Array(ConfigKey())
32
+
33
+ # list, getvalues
34
+ type = String()
35
+
36
+ # put
37
+ values = Array(ConfigValue())
38
+
39
+ class ConfigResponse(Record):
40
+
41
+ # get, list, getvalues, config
42
+ version = Integer()
43
+
44
+ # get, getvalues
45
+ values = Array(ConfigValue())
46
+
47
+ # list
48
+ directory = Array(String())
49
+
50
+ # config
51
+ config = Map(Map(String()))
52
+
53
+ # Everything
54
+ error = Error()
55
+
56
+ class ConfigPush(Record):
57
+ version = Integer()
58
+ config = Map(Map(String()))
59
+
60
+ config_request_queue = topic(
61
+ 'config', kind='non-persistent', namespace='request'
62
+ )
63
+ config_response_queue = topic(
64
+ 'config', kind='non-persistent', namespace='response'
65
+ )
66
+ config_push_queue = topic(
67
+ 'config', kind='persistent', namespace='config'
68
+ )
69
+
70
+ ############################################################################
71
+
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: trustgraph-base
3
- Version: 0.21.19
3
+ Version: 0.22.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
- Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.21.19.tar.gz
6
+ Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.22.0.tar.gz
7
7
  Author: trustgraph.ai
8
8
  Author-email: security@trustgraph.ai
9
9
  Classifier: Programming Language :: Python :: 3
@@ -16,6 +16,7 @@ trustgraph/base/subscriber.py
16
16
  trustgraph/clients/__init__.py
17
17
  trustgraph/clients/agent_client.py
18
18
  trustgraph/clients/base.py
19
+ trustgraph/clients/config_client.py
19
20
  trustgraph/clients/document_embeddings_client.py
20
21
  trustgraph/clients/document_rag_client.py
21
22
  trustgraph/clients/embeddings_client.py
@@ -35,6 +36,7 @@ trustgraph/objects/field.py
35
36
  trustgraph/objects/object.py
36
37
  trustgraph/schema/__init__.py
37
38
  trustgraph/schema/agent.py
39
+ trustgraph/schema/config.py
38
40
  trustgraph/schema/documents.py
39
41
  trustgraph/schema/graph.py
40
42
  trustgraph/schema/library.py
@@ -1 +0,0 @@
1
- __version__ = "0.21.19"