trustgraph-cli 2.1.25__tar.gz → 2.1.27__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_cli-2.1.25 → trustgraph_cli-2.1.27}/PKG-INFO +1 -1
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/pyproject.toml +1 -0
- trustgraph_cli-2.1.27/trustgraph/cli/monitor_prompts.py +344 -0
- trustgraph_cli-2.1.27/trustgraph/cli_version.py +1 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph_cli.egg-info/PKG-INFO +1 -1
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph_cli.egg-info/SOURCES.txt +1 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph_cli.egg-info/entry_points.txt +1 -0
- trustgraph_cli-2.1.25/trustgraph/cli_version.py +0 -1
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/README.md +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/setup.cfg +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/__init__.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/add_library_document.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/delete_collection.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/delete_config_item.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/delete_flow_blueprint.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/delete_kg_core.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/delete_mcp_tool.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/delete_tool.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/dump_msgpack.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/dump_queues.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/get_config_item.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/get_document_content.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/get_flow_blueprint.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/get_kg_core.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/graph_to_turtle.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/init_pulsar_manager.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/init_trustgraph.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/invoke_agent.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/invoke_document_embeddings.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/invoke_document_rag.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/invoke_embeddings.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/invoke_graph_embeddings.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/invoke_graph_rag.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/invoke_llm.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/invoke_mcp_tool.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/invoke_nlp_query.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/invoke_prompt.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/invoke_row_embeddings.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/invoke_rows_query.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/invoke_structured_query.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/list_collections.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/list_config_items.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/list_explain_traces.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/load_doc_embeds.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/load_kg_core.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/load_knowledge.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/load_sample_documents.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/load_structured_data.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/load_turtle.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/put_config_item.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/put_flow_blueprint.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/put_kg_core.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/query_graph.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/remove_library_document.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/save_doc_embeds.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/set_collection.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/set_mcp_tool.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/set_prompt.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/set_token_costs.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/set_tool.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/show_config.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/show_explain_trace.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/show_extraction_provenance.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/show_flow_blueprints.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/show_flow_state.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/show_flows.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/show_graph.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/show_kg_cores.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/show_library_documents.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/show_library_processing.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/show_mcp_tools.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/show_parameter_types.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/show_processor_state.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/show_prompts.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/show_token_costs.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/show_token_rate.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/show_tools.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/start_flow.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/start_library_processing.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/stop_flow.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/stop_library_processing.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/unload_kg_core.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/verify_system_status.py +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph_cli.egg-info/dependency_links.txt +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph_cli.egg-info/requires.txt +0 -0
- {trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph_cli.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: trustgraph-cli
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.27
|
|
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
|
|
@@ -35,6 +35,7 @@ tg-delete-kg-core = "trustgraph.cli.delete_kg_core:main"
|
|
|
35
35
|
tg-delete-tool = "trustgraph.cli.delete_tool:main"
|
|
36
36
|
tg-dump-msgpack = "trustgraph.cli.dump_msgpack:main"
|
|
37
37
|
tg-dump-queues = "trustgraph.cli.dump_queues:main"
|
|
38
|
+
tg-monitor-prompts = "trustgraph.cli.monitor_prompts:main"
|
|
38
39
|
tg-get-flow-blueprint = "trustgraph.cli.get_flow_blueprint:main"
|
|
39
40
|
tg-get-kg-core = "trustgraph.cli.get_kg_core:main"
|
|
40
41
|
tg-get-document-content = "trustgraph.cli.get_document_content:main"
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Monitor prompt request/response queues and log activity with timing.
|
|
3
|
+
|
|
4
|
+
Subscribes to prompt request and response Pulsar queues, correlates
|
|
5
|
+
them by message ID, and logs a summary of each request/response with
|
|
6
|
+
elapsed time. Streaming responses are accumulated and shown once at
|
|
7
|
+
completion.
|
|
8
|
+
|
|
9
|
+
Examples:
|
|
10
|
+
tg-monitor-prompts
|
|
11
|
+
tg-monitor-prompts --flow default --max-lines 5
|
|
12
|
+
tg-monitor-prompts --queue-type prompt-rag
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import json
|
|
16
|
+
import asyncio
|
|
17
|
+
import sys
|
|
18
|
+
import argparse
|
|
19
|
+
from datetime import datetime
|
|
20
|
+
from collections import OrderedDict
|
|
21
|
+
|
|
22
|
+
import pulsar
|
|
23
|
+
from pulsar.schema import BytesSchema
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
default_flow = "default"
|
|
27
|
+
default_queue_type = "prompt"
|
|
28
|
+
default_max_lines = 3
|
|
29
|
+
default_max_width = 80
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def truncate_text(text, max_lines, max_width):
|
|
33
|
+
"""Truncate text to max_lines lines, each at most max_width chars."""
|
|
34
|
+
if not text:
|
|
35
|
+
return "(empty)"
|
|
36
|
+
|
|
37
|
+
lines = text.splitlines()
|
|
38
|
+
result = []
|
|
39
|
+
for line in lines[:max_lines]:
|
|
40
|
+
if len(line) > max_width:
|
|
41
|
+
result.append(line[:max_width - 3] + "...")
|
|
42
|
+
else:
|
|
43
|
+
result.append(line)
|
|
44
|
+
|
|
45
|
+
if len(lines) > max_lines:
|
|
46
|
+
result.append(f" ... ({len(lines) - max_lines} more lines)")
|
|
47
|
+
|
|
48
|
+
return "\n".join(result)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def summarise_value(value, max_width):
|
|
52
|
+
"""Summarise a term value — show type and size for large values."""
|
|
53
|
+
# Try to parse JSON
|
|
54
|
+
try:
|
|
55
|
+
parsed = json.loads(value)
|
|
56
|
+
except (json.JSONDecodeError, TypeError):
|
|
57
|
+
parsed = value
|
|
58
|
+
|
|
59
|
+
if isinstance(parsed, list):
|
|
60
|
+
return f"[{len(parsed)} items]"
|
|
61
|
+
elif isinstance(parsed, dict):
|
|
62
|
+
return f"{{{len(parsed)} keys}}"
|
|
63
|
+
elif isinstance(parsed, str):
|
|
64
|
+
if len(parsed) > max_width:
|
|
65
|
+
return parsed[:max_width - 3] + "..."
|
|
66
|
+
return parsed
|
|
67
|
+
else:
|
|
68
|
+
s = str(parsed)
|
|
69
|
+
if len(s) > max_width:
|
|
70
|
+
return s[:max_width - 3] + "..."
|
|
71
|
+
return s
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def format_terms(terms, max_lines, max_width):
|
|
75
|
+
"""Format prompt terms for display — concise summary."""
|
|
76
|
+
if not terms:
|
|
77
|
+
return ""
|
|
78
|
+
|
|
79
|
+
parts = []
|
|
80
|
+
for key, value in terms.items():
|
|
81
|
+
summary = summarise_value(value, max_width - len(key) - 4)
|
|
82
|
+
parts.append(f" {key}: {summary}")
|
|
83
|
+
|
|
84
|
+
return "\n".join(parts)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def parse_raw_message(msg):
|
|
88
|
+
"""Parse a raw Pulsar message into (correlation_id, body_dict)."""
|
|
89
|
+
try:
|
|
90
|
+
props = msg.properties()
|
|
91
|
+
corr_id = props.get("id", "")
|
|
92
|
+
except Exception:
|
|
93
|
+
corr_id = ""
|
|
94
|
+
|
|
95
|
+
try:
|
|
96
|
+
value = msg.value()
|
|
97
|
+
if isinstance(value, bytes):
|
|
98
|
+
value = value.decode("utf-8")
|
|
99
|
+
body = json.loads(value) if isinstance(value, str) else {}
|
|
100
|
+
except Exception:
|
|
101
|
+
body = {}
|
|
102
|
+
|
|
103
|
+
return corr_id, body
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def receive_with_timeout(consumer, timeout_ms=500):
|
|
107
|
+
"""Receive a message with timeout, returning None on timeout."""
|
|
108
|
+
try:
|
|
109
|
+
return consumer.receive(timeout_millis=timeout_ms)
|
|
110
|
+
except Exception:
|
|
111
|
+
return None
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
async def monitor(flow, queue_type, max_lines, max_width,
|
|
115
|
+
pulsar_host, listener_name):
|
|
116
|
+
|
|
117
|
+
request_queue = f"non-persistent://tg/request/{queue_type}:{flow}"
|
|
118
|
+
response_queue = f"non-persistent://tg/response/{queue_type}:{flow}"
|
|
119
|
+
|
|
120
|
+
print(f"Monitoring prompt queues:")
|
|
121
|
+
print(f" Request: {request_queue}")
|
|
122
|
+
print(f" Response: {response_queue}")
|
|
123
|
+
print(f"Press Ctrl+C to stop\n")
|
|
124
|
+
|
|
125
|
+
client = pulsar.Client(
|
|
126
|
+
pulsar_host,
|
|
127
|
+
listener_name=listener_name,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
req_consumer = client.subscribe(
|
|
131
|
+
request_queue,
|
|
132
|
+
subscription_name="prompt-monitor-req",
|
|
133
|
+
consumer_type=pulsar.ConsumerType.Shared,
|
|
134
|
+
schema=BytesSchema(),
|
|
135
|
+
initial_position=pulsar.InitialPosition.Latest,
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
resp_consumer = client.subscribe(
|
|
139
|
+
response_queue,
|
|
140
|
+
subscription_name="prompt-monitor-resp",
|
|
141
|
+
consumer_type=pulsar.ConsumerType.Shared,
|
|
142
|
+
schema=BytesSchema(),
|
|
143
|
+
initial_position=pulsar.InitialPosition.Latest,
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
# Track in-flight requests: corr_id -> (timestamp, template_id)
|
|
147
|
+
in_flight = OrderedDict()
|
|
148
|
+
|
|
149
|
+
# Accumulate streaming responses: corr_id -> list of text chunks
|
|
150
|
+
streaming_chunks = {}
|
|
151
|
+
|
|
152
|
+
print("Listening...\n")
|
|
153
|
+
|
|
154
|
+
try:
|
|
155
|
+
while True:
|
|
156
|
+
got_message = False
|
|
157
|
+
|
|
158
|
+
# Poll request queue
|
|
159
|
+
msg = receive_with_timeout(req_consumer, 100)
|
|
160
|
+
if msg:
|
|
161
|
+
got_message = True
|
|
162
|
+
timestamp = datetime.now()
|
|
163
|
+
corr_id, body = parse_raw_message(msg)
|
|
164
|
+
time_str = timestamp.strftime("%H:%M:%S.%f")[:-3]
|
|
165
|
+
|
|
166
|
+
template_id = body.get("id", "(unknown)")
|
|
167
|
+
terms = body.get("terms", {})
|
|
168
|
+
streaming = body.get("streaming", False)
|
|
169
|
+
|
|
170
|
+
in_flight[corr_id] = (timestamp, template_id)
|
|
171
|
+
|
|
172
|
+
# Limit size
|
|
173
|
+
while len(in_flight) > 1000:
|
|
174
|
+
in_flight.popitem(last=False)
|
|
175
|
+
|
|
176
|
+
stream_flag = " [streaming]" if streaming else ""
|
|
177
|
+
id_display = corr_id[:8] if corr_id else "--------"
|
|
178
|
+
print(f"[{time_str}] REQ {id_display} "
|
|
179
|
+
f"template={template_id}{stream_flag}")
|
|
180
|
+
|
|
181
|
+
if terms:
|
|
182
|
+
print(format_terms(terms, max_lines, max_width))
|
|
183
|
+
|
|
184
|
+
req_consumer.acknowledge(msg)
|
|
185
|
+
|
|
186
|
+
# Poll response queue
|
|
187
|
+
msg = receive_with_timeout(resp_consumer, 100)
|
|
188
|
+
if msg:
|
|
189
|
+
got_message = True
|
|
190
|
+
timestamp = datetime.now()
|
|
191
|
+
corr_id, body = parse_raw_message(msg)
|
|
192
|
+
time_str = timestamp.strftime("%H:%M:%S.%f")[:-3]
|
|
193
|
+
id_display = corr_id[:8] if corr_id else "--------"
|
|
194
|
+
|
|
195
|
+
error = body.get("error")
|
|
196
|
+
text = body.get("text", "")
|
|
197
|
+
obj = body.get("object", "")
|
|
198
|
+
eos = body.get("end_of_stream", False)
|
|
199
|
+
|
|
200
|
+
if error:
|
|
201
|
+
# Error — show immediately
|
|
202
|
+
elapsed_str = ""
|
|
203
|
+
if corr_id in in_flight:
|
|
204
|
+
req_timestamp, _ = in_flight.pop(corr_id)
|
|
205
|
+
elapsed = (timestamp - req_timestamp).total_seconds()
|
|
206
|
+
elapsed_str = f" ({elapsed:.3f}s)"
|
|
207
|
+
streaming_chunks.pop(corr_id, None)
|
|
208
|
+
|
|
209
|
+
err_msg = error
|
|
210
|
+
if isinstance(error, dict):
|
|
211
|
+
err_msg = error.get("message", str(error))
|
|
212
|
+
print(f"[{time_str}] ERR {id_display} "
|
|
213
|
+
f"{err_msg}{elapsed_str}")
|
|
214
|
+
|
|
215
|
+
elif eos:
|
|
216
|
+
# End of stream — show accumulated text + timing
|
|
217
|
+
elapsed_str = ""
|
|
218
|
+
if corr_id in in_flight:
|
|
219
|
+
req_timestamp, _ = in_flight.pop(corr_id)
|
|
220
|
+
elapsed = (timestamp - req_timestamp).total_seconds()
|
|
221
|
+
elapsed_str = f" ({elapsed:.3f}s)"
|
|
222
|
+
|
|
223
|
+
accumulated = streaming_chunks.pop(corr_id, [])
|
|
224
|
+
if text:
|
|
225
|
+
accumulated.append(text)
|
|
226
|
+
|
|
227
|
+
full_text = "".join(accumulated)
|
|
228
|
+
if full_text:
|
|
229
|
+
truncated = truncate_text(
|
|
230
|
+
full_text, max_lines, max_width
|
|
231
|
+
)
|
|
232
|
+
print(f"[{time_str}] RESP {id_display}"
|
|
233
|
+
f"{elapsed_str}")
|
|
234
|
+
print(f" {truncated}")
|
|
235
|
+
else:
|
|
236
|
+
print(f"[{time_str}] RESP {id_display}"
|
|
237
|
+
f"{elapsed_str} (empty)")
|
|
238
|
+
|
|
239
|
+
elif text or obj:
|
|
240
|
+
# Streaming chunk or non-streaming response
|
|
241
|
+
if corr_id in streaming_chunks or (
|
|
242
|
+
corr_id in in_flight
|
|
243
|
+
):
|
|
244
|
+
# Accumulate streaming chunk
|
|
245
|
+
if corr_id not in streaming_chunks:
|
|
246
|
+
streaming_chunks[corr_id] = []
|
|
247
|
+
streaming_chunks[corr_id].append(text or obj)
|
|
248
|
+
else:
|
|
249
|
+
# Non-streaming single response
|
|
250
|
+
elapsed_str = ""
|
|
251
|
+
if corr_id in in_flight:
|
|
252
|
+
req_timestamp, _ = in_flight.pop(corr_id)
|
|
253
|
+
elapsed = (
|
|
254
|
+
timestamp - req_timestamp
|
|
255
|
+
).total_seconds()
|
|
256
|
+
elapsed_str = f" ({elapsed:.3f}s)"
|
|
257
|
+
|
|
258
|
+
content = text or obj
|
|
259
|
+
label = "" if text else " (object)"
|
|
260
|
+
truncated = truncate_text(
|
|
261
|
+
content, max_lines, max_width
|
|
262
|
+
)
|
|
263
|
+
print(f"[{time_str}] RESP {id_display}"
|
|
264
|
+
f"{label}{elapsed_str}")
|
|
265
|
+
print(f" {truncated}")
|
|
266
|
+
|
|
267
|
+
resp_consumer.acknowledge(msg)
|
|
268
|
+
|
|
269
|
+
if not got_message:
|
|
270
|
+
await asyncio.sleep(0.05)
|
|
271
|
+
|
|
272
|
+
except KeyboardInterrupt:
|
|
273
|
+
print("\nStopping...")
|
|
274
|
+
finally:
|
|
275
|
+
req_consumer.close()
|
|
276
|
+
resp_consumer.close()
|
|
277
|
+
client.close()
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def main():
|
|
281
|
+
parser = argparse.ArgumentParser(
|
|
282
|
+
prog="tg-monitor-prompts",
|
|
283
|
+
description=__doc__,
|
|
284
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
285
|
+
)
|
|
286
|
+
|
|
287
|
+
parser.add_argument(
|
|
288
|
+
"-f", "--flow",
|
|
289
|
+
default=default_flow,
|
|
290
|
+
help=f"Flow ID (default: {default_flow})",
|
|
291
|
+
)
|
|
292
|
+
|
|
293
|
+
parser.add_argument(
|
|
294
|
+
"-q", "--queue-type",
|
|
295
|
+
default=default_queue_type,
|
|
296
|
+
help=f"Queue type: prompt or prompt-rag (default: {default_queue_type})",
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
parser.add_argument(
|
|
300
|
+
"-l", "--max-lines",
|
|
301
|
+
type=int,
|
|
302
|
+
default=default_max_lines,
|
|
303
|
+
help=f"Max lines of text per term/response (default: {default_max_lines})",
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
parser.add_argument(
|
|
307
|
+
"-w", "--max-width",
|
|
308
|
+
type=int,
|
|
309
|
+
default=default_max_width,
|
|
310
|
+
help=f"Max width per line (default: {default_max_width})",
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
parser.add_argument(
|
|
314
|
+
"--pulsar-host",
|
|
315
|
+
default="pulsar://localhost:6650",
|
|
316
|
+
help="Pulsar host URL (default: pulsar://localhost:6650)",
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
parser.add_argument(
|
|
320
|
+
"--listener-name",
|
|
321
|
+
default="localhost",
|
|
322
|
+
help="Pulsar listener name (default: localhost)",
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
args = parser.parse_args()
|
|
326
|
+
|
|
327
|
+
try:
|
|
328
|
+
asyncio.run(monitor(
|
|
329
|
+
flow=args.flow,
|
|
330
|
+
queue_type=args.queue_type,
|
|
331
|
+
max_lines=args.max_lines,
|
|
332
|
+
max_width=args.max_width,
|
|
333
|
+
pulsar_host=args.pulsar_host,
|
|
334
|
+
listener_name=args.listener_name,
|
|
335
|
+
))
|
|
336
|
+
except KeyboardInterrupt:
|
|
337
|
+
pass
|
|
338
|
+
except Exception as e:
|
|
339
|
+
print(f"Fatal error: {e}", file=sys.stderr)
|
|
340
|
+
sys.exit(1)
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
if __name__ == "__main__":
|
|
344
|
+
main()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.1.27"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: trustgraph-cli
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.27
|
|
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
|
|
@@ -40,6 +40,7 @@ trustgraph/cli/load_knowledge.py
|
|
|
40
40
|
trustgraph/cli/load_sample_documents.py
|
|
41
41
|
trustgraph/cli/load_structured_data.py
|
|
42
42
|
trustgraph/cli/load_turtle.py
|
|
43
|
+
trustgraph/cli/monitor_prompts.py
|
|
43
44
|
trustgraph/cli/put_config_item.py
|
|
44
45
|
trustgraph/cli/put_flow_blueprint.py
|
|
45
46
|
trustgraph/cli/put_kg_core.py
|
|
@@ -36,6 +36,7 @@ tg-load-knowledge = trustgraph.cli.load_knowledge:main
|
|
|
36
36
|
tg-load-sample-documents = trustgraph.cli.load_sample_documents:main
|
|
37
37
|
tg-load-structured-data = trustgraph.cli.load_structured_data:main
|
|
38
38
|
tg-load-turtle = trustgraph.cli.load_turtle:main
|
|
39
|
+
tg-monitor-prompts = trustgraph.cli.monitor_prompts:main
|
|
39
40
|
tg-put-config-item = trustgraph.cli.put_config_item:main
|
|
40
41
|
tg-put-flow-blueprint = trustgraph.cli.put_flow_blueprint:main
|
|
41
42
|
tg-put-kg-core = trustgraph.cli.put_kg_core:main
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.1.25"
|
|
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_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/invoke_document_embeddings.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
|
|
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_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph/cli/show_extraction_provenance.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
|
{trustgraph_cli-2.1.25 → trustgraph_cli-2.1.27}/trustgraph_cli.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|