trustgraph-base 1.1.5__tar.gz → 1.1.7__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 (113) hide show
  1. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/PKG-INFO +2 -2
  2. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/api/config.py +14 -1
  3. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/api/flow.py +27 -2
  4. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/__init__.py +2 -0
  5. trustgraph-base-1.1.7/trustgraph/base/tool_client.py +40 -0
  6. trustgraph-base-1.1.7/trustgraph/base/tool_service.py +121 -0
  7. trustgraph-base-1.1.7/trustgraph/base_version.py +1 -0
  8. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/messaging/__init__.py +7 -0
  9. trustgraph-base-1.1.7/trustgraph/messaging/translators/tool.py +51 -0
  10. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/schema/models.py +19 -0
  11. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph_base.egg-info/PKG-INFO +2 -2
  12. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph_base.egg-info/SOURCES.txt +3 -0
  13. trustgraph-base-1.1.5/trustgraph/base_version.py +0 -1
  14. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/README.md +0 -0
  15. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/setup.cfg +0 -0
  16. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/setup.py +0 -0
  17. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/api/__init__.py +0 -0
  18. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/api/api.py +0 -0
  19. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/api/exceptions.py +0 -0
  20. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/api/knowledge.py +0 -0
  21. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/api/library.py +0 -0
  22. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/api/types.py +0 -0
  23. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/agent_client.py +0 -0
  24. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/agent_service.py +0 -0
  25. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/async_processor.py +0 -0
  26. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/consumer.py +0 -0
  27. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/consumer_spec.py +0 -0
  28. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/document_embeddings_client.py +0 -0
  29. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/document_embeddings_query_service.py +0 -0
  30. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/document_embeddings_store_service.py +0 -0
  31. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/embeddings_client.py +0 -0
  32. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/embeddings_service.py +0 -0
  33. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/flow.py +0 -0
  34. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/flow_processor.py +0 -0
  35. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/graph_embeddings_client.py +0 -0
  36. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/graph_embeddings_query_service.py +0 -0
  37. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/graph_embeddings_store_service.py +0 -0
  38. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/graph_rag_client.py +0 -0
  39. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/llm_service.py +0 -0
  40. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/metrics.py +0 -0
  41. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/producer.py +0 -0
  42. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/producer_spec.py +0 -0
  43. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/prompt_client.py +0 -0
  44. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/publisher.py +0 -0
  45. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/pubsub.py +0 -0
  46. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/request_response_spec.py +0 -0
  47. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/setting_spec.py +0 -0
  48. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/spec.py +0 -0
  49. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/subscriber.py +0 -0
  50. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/subscriber_spec.py +0 -0
  51. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/text_completion_client.py +0 -0
  52. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/triples_client.py +0 -0
  53. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/triples_query_service.py +0 -0
  54. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/base/triples_store_service.py +0 -0
  55. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/clients/__init__.py +0 -0
  56. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/clients/agent_client.py +0 -0
  57. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/clients/base.py +0 -0
  58. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/clients/config_client.py +0 -0
  59. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/clients/document_embeddings_client.py +0 -0
  60. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/clients/document_rag_client.py +0 -0
  61. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/clients/embeddings_client.py +0 -0
  62. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/clients/graph_embeddings_client.py +0 -0
  63. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/clients/graph_rag_client.py +0 -0
  64. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/clients/llm_client.py +0 -0
  65. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/clients/prompt_client.py +0 -0
  66. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/clients/triples_query_client.py +0 -0
  67. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/exceptions.py +0 -0
  68. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/knowledge/__init__.py +0 -0
  69. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/knowledge/defs.py +0 -0
  70. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/knowledge/document.py +0 -0
  71. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/knowledge/identifier.py +0 -0
  72. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/knowledge/organization.py +0 -0
  73. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/knowledge/publication.py +0 -0
  74. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/log_level.py +0 -0
  75. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/messaging/registry.py +0 -0
  76. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/messaging/translators/__init__.py +0 -0
  77. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/messaging/translators/agent.py +0 -0
  78. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/messaging/translators/base.py +0 -0
  79. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/messaging/translators/config.py +0 -0
  80. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/messaging/translators/document_loading.py +0 -0
  81. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/messaging/translators/embeddings.py +0 -0
  82. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/messaging/translators/embeddings_query.py +0 -0
  83. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/messaging/translators/flow.py +0 -0
  84. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/messaging/translators/knowledge.py +0 -0
  85. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/messaging/translators/library.py +0 -0
  86. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/messaging/translators/metadata.py +0 -0
  87. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/messaging/translators/primitives.py +0 -0
  88. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/messaging/translators/prompt.py +0 -0
  89. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/messaging/translators/retrieval.py +0 -0
  90. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/messaging/translators/text_completion.py +0 -0
  91. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/messaging/translators/triples.py +0 -0
  92. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/objects/__init__.py +0 -0
  93. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/objects/field.py +0 -0
  94. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/objects/object.py +0 -0
  95. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/rdf.py +0 -0
  96. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/schema/__init__.py +0 -0
  97. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/schema/agent.py +0 -0
  98. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/schema/config.py +0 -0
  99. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/schema/documents.py +0 -0
  100. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/schema/flows.py +0 -0
  101. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/schema/graph.py +0 -0
  102. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/schema/knowledge.py +0 -0
  103. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/schema/library.py +0 -0
  104. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/schema/lookup.py +0 -0
  105. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/schema/metadata.py +0 -0
  106. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/schema/object.py +0 -0
  107. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/schema/prompt.py +0 -0
  108. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/schema/retrieval.py +0 -0
  109. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/schema/topic.py +0 -0
  110. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph/schema/types.py +0 -0
  111. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph_base.egg-info/dependency_links.txt +0 -0
  112. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/trustgraph_base.egg-info/requires.txt +0 -0
  113. {trustgraph-base-1.1.5 → trustgraph-base-1.1.7}/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: 1.1.5
