trustgraph-cli 1.3.1__tar.gz → 1.3.3__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.

Potentially problematic release.


This version of trustgraph-cli might be problematic. Click here for more details.

Files changed (69) hide show
  1. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/PKG-INFO +1 -1
  2. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/pyproject.toml +1 -0
  3. trustgraph_cli-1.3.3/trustgraph/cli/invoke_objects_query.py +201 -0
  4. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/set_tool.py +29 -0
  5. trustgraph_cli-1.3.3/trustgraph/cli_version.py +1 -0
  6. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph_cli.egg-info/PKG-INFO +1 -1
  7. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph_cli.egg-info/SOURCES.txt +1 -0
  8. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph_cli.egg-info/entry_points.txt +1 -0
  9. trustgraph_cli-1.3.1/trustgraph/cli_version.py +0 -1
  10. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/README.md +0 -0
  11. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/setup.cfg +0 -0
  12. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/__init__.py +0 -0
  13. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/add_library_document.py +0 -0
  14. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/delete_config_item.py +0 -0
  15. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/delete_flow_class.py +0 -0
  16. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/delete_kg_core.py +0 -0
  17. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/delete_mcp_tool.py +0 -0
  18. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/delete_tool.py +0 -0
  19. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/dump_msgpack.py +0 -0
  20. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/get_config_item.py +0 -0
  21. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/get_flow_class.py +0 -0
  22. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/get_kg_core.py +0 -0
  23. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/graph_to_turtle.py +0 -0
  24. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/init_pulsar_manager.py +0 -0
  25. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/init_trustgraph.py +0 -0
  26. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/invoke_agent.py +0 -0
  27. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/invoke_document_rag.py +0 -0
  28. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/invoke_graph_rag.py +0 -0
  29. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/invoke_llm.py +0 -0
  30. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/invoke_mcp_tool.py +0 -0
  31. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/invoke_prompt.py +0 -0
  32. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/list_config_items.py +0 -0
  33. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/load_doc_embeds.py +0 -0
  34. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/load_kg_core.py +0 -0
  35. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/load_knowledge.py +0 -0
  36. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/load_pdf.py +0 -0
  37. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/load_sample_documents.py +0 -0
  38. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/load_text.py +0 -0
  39. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/load_turtle.py +0 -0
  40. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/put_config_item.py +0 -0
  41. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/put_flow_class.py +0 -0
  42. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/put_kg_core.py +0 -0
  43. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/remove_library_document.py +0 -0
  44. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/save_doc_embeds.py +0 -0
  45. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/set_mcp_tool.py +0 -0
  46. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/set_prompt.py +0 -0
  47. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/set_token_costs.py +0 -0
  48. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/show_config.py +0 -0
  49. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/show_flow_classes.py +0 -0
  50. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/show_flow_state.py +0 -0
  51. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/show_flows.py +0 -0
  52. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/show_graph.py +0 -0
  53. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/show_kg_cores.py +0 -0
  54. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/show_library_documents.py +0 -0
  55. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/show_library_processing.py +0 -0
  56. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/show_mcp_tools.py +0 -0
  57. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/show_processor_state.py +0 -0
  58. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/show_prompts.py +0 -0
  59. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/show_token_costs.py +0 -0
  60. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/show_token_rate.py +0 -0
  61. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/show_tools.py +0 -0
  62. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/start_flow.py +0 -0
  63. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/start_library_processing.py +0 -0
  64. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/stop_flow.py +0 -0
  65. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/stop_library_processing.py +0 -0
  66. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph/cli/unload_kg_core.py +0 -0
  67. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph_cli.egg-info/dependency_links.txt +0 -0
  68. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/trustgraph_cli.egg-info/requires.txt +0 -0
  69. {trustgraph_cli-1.3.1 → trustgraph_cli-1.3.3}/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: 1.3.1
3
+ Version: 1.3.3
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
@@ -43,6 +43,7 @@ tg-invoke-document-rag = "trustgraph.cli.invoke_document_rag:main"
43
43
  tg-invoke-graph-rag = "trustgraph.cli.invoke_graph_rag:main"
44
44
  tg-invoke-llm = "trustgraph.cli.invoke_llm:main"
45
45
  tg-invoke-mcp-tool = "trustgraph.cli.invoke_mcp_tool:main"
46
+ tg-invoke-objects-query = "trustgraph.cli.invoke_objects_query:main"
46
47
  tg-invoke-prompt = "trustgraph.cli.invoke_prompt:main"
47
48
  tg-load-doc-embeds = "trustgraph.cli.load_doc_embeds:main"
48
49
  tg-load-kg-core = "trustgraph.cli.load_kg_core:main"
