trustgraph-base 0.14.16__tar.gz → 0.15.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 (50) hide show
  1. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/PKG-INFO +2 -2
  2. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/base/base_processor.py +3 -2
  3. trustgraph-base-0.15.0/trustgraph/base_version.py +1 -0
  4. trustgraph-base-0.15.0/trustgraph/clients/agent_client.py +64 -0
  5. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/clients/base.py +8 -0
  6. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/schema/__init__.py +1 -0
  7. trustgraph-base-0.15.0/trustgraph/schema/agent.py +37 -0
  8. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph_base.egg-info/PKG-INFO +2 -2
  9. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph_base.egg-info/SOURCES.txt +2 -0
  10. trustgraph-base-0.14.16/trustgraph/base_version.py +0 -1
  11. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/README.md +0 -0
  12. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/setup.cfg +0 -0
  13. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/setup.py +0 -0
  14. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/base/__init__.py +0 -0
  15. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/base/consumer.py +0 -0
  16. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/base/consumer_producer.py +0 -0
  17. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/base/producer.py +0 -0
  18. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/clients/__init__.py +0 -0
  19. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/clients/document_embeddings_client.py +0 -0
  20. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/clients/document_rag_client.py +0 -0
  21. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/clients/embeddings_client.py +0 -0
  22. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/clients/graph_embeddings_client.py +0 -0
  23. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/clients/graph_rag_client.py +0 -0
  24. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/clients/llm_client.py +0 -0
  25. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/clients/prompt_client.py +0 -0
  26. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/clients/triples_query_client.py +0 -0
  27. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/exceptions.py +0 -0
  28. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/knowledge/__init__.py +0 -0
  29. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/knowledge/defs.py +0 -0
  30. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/knowledge/document.py +0 -0
  31. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/knowledge/identifier.py +0 -0
  32. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/knowledge/organization.py +0 -0
  33. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/knowledge/publication.py +0 -0
  34. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/log_level.py +0 -0
  35. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/objects/__init__.py +0 -0
  36. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/objects/field.py +0 -0
  37. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/objects/object.py +0 -0
  38. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/rdf.py +0 -0
  39. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/schema/documents.py +0 -0
  40. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/schema/graph.py +0 -0
  41. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/schema/metadata.py +0 -0
  42. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/schema/models.py +0 -0
  43. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/schema/object.py +0 -0
  44. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/schema/prompt.py +0 -0
  45. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/schema/retrieval.py +0 -0
  46. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/schema/topic.py +0 -0
  47. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph/schema/types.py +0 -0
  48. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph_base.egg-info/dependency_links.txt +0 -0
  49. {trustgraph-base-0.14.16 → trustgraph-base-0.15.0}/trustgraph_base.egg-info/requires.txt +0 -0
  50. {trustgraph-base-0.14.16 → trustgraph-base-0.15.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.14.16
3
+ Version: 0.15.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.14.16.tar.gz
9
+ Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.15.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+)
@@ -39,8 +39,9 @@ class BaseProcessor:
39
39
 
40
40
  def __del__(self):
41
41
 
42
- if self.client:
43
- self.client.close()
42
+ if hasattr(self, "client"):
43
+ if self.client:
44
+ self.client.close()
44
45
 
45
46
  @staticmethod
46
47
  def add_args(parser):
