trustgraph-base 1.2.3__tar.gz → 1.2.5__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-1.2.3 → trustgraph_base-1.2.5}/PKG-INFO +1 -1
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/api/api.py +0 -5
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/api/config.py +5 -1
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/api/library.py +7 -4
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/agent_service.py +6 -2
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/async_processor.py +36 -13
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/consumer.py +14 -13
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/document_embeddings_client.py +6 -1
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/document_embeddings_query_service.py +10 -5
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/document_embeddings_store_service.py +6 -1
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/embeddings_service.py +8 -4
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/flow_processor.py +10 -6
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/graph_embeddings_client.py +6 -1
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/graph_embeddings_query_service.py +10 -5
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/graph_embeddings_store_service.py +6 -1
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/llm_service.py +6 -2
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/producer.py +8 -4
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/publisher.py +5 -1
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/pubsub.py +3 -4
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/request_response_spec.py +8 -4
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/subscriber.py +9 -6
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/tool_service.py +6 -2
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/triples_query_service.py +10 -5
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/triples_store_service.py +6 -1
- trustgraph_base-1.2.5/trustgraph/base_version.py +1 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph_base.egg-info/PKG-INFO +1 -1
- trustgraph_base-1.2.3/trustgraph/base_version.py +0 -1
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/README.md +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/pyproject.toml +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/setup.cfg +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/api/__init__.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/api/exceptions.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/api/flow.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/api/knowledge.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/api/types.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/__init__.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/agent_client.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/consumer_spec.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/embeddings_client.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/flow.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/graph_rag_client.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/metrics.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/producer_spec.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/prompt_client.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/setting_spec.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/spec.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/subscriber_spec.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/text_completion_client.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/tool_client.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/triples_client.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/clients/__init__.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/clients/agent_client.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/clients/base.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/clients/config_client.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/clients/document_embeddings_client.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/clients/document_rag_client.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/clients/embeddings_client.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/clients/graph_embeddings_client.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/clients/graph_rag_client.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/clients/llm_client.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/clients/prompt_client.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/clients/triples_query_client.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/exceptions.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/knowledge/__init__.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/knowledge/defs.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/knowledge/document.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/knowledge/identifier.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/knowledge/organization.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/knowledge/publication.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/log_level.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/messaging/__init__.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/messaging/registry.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/messaging/translators/__init__.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/messaging/translators/agent.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/messaging/translators/base.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/messaging/translators/config.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/messaging/translators/document_loading.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/messaging/translators/embeddings.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/messaging/translators/embeddings_query.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/messaging/translators/flow.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/messaging/translators/knowledge.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/messaging/translators/library.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/messaging/translators/metadata.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/messaging/translators/primitives.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/messaging/translators/prompt.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/messaging/translators/retrieval.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/messaging/translators/text_completion.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/messaging/translators/tool.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/messaging/translators/triples.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/objects/__init__.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/objects/field.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/objects/object.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/rdf.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/schema/__init__.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/schema/agent.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/schema/config.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/schema/documents.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/schema/flows.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/schema/graph.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/schema/knowledge.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/schema/library.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/schema/lookup.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/schema/metadata.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/schema/models.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/schema/object.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/schema/prompt.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/schema/retrieval.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/schema/topic.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/schema/types.py +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph_base.egg-info/SOURCES.txt +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph_base.egg-info/dependency_links.txt +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph_base.egg-info/requires.txt +0 -0
- {trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph_base.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: trustgraph-base
|
3
|
-
Version: 1.2.
|
3
|
+
Version: 1.2.5
|
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
|
Author-email: "trustgraph.ai" <security@trustgraph.ai>
|
6
6
|
Project-URL: Homepage, https://github.com/trustgraph-ai/trustgraph
|
@@ -49,9 +49,6 @@ class Api:
|
|
49
49
|
|
50
50
|
url = f"{self.url}{path}"
|
51
51
|
|
52
|
-
# print("uri:", url)
|
53
|
-
# print(json.dumps(request, indent=4))
|
54
|
-
|
55
52
|
# Invoke the API, input is passed as JSON
|
56
53
|
resp = requests.post(url, json=request, timeout=self.timeout)
|
57
54
|
|
@@ -59,8 +56,6 @@ class Api:
|
|
59
56
|
if resp.status_code != 200:
|
60
57
|
raise ProtocolException(f"Status code {resp.status_code}")
|
61
58
|
|
62
|
-
# print(resp.text)
|
63
|
-
|
64
59
|
try:
|
65
60
|
# Parse the response as JSON
|
66
61
|
object = resp.json()
|
@@ -1,7 +1,11 @@
|
|
1
1
|
|
2
|
+
import logging
|
3
|
+
|
2
4
|
from . exceptions import *
|
3
5
|
from . types import ConfigValue
|
4
6
|
|
7
|
+
logger = logging.getLogger(__name__)
|
8
|
+
|
5
9
|
class Config:
|
6
10
|
|
7
11
|
def __init__(self, api):
|
@@ -33,7 +37,7 @@ class Config:
|
|
33
37
|
for v in object["values"]
|
34
38
|
]
|
35
39
|
except Exception as e:
|
36
|
-
|
40
|
+
logger.error("Failed to parse config get response", exc_info=True)
|
37
41
|
raise ProtocolException("Response not formatted correctly")
|
38
42
|
|
39
43
|
def put(self, values):
|
@@ -2,11 +2,14 @@
|
|
2
2
|
import datetime
|
3
3
|
import time
|
4
4
|
import base64
|
5
|
+
import logging
|
5
6
|
|
6
7
|
from . types import DocumentMetadata, ProcessingMetadata, Triple
|
7
8
|
from .. knowledge import hash, Uri, Literal
|
8
9
|
from . exceptions import *
|
9
10
|
|
11
|
+
logger = logging.getLogger(__name__)
|
12
|
+
|
10
13
|
def to_value(x):
|
11
14
|
if x["e"]: return Uri(x["v"])
|
12
15
|
return Literal(x["v"])
|
@@ -112,7 +115,7 @@ class Library:
|
|
112
115
|
for v in object["document-metadatas"]
|
113
116
|
]
|
114
117
|
except Exception as e:
|
115
|
-
|
118
|
+
logger.error("Failed to parse document list response", exc_info=True)
|
116
119
|
raise ProtocolException(f"Response not formatted correctly")
|
117
120
|
|
118
121
|
def get_document(self, user, id):
|
@@ -145,7 +148,7 @@ class Library:
|
|
145
148
|
tags = doc["tags"]
|
146
149
|
)
|
147
150
|
except Exception as e:
|
148
|
-
|
151
|
+
logger.error("Failed to parse document response", exc_info=True)
|
149
152
|
raise ProtocolException(f"Response not formatted correctly")
|
150
153
|
|
151
154
|
def update_document(self, user, id, metadata):
|
@@ -192,7 +195,7 @@ class Library:
|
|
192
195
|
tags = doc["tags"]
|
193
196
|
)
|
194
197
|
except Exception as e:
|
195
|
-
|
198
|
+
logger.error("Failed to parse document update response", exc_info=True)
|
196
199
|
raise ProtocolException(f"Response not formatted correctly")
|
197
200
|
|
198
201
|
def remove_document(self, user, id):
|
@@ -266,6 +269,6 @@ class Library:
|
|
266
269
|
for v in object["processing-metadatas"]
|
267
270
|
]
|
268
271
|
except Exception as e:
|
269
|
-
|
272
|
+
logger.error("Failed to parse processing list response", exc_info=True)
|
270
273
|
raise ProtocolException(f"Response not formatted correctly")
|
271
274
|
|
@@ -4,12 +4,16 @@ Agent manager service completion base class
|
|
4
4
|
"""
|
5
5
|
|
6
6
|
import time
|
7
|
+
import logging
|
7
8
|
from prometheus_client import Histogram
|
8
9
|
|
9
10
|
from .. schema import AgentRequest, AgentResponse, Error
|
10
11
|
from .. exceptions import TooManyRequests
|
11
12
|
from .. base import FlowProcessor, ConsumerSpec, ProducerSpec
|
12
13
|
|
14
|
+
# Module logger
|
15
|
+
logger = logging.getLogger(__name__)
|
16
|
+
|
13
17
|
default_ident = "agent-manager"
|
14
18
|
|
15
19
|
class AgentService(FlowProcessor):
|
@@ -76,9 +80,9 @@ class AgentService(FlowProcessor):
|
|
76
80
|
except Exception as e:
|
77
81
|
|
78
82
|
# Apart from rate limits, treat all exceptions as unrecoverable
|
79
|
-
|
83
|
+
logger.error(f"Exception in agent service on_request: {e}", exc_info=True)
|
80
84
|
|
81
|
-
|
85
|
+
logger.info("Sending error response...")
|
82
86
|
|
83
87
|
await flow.producer["response"].send(
|
84
88
|
AgentResponse(
|
@@ -9,6 +9,8 @@ import argparse
|
|
9
9
|
import _pulsar
|
10
10
|
import time
|
11
11
|
import uuid
|
12
|
+
import logging
|
13
|
+
import os
|
12
14
|
from prometheus_client import start_http_server, Info
|
13
15
|
|
14
16
|
from .. schema import ConfigPush, config_push_queue
|
@@ -20,6 +22,9 @@ from . metrics import ProcessorMetrics, ConsumerMetrics
|
|
20
22
|
|
21
23
|
default_config_queue = config_push_queue
|
22
24
|
|
25
|
+
# Module logger
|
26
|
+
logger = logging.getLogger(__name__)
|
27
|
+
|
23
28
|
# Async processor
|
24
29
|
class AsyncProcessor:
|
25
30
|
|
@@ -113,7 +118,7 @@ class AsyncProcessor:
|
|
113
118
|
version = message.value().version
|
114
119
|
|
115
120
|
# Invoke message handlers
|
116
|
-
|
121
|
+
logger.info(f"Config change event: version={version}")
|
117
122
|
for ch in self.config_handlers:
|
118
123
|
await ch(config, version)
|
119
124
|
|
@@ -156,9 +161,23 @@ class AsyncProcessor:
|
|
156
161
|
|
157
162
|
# This is here to output a debug message, shouldn't be needed.
|
158
163
|
except Exception as e:
|
159
|
-
|
164
|
+
logger.error("Exception, closing taskgroup", exc_info=True)
|
160
165
|
raise e
|
161
166
|
|
167
|
+
@classmethod
|
168
|
+
def setup_logging(cls, log_level='INFO'):
|
169
|
+
"""Configure logging for the entire application"""
|
170
|
+
# Support environment variable override
|
171
|
+
env_log_level = os.environ.get('TRUSTGRAPH_LOG_LEVEL', log_level)
|
172
|
+
|
173
|
+
# Configure logging
|
174
|
+
logging.basicConfig(
|
175
|
+
level=getattr(logging, env_log_level.upper()),
|
176
|
+
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
177
|
+
handlers=[logging.StreamHandler()]
|
178
|
+
)
|
179
|
+
logger.info(f"Logging configured with level: {env_log_level}")
|
180
|
+
|
162
181
|
# Startup fabric. launch calls launch_async in async mode.
|
163
182
|
@classmethod
|
164
183
|
def launch(cls, ident, doc):
|
@@ -183,8 +202,11 @@ class AsyncProcessor:
|
|
183
202
|
args = parser.parse_args()
|
184
203
|
args = vars(args)
|
185
204
|
|
205
|
+
# Setup logging before anything else
|
206
|
+
cls.setup_logging(args.get('log_level', 'INFO').upper())
|
207
|
+
|
186
208
|
# Debug
|
187
|
-
|
209
|
+
logger.debug(f"Arguments: {args}")
|
188
210
|
|
189
211
|
# Start the Prometheus metrics service if needed
|
190
212
|
if args["metrics"]:
|
@@ -193,7 +215,7 @@ class AsyncProcessor:
|
|
193
215
|
# Loop forever, exception handler
|
194
216
|
while True:
|
195
217
|
|
196
|
-
|
218
|
+
logger.info("Starting...")
|
197
219
|
|
198
220
|
try:
|
199
221
|
|
@@ -203,30 +225,30 @@ class AsyncProcessor:
|
|
203
225
|
))
|
204
226
|
|
205
227
|
except KeyboardInterrupt:
|
206
|
-
|
228
|
+
logger.info("Keyboard interrupt.")
|
207
229
|
return
|
208
230
|
|
209
231
|
except _pulsar.Interrupted:
|
210
|
-
|
232
|
+
logger.info("Pulsar Interrupted.")
|
211
233
|
return
|
212
234
|
|
213
235
|
# Exceptions from a taskgroup come in as an exception group
|
214
236
|
except ExceptionGroup as e:
|
215
237
|
|
216
|
-
|
238
|
+
logger.error("Exception group:")
|
217
239
|
|
218
240
|
for se in e.exceptions:
|
219
|
-
|
220
|
-
|
241
|
+
logger.error(f" Type: {type(se)}")
|
242
|
+
logger.error(f" Exception: {se}", exc_info=se)
|
221
243
|
|
222
244
|
except Exception as e:
|
223
|
-
|
224
|
-
|
245
|
+
logger.error(f"Type: {type(e)}")
|
246
|
+
logger.error(f"Exception: {e}", exc_info=True)
|
225
247
|
|
226
248
|
# Retry occurs here
|
227
|
-
|
249
|
+
logger.warning("Will retry...")
|
228
250
|
time.sleep(4)
|
229
|
-
|
251
|
+
logger.info("Retrying...")
|
230
252
|
|
231
253
|
# The command-line arguments are built using a stack of add_args
|
232
254
|
# invocations
|
@@ -254,3 +276,4 @@ class AsyncProcessor:
|
|
254
276
|
default=8000,
|
255
277
|
help=f'Pulsar host (default: 8000)',
|
256
278
|
)
|
279
|
+
|
@@ -14,9 +14,13 @@ import pulsar
|
|
14
14
|
import _pulsar
|
15
15
|
import asyncio
|
16
16
|
import time
|
17
|
+
import logging
|
17
18
|
|
18
19
|
from .. exceptions import TooManyRequests
|
19
20
|
|
21
|
+
# Module logger
|
22
|
+
logger = logging.getLogger(__name__)
|
23
|
+
|
20
24
|
class Consumer:
|
21
25
|
|
22
26
|
def __init__(
|
@@ -90,7 +94,7 @@ class Consumer:
|
|
90
94
|
|
91
95
|
try:
|
92
96
|
|
93
|
-
|
97
|
+
logger.info(f"Subscribing to topic: {self.topic}")
|
94
98
|
|
95
99
|
if self.start_of_messages:
|
96
100
|
pos = pulsar.InitialPosition.Earliest
|
@@ -108,21 +112,18 @@ class Consumer:
|
|
108
112
|
|
109
113
|
except Exception as e:
|
110
114
|
|
111
|
-
|
115
|
+
logger.error(f"Consumer subscription exception: {e}", exc_info=True)
|
112
116
|
await asyncio.sleep(self.reconnect_time)
|
113
117
|
continue
|
114
118
|
|
115
|
-
|
119
|
+
logger.info(f"Successfully subscribed to topic: {self.topic}")
|
116
120
|
|
117
121
|
if self.metrics:
|
118
122
|
self.metrics.state("running")
|
119
123
|
|
120
124
|
try:
|
121
125
|
|
122
|
-
|
123
|
-
"Starting", self.concurrency, "receiver threads",
|
124
|
-
flush=True
|
125
|
-
)
|
126
|
+
logger.info(f"Starting {self.concurrency} receiver threads")
|
126
127
|
|
127
128
|
async with asyncio.TaskGroup() as tg:
|
128
129
|
|
@@ -138,7 +139,7 @@ class Consumer:
|
|
138
139
|
|
139
140
|
except Exception as e:
|
140
141
|
|
141
|
-
|
142
|
+
logger.error(f"Consumer loop exception: {e}", exc_info=True)
|
142
143
|
self.consumer.unsubscribe()
|
143
144
|
self.consumer.close()
|
144
145
|
self.consumer = None
|
@@ -174,7 +175,7 @@ class Consumer:
|
|
174
175
|
|
175
176
|
if time.time() > expiry:
|
176
177
|
|
177
|
-
|
178
|
+
logger.warning("Gave up waiting for rate-limit retry")
|
178
179
|
|
179
180
|
# Message failed to be processed, this causes it to
|
180
181
|
# be retried
|
@@ -188,7 +189,7 @@ class Consumer:
|
|
188
189
|
|
189
190
|
try:
|
190
191
|
|
191
|
-
|
192
|
+
logger.debug("Processing message...")
|
192
193
|
|
193
194
|
if self.metrics:
|
194
195
|
|
@@ -198,7 +199,7 @@ class Consumer:
|
|
198
199
|
else:
|
199
200
|
await self.handler(msg, self, self.flow)
|
200
201
|
|
201
|
-
|
202
|
+
logger.debug("Message processed successfully")
|
202
203
|
|
203
204
|
# Acknowledge successful processing of the message
|
204
205
|
self.consumer.acknowledge(msg)
|
@@ -211,7 +212,7 @@ class Consumer:
|
|
211
212
|
|
212
213
|
except TooManyRequests:
|
213
214
|
|
214
|
-
|
215
|
+
logger.warning("Rate limit exceeded, will retry...")
|
215
216
|
|
216
217
|
if self.metrics:
|
217
218
|
self.metrics.rate_limit()
|
@@ -224,7 +225,7 @@ class Consumer:
|
|
224
225
|
|
225
226
|
except Exception as e:
|
226
227
|
|
227
|
-
|
228
|
+
logger.error(f"Message processing exception: {e}", exc_info=True)
|
228
229
|
|
229
230
|
# Message failed to be processed, this causes it to
|
230
231
|
# be retried
|
{trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/document_embeddings_client.py
RENAMED
@@ -1,8 +1,13 @@
|
|
1
1
|
|
2
|
+
import logging
|
3
|
+
|
2
4
|
from . request_response_spec import RequestResponse, RequestResponseSpec
|
3
5
|
from .. schema import DocumentEmbeddingsRequest, DocumentEmbeddingsResponse
|
4
6
|
from .. knowledge import Uri, Literal
|
5
7
|
|
8
|
+
# Module logger
|
9
|
+
logger = logging.getLogger(__name__)
|
10
|
+
|
6
11
|
class DocumentEmbeddingsClient(RequestResponse):
|
7
12
|
async def query(self, vectors, limit=20, user="trustgraph",
|
8
13
|
collection="default", timeout=30):
|
@@ -17,7 +22,7 @@ class DocumentEmbeddingsClient(RequestResponse):
|
|
17
22
|
timeout=timeout
|
18
23
|
)
|
19
24
|
|
20
|
-
|
25
|
+
logger.debug(f"Document embeddings response: {resp}")
|
21
26
|
|
22
27
|
if resp.error:
|
23
28
|
raise RuntimeError(resp.error.message)
|
{trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/document_embeddings_query_service.py
RENAMED
@@ -4,6 +4,8 @@ Document embeddings query service. Input is vectors. Output is list of
|
|
4
4
|
embeddings.
|
5
5
|
"""
|
6
6
|
|
7
|
+
import logging
|
8
|
+
|
7
9
|
from .. schema import DocumentEmbeddingsRequest, DocumentEmbeddingsResponse
|
8
10
|
from .. schema import Error, Value
|
9
11
|
|
@@ -11,6 +13,9 @@ from . flow_processor import FlowProcessor
|
|
11
13
|
from . consumer_spec import ConsumerSpec
|
12
14
|
from . producer_spec import ProducerSpec
|
13
15
|
|
16
|
+
# Module logger
|
17
|
+
logger = logging.getLogger(__name__)
|
18
|
+
|
14
19
|
default_ident = "ge-query"
|
15
20
|
|
16
21
|
class DocumentEmbeddingsQueryService(FlowProcessor):
|
@@ -47,21 +52,21 @@ class DocumentEmbeddingsQueryService(FlowProcessor):
|
|
47
52
|
# Sender-produced ID
|
48
53
|
id = msg.properties()["id"]
|
49
54
|
|
50
|
-
|
55
|
+
logger.debug(f"Handling document embeddings query request {id}...")
|
51
56
|
|
52
57
|
docs = await self.query_document_embeddings(request)
|
53
58
|
|
54
|
-
|
59
|
+
logger.debug("Sending document embeddings query response...")
|
55
60
|
r = DocumentEmbeddingsResponse(documents=docs, error=None)
|
56
61
|
await flow("response").send(r, properties={"id": id})
|
57
62
|
|
58
|
-
|
63
|
+
logger.debug("Document embeddings query request completed")
|
59
64
|
|
60
65
|
except Exception as e:
|
61
66
|
|
62
|
-
|
67
|
+
logger.error(f"Exception in document embeddings query service: {e}", exc_info=True)
|
63
68
|
|
64
|
-
|
69
|
+
logger.info("Sending error response...")
|
65
70
|
|
66
71
|
r = DocumentEmbeddingsResponse(
|
67
72
|
error=Error(
|
{trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/document_embeddings_store_service.py
RENAMED
@@ -3,10 +3,15 @@
|
|
3
3
|
Document embeddings store base class
|
4
4
|
"""
|
5
5
|
|
6
|
+
import logging
|
7
|
+
|
6
8
|
from .. schema import DocumentEmbeddings
|
7
9
|
from .. base import FlowProcessor, ConsumerSpec
|
8
10
|
from .. exceptions import TooManyRequests
|
9
11
|
|
12
|
+
# Module logger
|
13
|
+
logger = logging.getLogger(__name__)
|
14
|
+
|
10
15
|
default_ident = "document-embeddings-write"
|
11
16
|
|
12
17
|
class DocumentEmbeddingsStoreService(FlowProcessor):
|
@@ -40,7 +45,7 @@ class DocumentEmbeddingsStoreService(FlowProcessor):
|
|
40
45
|
|
41
46
|
except Exception as e:
|
42
47
|
|
43
|
-
|
48
|
+
logger.error(f"Exception in document embeddings store service: {e}", exc_info=True)
|
44
49
|
raise e
|
45
50
|
|
46
51
|
@staticmethod
|
@@ -4,12 +4,16 @@ Embeddings resolution base class
|
|
4
4
|
"""
|
5
5
|
|
6
6
|
import time
|
7
|
+
import logging
|
7
8
|
from prometheus_client import Histogram
|
8
9
|
|
9
10
|
from .. schema import EmbeddingsRequest, EmbeddingsResponse, Error
|
10
11
|
from .. exceptions import TooManyRequests
|
11
12
|
from .. base import FlowProcessor, ConsumerSpec, ProducerSpec
|
12
13
|
|
14
|
+
# Module logger
|
15
|
+
logger = logging.getLogger(__name__)
|
16
|
+
|
13
17
|
default_ident = "embeddings"
|
14
18
|
default_concurrency = 1
|
15
19
|
|
@@ -51,7 +55,7 @@ class EmbeddingsService(FlowProcessor):
|
|
51
55
|
|
52
56
|
id = msg.properties()["id"]
|
53
57
|
|
54
|
-
|
58
|
+
logger.debug(f"Handling embeddings request {id}...")
|
55
59
|
|
56
60
|
vectors = await self.on_embeddings(request.text)
|
57
61
|
|
@@ -63,7 +67,7 @@ class EmbeddingsService(FlowProcessor):
|
|
63
67
|
properties={"id": id}
|
64
68
|
)
|
65
69
|
|
66
|
-
|
70
|
+
logger.debug("Embeddings request handled successfully")
|
67
71
|
|
68
72
|
except TooManyRequests as e:
|
69
73
|
raise e
|
@@ -72,9 +76,9 @@ class EmbeddingsService(FlowProcessor):
|
|
72
76
|
|
73
77
|
# Apart from rate limits, treat all exceptions as unrecoverable
|
74
78
|
|
75
|
-
|
79
|
+
logger.error(f"Exception in embeddings service: {e}", exc_info=True)
|
76
80
|
|
77
|
-
|
81
|
+
logger.info("Sending error response...")
|
78
82
|
|
79
83
|
await flow.producer["response"].send(
|
80
84
|
EmbeddingsResponse(
|
@@ -4,6 +4,7 @@
|
|
4
4
|
# configuration service which can't manage itself.
|
5
5
|
|
6
6
|
import json
|
7
|
+
import logging
|
7
8
|
|
8
9
|
from pulsar.schema import JsonSchema
|
9
10
|
|
@@ -14,6 +15,9 @@ from .. log_level import LogLevel
|
|
14
15
|
from . async_processor import AsyncProcessor
|
15
16
|
from . flow import Flow
|
16
17
|
|
18
|
+
# Module logger
|
19
|
+
logger = logging.getLogger(__name__)
|
20
|
+
|
17
21
|
# Parent class for configurable processors, configured with flows by
|
18
22
|
# the config service
|
19
23
|
class FlowProcessor(AsyncProcessor):
|
@@ -34,7 +38,7 @@ class FlowProcessor(AsyncProcessor):
|
|
34
38
|
# Array of specifications: ConsumerSpec, ProducerSpec, SettingSpec
|
35
39
|
self.specifications = []
|
36
40
|
|
37
|
-
|
41
|
+
logger.info("Service initialised.")
|
38
42
|
|
39
43
|
# Register a configuration variable
|
40
44
|
def register_specification(self, spec):
|
@@ -44,19 +48,19 @@ class FlowProcessor(AsyncProcessor):
|
|
44
48
|
async def start_flow(self, flow, defn):
|
45
49
|
self.flows[flow] = Flow(self.id, flow, self, defn)
|
46
50
|
await self.flows[flow].start()
|
47
|
-
|
51
|
+
logger.info(f"Started flow: {flow}")
|
48
52
|
|
49
53
|
# Stop processing for a new flow
|
50
54
|
async def stop_flow(self, flow):
|
51
55
|
if flow in self.flows:
|
52
56
|
await self.flows[flow].stop()
|
53
57
|
del self.flows[flow]
|
54
|
-
|
58
|
+
logger.info(f"Stopped flow: {flow}")
|
55
59
|
|
56
60
|
# Event handler - called for a configuration change
|
57
61
|
async def on_configure_flows(self, config, version):
|
58
62
|
|
59
|
-
|
63
|
+
logger.info(f"Got config version {version}")
|
60
64
|
|
61
65
|
# Skip over invalid data
|
62
66
|
if "flows-active" not in config: return
|
@@ -69,7 +73,7 @@ class FlowProcessor(AsyncProcessor):
|
|
69
73
|
|
70
74
|
else:
|
71
75
|
|
72
|
-
|
76
|
+
logger.debug("No configuration settings for me.")
|
73
77
|
flow_config = {}
|
74
78
|
|
75
79
|
# Get list of flows which should be running and are currently
|
@@ -88,7 +92,7 @@ class FlowProcessor(AsyncProcessor):
|
|
88
92
|
if flow not in wanted_flows:
|
89
93
|
await self.stop_flow(flow)
|
90
94
|
|
91
|
-
|
95
|
+
logger.info("Handled config update")
|
92
96
|
|
93
97
|
# Start threads, just call parent
|
94
98
|
async def start(self):
|
@@ -1,8 +1,13 @@
|
|
1
1
|
|
2
|
+
import logging
|
3
|
+
|
2
4
|
from . request_response_spec import RequestResponse, RequestResponseSpec
|
3
5
|
from .. schema import GraphEmbeddingsRequest, GraphEmbeddingsResponse
|
4
6
|
from .. knowledge import Uri, Literal
|
5
7
|
|
8
|
+
# Module logger
|
9
|
+
logger = logging.getLogger(__name__)
|
10
|
+
|
6
11
|
def to_value(x):
|
7
12
|
if x.is_uri: return Uri(x.value)
|
8
13
|
return Literal(x.value)
|
@@ -21,7 +26,7 @@ class GraphEmbeddingsClient(RequestResponse):
|
|
21
26
|
timeout=timeout
|
22
27
|
)
|
23
28
|
|
24
|
-
|
29
|
+
logger.debug(f"Graph embeddings response: {resp}")
|
25
30
|
|
26
31
|
if resp.error:
|
27
32
|
raise RuntimeError(resp.error.message)
|
{trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/graph_embeddings_query_service.py
RENAMED
@@ -4,6 +4,8 @@ Graph embeddings query service. Input is vectors. Output is list of
|
|
4
4
|
embeddings.
|
5
5
|
"""
|
6
6
|
|
7
|
+
import logging
|
8
|
+
|
7
9
|
from .. schema import GraphEmbeddingsRequest, GraphEmbeddingsResponse
|
8
10
|
from .. schema import Error, Value
|
9
11
|
|
@@ -11,6 +13,9 @@ from . flow_processor import FlowProcessor
|
|
11
13
|
from . consumer_spec import ConsumerSpec
|
12
14
|
from . producer_spec import ProducerSpec
|
13
15
|
|
16
|
+
# Module logger
|
17
|
+
logger = logging.getLogger(__name__)
|
18
|
+
|
14
19
|
default_ident = "ge-query"
|
15
20
|
|
16
21
|
class GraphEmbeddingsQueryService(FlowProcessor):
|
@@ -47,21 +52,21 @@ class GraphEmbeddingsQueryService(FlowProcessor):
|
|
47
52
|
# Sender-produced ID
|
48
53
|
id = msg.properties()["id"]
|
49
54
|
|
50
|
-
|
55
|
+
logger.debug(f"Handling graph embeddings query request {id}...")
|
51
56
|
|
52
57
|
entities = await self.query_graph_embeddings(request)
|
53
58
|
|
54
|
-
|
59
|
+
logger.debug("Sending graph embeddings query response...")
|
55
60
|
r = GraphEmbeddingsResponse(entities=entities, error=None)
|
56
61
|
await flow("response").send(r, properties={"id": id})
|
57
62
|
|
58
|
-
|
63
|
+
logger.debug("Graph embeddings query request completed")
|
59
64
|
|
60
65
|
except Exception as e:
|
61
66
|
|
62
|
-
|
67
|
+
logger.error(f"Exception in graph embeddings query service: {e}", exc_info=True)
|
63
68
|
|
64
|
-
|
69
|
+
logger.info("Sending error response...")
|
65
70
|
|
66
71
|
r = GraphEmbeddingsResponse(
|
67
72
|
error=Error(
|
{trustgraph_base-1.2.3 → trustgraph_base-1.2.5}/trustgraph/base/graph_embeddings_store_service.py
RENAMED
@@ -3,10 +3,15 @@
|
|
3
3
|
Graph embeddings store base class
|
4
4
|
"""
|
5
5
|
|
6
|
+
import logging
|
7
|
+
|
6
8
|
from .. schema import GraphEmbeddings
|
7
9
|
from .. base import FlowProcessor, ConsumerSpec
|
8
10
|
from .. exceptions import TooManyRequests
|
9
11
|
|
12
|
+
# Module logger
|
13
|
+
logger = logging.getLogger(__name__)
|
14
|
+
|
10
15
|
default_ident = "graph-embeddings-write"
|
11
16
|
|
12
17
|
class GraphEmbeddingsStoreService(FlowProcessor):
|
@@ -40,7 +45,7 @@ class GraphEmbeddingsStoreService(FlowProcessor):
|
|
40
45
|
|
41
46
|
except Exception as e:
|
42
47
|
|
43
|
-
|
48
|
+
logger.error(f"Exception in graph embeddings store service: {e}", exc_info=True)
|
44
49
|
raise e
|
45
50
|
|
46
51
|
@staticmethod
|
@@ -4,12 +4,16 @@ LLM text completion base class
|
|
4
4
|
"""
|
5
5
|
|
6
6
|
import time
|
7
|
+
import logging
|
7
8
|
from prometheus_client import Histogram
|
8
9
|
|
9
10
|
from .. schema import TextCompletionRequest, TextCompletionResponse, Error
|
10
11
|
from .. exceptions import TooManyRequests
|
11
12
|
from .. base import FlowProcessor, ConsumerSpec, ProducerSpec
|
12
13
|
|
14
|
+
# Module logger
|
15
|
+
logger = logging.getLogger(__name__)
|
16
|
+
|
13
17
|
default_ident = "text-completion"
|
14
18
|
default_concurrency = 1
|
15
19
|
|
@@ -103,9 +107,9 @@ class LlmService(FlowProcessor):
|
|
103
107
|
|
104
108
|
# Apart from rate limits, treat all exceptions as unrecoverable
|
105
109
|
|
106
|
-
|
110
|
+
logger.error(f"LLM service exception: {e}", exc_info=True)
|
107
111
|
|
108
|
-
|
112
|
+
logger.debug("Sending error response...")
|
109
113
|
|
110
114
|
await flow.producer["response"].send(
|
111
115
|
TextCompletionResponse(
|