3
+ Version: 1.1.7
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/v1.1.5.tar.gz
6
+ Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v1.1.7.tar.gz
7
7
  Author: trustgraph.ai
8
8
  Author-email: security@trustgraph.ai
9
9
  Classifier: Programming Language :: Python :: 3
@@ -49,6 +49,19 @@ class Config:
49
49
 
50
50
  self.request(input)
51
51
 
52
+ def delete(self, keys):
53
+
54
+ # The input consists of system and prompt strings
55
+ input = {
56
+ "operation": "delete",
57
+ "keys": [
58
+ { "type": v.type, "key": v.key }
59
+ for v in keys
60
+ ]
61
+ }
62
+
63
+ self.request(input)
64
+
52
65
  def list(self, type):
53
66
 
54
67
  # The input consists of system and prompt strings
@@ -67,7 +80,7 @@ class Config:
67
80
  "type": type,
68
81
  }
69
82
 
70
- object = self.request(input)["directory"]
83
+ object = self.request(input)
71
84
 
72
85
  try:
73
86
  return [
@@ -4,6 +4,7 @@ import base64
4
4
 
5
5
  from .. knowledge import hash, Uri, Literal
6
6
  from . types import Triple
7
+ from . exceptions import ProtocolException
7
8
 
8
9
  def to_value(x):
9
10
  if x["e"]: return Uri(x["v"])
@@ -197,7 +198,6 @@ class FlowInstance:
197
198
 
198
199
  def prompt(self, id, variables):
199
200
 
200
- # The input consists of system and prompt strings
201
201
  input = {
202
202
  "id": id,
203
203
  "variables": variables
@@ -221,12 +221,37 @@ class FlowInstance:
221
221
 
222
222
  raise ProtocolException("Response not formatted correctly")
223
223
 
224
+ def mcp_tool(self, name, parameters={}):
225
+
226
+ # The input consists of name and parameters
227
+ input = {
228
+ "name": name,
229
+ "parameters": parameters,
230
+ }
231
+
232
+ object = self.request(
233
+ "service/mcp-tool",
234
+ input
235
+ )
236
+
237
+ if "text" in object:
238
+ return object["text"]
239
+
240
+ if "object" in object:
241
+ try:
242
+ return object["object"]
243
+ except Exception as e:
244
+ raise ProtocolException(
245
+ "Returned object not well-formed JSON"
246
+ )
247
+
248
+ raise ProtocolException("Response not formatted correctly")
249
+
224
250
  def triples_query(
225
251
  self, s=None, p=None, o=None,
226
252
  user=None, collection=None, limit=10000
227
253
  ):
228
254
 
229
- # The input consists of system and prompt strings
230
255
  input = {
231
256
  "limit": limit
232
257
  }
@@ -28,4 +28,6 @@ from . triples_client import TriplesClientSpec
28
28
  from . document_embeddings_client import DocumentEmbeddingsClientSpec
29
29
  from . agent_service import AgentService
30
30
  from . graph_rag_client import GraphRagClientSpec
31
+ from . tool_service import ToolService
32
+ from . tool_client import ToolClientSpec
31
33
 
@@ -0,0 +1,40 @@
1
+
2
+ import json
3
+
4
+ from . request_response_spec import RequestResponse, RequestResponseSpec
5
+ from .. schema import ToolRequest, ToolResponse
6
+
7
+ class ToolClient(RequestResponse):
8
+
9
+ async def invoke(self, name, parameters={}, timeout=600):
10
+
11
+ if parameters is None:
12
+ parameters = {}
13
+
14
+ resp = await self.request(
15
+ ToolRequest(
16
+ name = name,
17
+ parameters = json.dumps(parameters),
18
+ ),
19
+ timeout=timeout
20
+ )
21
+
22
+ if resp.error:
23
+ raise RuntimeError(resp.error.message)
24
+
25
+ if resp.text: return resp.text
26
+
27
+ return json.loads(resp.object)
28
+
29
+ class ToolClientSpec(RequestResponseSpec):
30
+ def __init__(
31
+ self, request_name, response_name,
32
+ ):
33
+ super(ToolClientSpec, self).__init__(
34
+ request_name = request_name,
35
+ request_schema = ToolRequest,
36
+ response_name = response_name,
37
+ response_schema = ToolResponse,
38
+ impl = ToolClient,
39
+ )
40
+
@@ -0,0 +1,121 @@
1
+
2
+ """
3
+ Tool invocation base class
4
+ """
5
+
6
+ import json
7
+ from prometheus_client import Counter
8
+
9
+ from .. schema import ToolRequest, ToolResponse, Error
10
+ from .. exceptions import TooManyRequests
11
+ from .. base import FlowProcessor, ConsumerSpec, ProducerSpec
12
+
13
+ default_concurrency = 1
14
+
15
+ class ToolService(FlowProcessor):
16
+
17
+ def __init__(self, **params):
18
+
19
+ id = params.get("id")
20
+ concurrency = params.get("concurrency", 1)
21
+
22
+ super(ToolService, self).__init__(**params | {
23
+ "id": id,
24
+ "concurrency": concurrency,
25
+ })
26
+
27
+ self.register_specification(
28
+ ConsumerSpec(
29
+ name = "request",
30
+ schema = ToolRequest,
31
+ handler = self.on_request,
32
+ concurrency = concurrency,
33
+ )
34
+ )
35
+
36
+ self.register_specification(
37
+ ProducerSpec(
38
+ name = "response",
39
+ schema = ToolResponse
40
+ )
41
+ )
42
+
43
+ if not hasattr(__class__, "tool_invocation_metric"):
44
+ __class__.tool_invocation_metric = Counter(
45
+ 'tool_invocation_count', 'Tool invocation count',
46
+ ["id", "flow", "name"],
47
+ )
48
+
49
+ async def on_request(self, msg, consumer, flow):
50
+
51
+ try:
52
+
53
+ request = msg.value()
54
+
55
+ # Sender-produced ID
56
+
57
+ id = msg.properties()["id"]
58
+
59
+ response = await self.invoke_tool(
60
+ request.name,
61
+ json.loads(request.parameters) if request.parameters else {},
62
+ )
63
+
64
+ if isinstance(response, str):
65
+ await flow("response").send(
66
+ ToolResponse(
67
+ error=None,
68
+ text=response,
69
+ object=None,
70
+ ),
71
+ properties={"id": id}
72
+ )
73
+ else:
74
+ await flow("response").send(
75
+ ToolResponse(
76
+ error=None,
77
+ text=None,
78
+ object=json.dumps(response),
79
+ ),
80
+ properties={"id": id}
81
+ )
82
+
83
+ __class__.tool_invocation_metric.labels(
84
+ id = self.id, flow = flow.name, name = request.name,
85
+ ).inc()
86
+
87
+ except TooManyRequests as e:
88
+ raise e
89
+
90
+ except Exception as e:
91
+
92
+ # Apart from rate limits, treat all exceptions as unrecoverable
93
+
94
+ print(f"Exception: {e}")
95
+
96
+ print("Send error response...", flush=True)
97
+
98
+ await flow.producer["response"].send(
99
+ ToolResponse(
100
+ error=Error(
101
+ type = "tool-error",
102
+ message = str(e),
103
+ ),
104
+ text=None,
105
+ object=None,
106
+ ),
107
+ properties={"id": id}
108
+ )
109
+
110
+ @staticmethod
111
+ def add_args(parser):
112
+
113
+ parser.add_argument(
114
+ '-c', '--concurrency',
115
+ type=int,
116
+ default=default_concurrency,
117
+ help=f'Concurrent processing threads (default: {default_concurrency})'
118
+ )
119
+
120
+ FlowProcessor.add_args(parser)
121
+
@@ -0,0 +1 @@
1
+ __version__ = "1.1.7"
@@ -16,6 +16,7 @@ from .translators.document_loading import DocumentTranslator, TextDocumentTransl
16
16
  from .translators.config import ConfigRequestTranslator, ConfigResponseTranslator
17
17
  from .translators.flow import FlowRequestTranslator, FlowResponseTranslator
18
18
  from .translators.prompt import PromptRequestTranslator, PromptResponseTranslator
19
+ from .translators.tool import ToolRequestTranslator, ToolResponseTranslator
19
20
  from .translators.embeddings_query import (
20
21
  DocumentEmbeddingsRequestTranslator, DocumentEmbeddingsResponseTranslator,
21
22
  GraphEmbeddingsRequestTranslator, GraphEmbeddingsResponseTranslator
@@ -88,6 +89,12 @@ TranslatorRegistry.register_service(
88
89
  PromptResponseTranslator()
89
90
  )
90
91
 
92
+ TranslatorRegistry.register_service(
93
+ "tool",
94
+ ToolRequestTranslator(),
95
+ ToolResponseTranslator()
96
+ )
97
+
91
98
  TranslatorRegistry.register_service(
92
99
  "document-embeddings-query",
93
100
  DocumentEmbeddingsRequestTranslator(),
@@ -0,0 +1,51 @@
1
+ import json
2
+ from typing import Dict, Any, Tuple
3
+ from ...schema import ToolRequest, ToolResponse
4
+ from .base import MessageTranslator
5
+
6
+ class ToolRequestTranslator(MessageTranslator):
7
+ """Translator for ToolRequest schema objects"""
8
+
9
+ def to_pulsar(self, data: Dict[str, Any]) -> ToolRequest:
10
+ # Handle both "name" and "parameters" input keys
11
+ name = data.get("name", "")
12
+ if "parameters" in data:
13
+ parameters = json.dumps(data["parameters"])
14
+ else:
15
+ parameters = None
16
+
17
+ return ToolRequest(
18
+ name = name,
19
+ parameters = parameters,
20
+ )
21
+
22
+ def from_pulsar(self, obj: ToolRequest) -> Dict[str, Any]:
23
+ result = {}
24
+
25
+ if obj.name:
26
+ result["name"] = obj.name
27
+ if obj.parameters is not None:
28
+ result["parameters"] = json.loads(obj.parameters)
29
+
30
+ return result
31
+
32
+ class ToolResponseTranslator(MessageTranslator):
33
+ """Translator for ToolResponse schema objects"""
34
+
35
+ def to_pulsar(self, data: Dict[str, Any]) -> ToolResponse:
36
+ raise NotImplementedError("Response translation to Pulsar not typically needed")
37
+
38
+ def from_pulsar(self, obj: ToolResponse) -> Dict[str, Any]:
39
+
40
+ result = {}
41
+
42
+ if obj.text:
43
+ result["text"] = obj.text
44
+ if obj.object:
45
+ result["object"] = json.loads(obj.object)
46
+
47
+ return result
48
+
49
+ def from_response_with_completion(self, obj: ToolResponse) -> Tuple[Dict[str, Any], bool]:
50
+ """Returns (response_dict, is_final)"""
51
+ return self.from_pulsar(obj), True
@@ -30,3 +30,22 @@ class EmbeddingsResponse(Record):
30
30
  error = Error()
31
31
  vectors = Array(Array(Double()))
32
32
 
33
+ ############################################################################
34
+
35
+ # Tool request/response
36
+
37
+ class ToolRequest(Record):
38
+ name = String()
39
+
40
+ # Parameters are JSON encoded
41
+ parameters = String()
42
+
43
+ class ToolResponse(Record):
44
+ error = Error()
45
+
46
+ # Plain text aka "unstructured"
47
+ text = String()
48
+
49
+ # JSON-encoded object aka "structured"
50
+ object = String()
51
+
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: trustgraph-base
3
- Version: 1.1.5
3
+ Version: 1.1.7
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/v1.1.5.tar.gz
6
+ Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v1.1.7.tar.gz
7
7
  Author: trustgraph.ai
8
8
  Author-email: security@trustgraph.ai
9
9
  Classifier: Programming Language :: Python :: 3
@@ -42,6 +42,8 @@ trustgraph/base/spec.py
42
42
  trustgraph/base/subscriber.py
43
43
  trustgraph/base/subscriber_spec.py
44
44
  trustgraph/base/text_completion_client.py
45
+ trustgraph/base/tool_client.py
46
+ trustgraph/base/tool_service.py
45
47
  trustgraph/base/triples_client.py
46
48
  trustgraph/base/triples_query_service.py
47
49
  trustgraph/base/triples_store_service.py
@@ -80,6 +82,7 @@ trustgraph/messaging/translators/primitives.py
80
82
  trustgraph/messaging/translators/prompt.py
81
83
  trustgraph/messaging/translators/retrieval.py
82
84
  trustgraph/messaging/translators/text_completion.py
85
+ trustgraph/messaging/translators/tool.py
83
86
  trustgraph/messaging/translators/triples.py
84
87
  trustgraph/objects/__init__.py
85
88
  trustgraph/objects/field.py
@@ -1 +0,0 @@
1
- __version__ = "1.1.5"