@@ -0,0 +1 @@
1
+ __version__ = "0.15.0"
@@ -0,0 +1,64 @@
1
+
2
+ import _pulsar
3
+
4
+ from .. schema import AgentRequest, AgentResponse
5
+ from .. schema import agent_request_queue
6
+ from .. schema import agent_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 AgentClient(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 is None: input_queue = agent_request_queue
26
+ if output_queue is None: output_queue = agent_response_queue
27
+
28
+ super(AgentClient, self).__init__(
29
+ log_level=log_level,
30
+ subscriber=subscriber,
31
+ input_queue=input_queue,
32
+ output_queue=output_queue,
33
+ pulsar_host=pulsar_host,
34
+ input_schema=AgentRequest,
35
+ output_schema=AgentResponse,
36
+ )
37
+
38
+ def request(
39
+ self,
40
+ question,
41
+ think=None,
42
+ observe=None,
43
+ timeout=300
44
+ ):
45
+
46
+ def inspect(x):
47
+
48
+ if x.thought and think:
49
+ think(x.thought)
50
+ return
51
+
52
+ if x.observation and observe:
53
+ observe(x.observation)
54
+ return
55
+
56
+ if x.answer:
57
+ return True
58
+
59
+ return False
60
+
61
+ return self.call(
62
+ question=question, inspect=inspect, timeout=timeout
63
+ ).answer
64
+
@@ -59,10 +59,14 @@ class BaseClient:
59
59
  def call(self, **args):
60
60
 
61
61
  timeout = args.get("timeout", DEFAULT_TIMEOUT)
62
+ inspect = args.get("inspect", lambda x: True)
62
63
 
63
64
  if "timeout" in args:
64
65
  del args["timeout"]
65
66
 
67
+ if "inspect" in args:
68
+ del args["inspect"]
69
+
66
70
  id = str(uuid.uuid4())
67
71
 
68
72
  r = self.input_schema(**args)
@@ -103,6 +107,10 @@ class BaseClient:
103
107
  f"{value.error.type}: {value.error.message}"
104
108
  )
105
109
 
110
+ complete = inspect(value)
111
+
112
+ if not complete: continue
113
+
106
114
  resp = msg.value()
107
115
  self.consumer.acknowledge(msg)
108
116
  return resp
@@ -8,4 +8,5 @@ from . topic import *
8
8
  from . graph import *
9
9
  from . retrieval import *
10
10
  from . metadata import *
11
+ from . agent import *
11
12
 
@@ -0,0 +1,37 @@
1
+
2
+ from pulsar.schema import Record, String, Array, Map
3
+
4
+ from . topic import topic
5
+ from . types import Error
6
+
7
+ ############################################################################
8
+
9
+ # Prompt services, abstract the prompt generation
10
+
11
+ class AgentStep(Record):
12
+ thought = String()
13
+ action = String()
14
+ arguments = Map(String())
15
+ observation = String()
16
+
17
+ class AgentRequest(Record):
18
+ question = String()
19
+ plan = String()
20
+ state = String()
21
+ history = Array(AgentStep())
22
+
23
+ class AgentResponse(Record):
24
+ answer = String()
25
+ error = Error()
26
+ thought = String()
27
+ observation = String()
28
+
29
+ agent_request_queue = topic(
30
+ 'agent', kind='non-persistent', namespace='request'
31
+ )
32
+ agent_response_queue = topic(
33
+ 'agent', kind='non-persistent', namespace='response'
34
+ )
35
+
36
+ ############################################################################
37
+
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: trustgraph-base
3
- Version: 0.14.16
3
+ Version: 0.15.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.14.16.tar.gz
9
+ Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v0.15.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+)
@@ -10,6 +10,7 @@ trustgraph/base/consumer.py
10
10
  trustgraph/base/consumer_producer.py
11
11
  trustgraph/base/producer.py
12
12
  trustgraph/clients/__init__.py
13
+ trustgraph/clients/agent_client.py
13
14
  trustgraph/clients/base.py
14
15
  trustgraph/clients/document_embeddings_client.py
15
16
  trustgraph/clients/document_rag_client.py
@@ -29,6 +30,7 @@ trustgraph/objects/__init__.py
29
30
  trustgraph/objects/field.py
30
31
  trustgraph/objects/object.py
31
32
  trustgraph/schema/__init__.py
33
+ trustgraph/schema/agent.py
32
34
  trustgraph/schema/documents.py
33
35
  trustgraph/schema/graph.py
34
36
  trustgraph/schema/metadata.py
@@ -1 +0,0 @@
1
- __version__ = "0.14.16"