trustgraph-base 0.14.15__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.
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/PKG-INFO +2 -2
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/base/base_processor.py +3 -2
- trustgraph-base-0.15.0/trustgraph/base_version.py +1 -0
- trustgraph-base-0.15.0/trustgraph/clients/agent_client.py +64 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/clients/base.py +8 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/clients/prompt_client.py +8 -8
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/schema/__init__.py +1 -0
- trustgraph-base-0.15.0/trustgraph/schema/agent.py +37 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph_base.egg-info/PKG-INFO +2 -2
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph_base.egg-info/SOURCES.txt +2 -0
- trustgraph-base-0.14.15/trustgraph/base_version.py +0 -1
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/README.md +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/setup.cfg +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/setup.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/base/__init__.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/base/consumer.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/base/consumer_producer.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/base/producer.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/clients/__init__.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/clients/document_embeddings_client.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/clients/document_rag_client.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/clients/embeddings_client.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/clients/graph_embeddings_client.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/clients/graph_rag_client.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/clients/llm_client.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/clients/triples_query_client.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/exceptions.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/knowledge/__init__.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/knowledge/defs.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/knowledge/document.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/knowledge/identifier.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/knowledge/organization.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/knowledge/publication.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/log_level.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/objects/__init__.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/objects/field.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/objects/object.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/rdf.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/schema/documents.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/schema/graph.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/schema/metadata.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/schema/models.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/schema/object.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/schema/prompt.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/schema/retrieval.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/schema/topic.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/schema/types.py +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph_base.egg-info/dependency_links.txt +0 -0
- {trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph_base.egg-info/requires.txt +0 -0
- {trustgraph-base-0.14.15 → 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.
|
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.
|
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+)
|
@@ -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
|
@@ -57,13 +57,13 @@ class PromptClient(BaseClient):
|
|
57
57
|
output_schema=PromptResponse,
|
58
58
|
)
|
59
59
|
|
60
|
-
def request(self, id,
|
60
|
+
def request(self, id, variables, timeout=300):
|
61
61
|
|
62
62
|
resp = self.call(
|
63
63
|
id=id,
|
64
64
|
terms={
|
65
65
|
k: json.dumps(v)
|
66
|
-
for k, v in
|
66
|
+
for k, v in variables.items()
|
67
67
|
},
|
68
68
|
timeout=timeout
|
69
69
|
)
|
@@ -76,7 +76,7 @@ class PromptClient(BaseClient):
|
|
76
76
|
|
77
77
|
defs = self.request(
|
78
78
|
id="extract-definitions",
|
79
|
-
|
79
|
+
variables={
|
80
80
|
"text": chunk
|
81
81
|
},
|
82
82
|
timeout=timeout
|
@@ -91,7 +91,7 @@ class PromptClient(BaseClient):
|
|
91
91
|
|
92
92
|
rels = self.request(
|
93
93
|
id="extract-relationships",
|
94
|
-
|
94
|
+
variables={
|
95
95
|
"text": chunk
|
96
96
|
},
|
97
97
|
timeout=timeout
|
@@ -111,7 +111,7 @@ class PromptClient(BaseClient):
|
|
111
111
|
|
112
112
|
topics = self.request(
|
113
113
|
id="extract-topics",
|
114
|
-
|
114
|
+
variables={
|
115
115
|
"text": chunk
|
116
116
|
},
|
117
117
|
timeout=timeout
|
@@ -126,7 +126,7 @@ class PromptClient(BaseClient):
|
|
126
126
|
|
127
127
|
return self.request(
|
128
128
|
id="extract-rows",
|
129
|
-
|
129
|
+
variables={
|
130
130
|
"chunk": chunk,
|
131
131
|
"row-schema": {
|
132
132
|
"name": schema.name,
|
@@ -148,7 +148,7 @@ class PromptClient(BaseClient):
|
|
148
148
|
|
149
149
|
return self.request(
|
150
150
|
id="kg-prompt",
|
151
|
-
|
151
|
+
variables={
|
152
152
|
"query": query,
|
153
153
|
"knowledge": [
|
154
154
|
{ "s": v[0], "p": v[1], "o": v[2] }
|
@@ -162,7 +162,7 @@ class PromptClient(BaseClient):
|
|
162
162
|
|
163
163
|
return self.request(
|
164
164
|
id="document-prompt",
|
165
|
-
|
165
|
+
variables={
|
166
166
|
"query": query,
|
167
167
|
"documents": documents,
|
168
168
|
},
|
@@ -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.
|
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.
|
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.15"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/clients/document_embeddings_client.py
RENAMED
File without changes
|
{trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/clients/document_rag_client.py
RENAMED
File without changes
|
File without changes
|
{trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/clients/graph_embeddings_client.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph/clients/triples_query_client.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{trustgraph-base-0.14.15 → trustgraph-base-0.15.0}/trustgraph_base.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|