@@ -0,0 +1,201 @@
1
+ """
2
+ Uses the ObjectsQuery service to execute GraphQL queries against structured data
3
+ """
4
+
5
+ import argparse
6
+ import os
7
+ import json
8
+ import sys
9
+ import csv
10
+ import io
11
+ from trustgraph.api import Api
12
+ from tabulate import tabulate
13
+
14
+ default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
15
+ default_user = 'trustgraph'
16
+ default_collection = 'default'
17
+
18
+ def format_output(data, output_format):
19
+ """Format GraphQL response data in the specified format"""
20
+ if not data:
21
+ return "No data returned"
22
+
23
+ # Handle case where data contains multiple query results
24
+ if len(data) == 1:
25
+ # Single query result - extract the list
26
+ query_name, result_list = next(iter(data.items()))
27
+ if isinstance(result_list, list):
28
+ return format_table_data(result_list, query_name, output_format)
29
+
30
+ # Multiple queries or non-list data - use JSON format
31
+ if output_format == 'json':
32
+ return json.dumps(data, indent=2)
33
+ else:
34
+ return json.dumps(data, indent=2) # Fallback to JSON
35
+
36
+ def format_table_data(rows, table_name, output_format):
37
+ """Format a list of rows in the specified format"""
38
+ if not rows:
39
+ return f"No {table_name} found"
40
+
41
+ if output_format == 'json':
42
+ return json.dumps({table_name: rows}, indent=2)
43
+
44
+ elif output_format == 'csv':
45
+ # Get field names in order from first row, then add any missing ones
46
+ fieldnames = list(rows[0].keys()) if rows else []
47
+ # Add any additional fields from other rows that might be missing
48
+ all_fields = set(fieldnames)
49
+ for row in rows:
50
+ for field in row.keys():
51
+ if field not in all_fields:
52
+ fieldnames.append(field)
53
+ all_fields.add(field)
54
+
55
+ # Create CSV string
56
+ output = io.StringIO()
57
+ writer = csv.DictWriter(output, fieldnames=fieldnames)
58
+ writer.writeheader()
59
+ writer.writerows(rows)
60
+ return output.getvalue().rstrip()
61
+
62
+ elif output_format == 'table':
63
+ # Get field names in order from first row, then add any missing ones
64
+ fieldnames = list(rows[0].keys()) if rows else []
65
+ # Add any additional fields from other rows that might be missing
66
+ all_fields = set(fieldnames)
67
+ for row in rows:
68
+ for field in row.keys():
69
+ if field not in all_fields:
70
+ fieldnames.append(field)
71
+ all_fields.add(field)
72
+
73
+ # Create table data
74
+ table_data = []
75
+ for row in rows:
76
+ table_row = [row.get(field, '') for field in fieldnames]
77
+ table_data.append(table_row)
78
+
79
+ return tabulate(table_data, headers=fieldnames, tablefmt='pretty')
80
+
81
+ else:
82
+ return json.dumps({table_name: rows}, indent=2)
83
+
84
+ def objects_query(
85
+ url, flow_id, query, user, collection, variables, operation_name, output_format='table'
86
+ ):
87
+
88
+ api = Api(url).flow().id(flow_id)
89
+
90
+ # Parse variables if provided as JSON string
91
+ parsed_variables = {}
92
+ if variables:
93
+ try:
94
+ parsed_variables = json.loads(variables)
95
+ except json.JSONDecodeError as e:
96
+ print(f"Error parsing variables JSON: {e}", file=sys.stderr)
97
+ sys.exit(1)
98
+
99
+ resp = api.objects_query(
100
+ query=query,
101
+ user=user,
102
+ collection=collection,
103
+ variables=parsed_variables if parsed_variables else None,
104
+ operation_name=operation_name
105
+ )
106
+
107
+ # Check for GraphQL errors
108
+ if "errors" in resp and resp["errors"]:
109
+ print("GraphQL Errors:", file=sys.stderr)
110
+ for error in resp["errors"]:
111
+ print(f" - {error.get('message', 'Unknown error')}", file=sys.stderr)
112
+ if "path" in error and error["path"]:
113
+ print(f" Path: {error['path']}", file=sys.stderr)
114
+ # Still print data if available
115
+ if "data" in resp and resp["data"]:
116
+ print(format_output(resp["data"], output_format))
117
+ sys.exit(1)
118
+
119
+ # Print the data
120
+ if "data" in resp:
121
+ print(format_output(resp["data"], output_format))
122
+ else:
123
+ print("No data returned", file=sys.stderr)
124
+ sys.exit(1)
125
+
126
+ def main():
127
+
128
+ parser = argparse.ArgumentParser(
129
+ prog='tg-invoke-objects-query',
130
+ description=__doc__,
131
+ )
132
+
133
+ parser.add_argument(
134
+ '-u', '--url',
135
+ default=default_url,
136
+ help=f'API URL (default: {default_url})',
137
+ )
138
+
139
+ parser.add_argument(
140
+ '-f', '--flow-id',
141
+ default="default",
142
+ help=f'Flow ID (default: default)'
143
+ )
144
+
145
+ parser.add_argument(
146
+ '-q', '--query',
147
+ required=True,
148
+ help='GraphQL query to execute',
149
+ )
150
+
151
+ parser.add_argument(
152
+ '-U', '--user',
153
+ default=default_user,
154
+ help=f'User ID (default: {default_user})'
155
+ )
156
+
157
+ parser.add_argument(
158
+ '-C', '--collection',
159
+ default=default_collection,
160
+ help=f'Collection ID (default: {default_collection})'
161
+ )
162
+
163
+ parser.add_argument(
164
+ '-v', '--variables',
165
+ help='GraphQL variables as JSON string (e.g., \'{"limit": 5}\')'
166
+ )
167
+
168
+ parser.add_argument(
169
+ '-o', '--operation-name',
170
+ help='Operation name for multi-operation GraphQL documents'
171
+ )
172
+
173
+ parser.add_argument(
174
+ '--format',
175
+ choices=['table', 'json', 'csv'],
176
+ default='table',
177
+ help='Output format (default: table)'
178
+ )
179
+
180
+ args = parser.parse_args()
181
+
182
+ try:
183
+
184
+ objects_query(
185
+ url=args.url,
186
+ flow_id=args.flow_id,
187
+ query=args.query,
188
+ user=args.user,
189
+ collection=args.collection,
190
+ variables=args.variables,
191
+ operation_name=args.operation_name,
192
+ output_format=args.format,
193
+ )
194
+
195
+ except Exception as e:
196
+
197
+ print("Exception:", e, flush=True, file=sys.stderr)
198
+ sys.exit(1)
199
+
200
+ if __name__ == "__main__":
201
+ main()
@@ -63,6 +63,9 @@ def set_tool(
63
63
  collection : str,
64
64
  template : str,
65
65
  arguments : List[Argument],
66
+ group : List[str],
67
+ state : str,
68
+ applicable_states : List[str],
66
69
  ):
67
70
 
68
71
  api = Api(url).config()
@@ -93,6 +96,12 @@ def set_tool(
93
96
  for a in arguments
94
97
  ]
95
98
 
99
+ if group: object["group"] = group
100
+
101
+ if state: object["state"] = state
102
+
103
+ if applicable_states: object["applicable-states"] = applicable_states
104
+
96
105
  values = api.put([
97
106
  ConfigValue(
98
107
  type="tool", key=f"{id}", value=json.dumps(object)
@@ -179,6 +188,23 @@ def main():
179
188
  help=f'Tool arguments in the form: name:type:description (can specify multiple)',
180
189
  )
181
190
 
191
+ parser.add_argument(
192
+ '--group',
193
+ nargs="*",
194
+ help=f'Tool groups (e.g., read-only, knowledge, admin)',
195
+ )
196
+
197
+ parser.add_argument(
198
+ '--state',
199
+ help=f'State to transition to after successful execution',
200
+ )
201
+
202
+ parser.add_argument(
203
+ '--applicable-states',
204
+ nargs="*",
205
+ help=f'States in which this tool is available',
206
+ )
207
+
182
208
  args = parser.parse_args()
183
209
 
184
210
  try:
@@ -219,6 +245,9 @@ def main():
219
245
  collection=args.collection,
220
246
  template=args.template,
221
247
  arguments=arguments,
248
+ group=args.group or [],
249
+ state=args.state,
250
+ applicable_states=getattr(args, 'applicable_states', None) or [],
222
251
  )
223
252
 
224
253
  except Exception as e:
@@ -0,0 +1 @@
1
+ __version__ = "1.3.3"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trustgraph-cli
3
- Version: 1.3.1
3
+ Version: 1.3.3
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
@@ -20,6 +20,7 @@ trustgraph/cli/invoke_document_rag.py
20
20
  trustgraph/cli/invoke_graph_rag.py
21
21
  trustgraph/cli/invoke_llm.py
22
22
  trustgraph/cli/invoke_mcp_tool.py
23
+ trustgraph/cli/invoke_objects_query.py
23
24
  trustgraph/cli/invoke_prompt.py
24
25
  trustgraph/cli/list_config_items.py
25
26
  trustgraph/cli/load_doc_embeds.py
@@ -16,6 +16,7 @@ tg-invoke-document-rag = trustgraph.cli.invoke_document_rag:main
16
16
  tg-invoke-graph-rag = trustgraph.cli.invoke_graph_rag:main
17
17
  tg-invoke-llm = trustgraph.cli.invoke_llm:main
18
18
  tg-invoke-mcp-tool = trustgraph.cli.invoke_mcp_tool:main
19
+ tg-invoke-objects-query = trustgraph.cli.invoke_objects_query:main
19
20
  tg-invoke-prompt = trustgraph.cli.invoke_prompt:main
20
21
  tg-list-config-items = trustgraph.cli.list_config_items:main
21
22
  tg-load-doc-embeds = trustgraph.cli.load_doc_embeds:main
@@ -1 +0,0 @@
1
- __version__ = "1.3.1"
File without changes
File without changes