trustgraph-cli 2.11.7__tar.gz → 3.0.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.

Potentially problematic release.


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

Files changed (141) hide show
  1. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/PKG-INFO +2 -2
  2. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/pyproject.toml +7 -1
  3. trustgraph_cli-3.0.0/trustgraph/cli/invoke_action.py +229 -0
  4. trustgraph_cli-3.0.0/trustgraph/cli/invoke_concept_extraction.py +113 -0
  5. trustgraph_cli-3.0.0/trustgraph/cli/invoke_knowledge_retrieval.py +230 -0
  6. trustgraph_cli-3.0.0/trustgraph/cli/invoke_planner.py +138 -0
  7. trustgraph_cli-3.0.0/trustgraph/cli/invoke_policy.py +186 -0
  8. trustgraph_cli-3.0.0/trustgraph/cli/invoke_verification.py +142 -0
  9. trustgraph_cli-3.0.0/trustgraph/cli_version.py +1 -0
  10. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph_cli.egg-info/PKG-INFO +2 -2
  11. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph_cli.egg-info/SOURCES.txt +6 -0
  12. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph_cli.egg-info/entry_points.txt +6 -0
  13. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph_cli.egg-info/requires.txt +1 -1
  14. trustgraph_cli-2.11.7/trustgraph/cli_version.py +0 -1
  15. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/README.md +0 -0
  16. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/setup.cfg +0 -0
  17. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/__init__.py +0 -0
  18. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/_iam.py +0 -0
  19. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/add_library_document.py +0 -0
  20. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/bootstrap_iam.py +0 -0
  21. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/change_password.py +0 -0
  22. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/create_api_key.py +0 -0
  23. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/create_user.py +0 -0
  24. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/create_workspace.py +0 -0
  25. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/delete_collection.py +0 -0
  26. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/delete_config_item.py +0 -0
  27. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/delete_flow_blueprint.py +0 -0
  28. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/delete_kg_core.py +0 -0
  29. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/delete_mcp_tool.py +0 -0
  30. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/delete_ontology.py +0 -0
  31. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/delete_tool.py +0 -0
  32. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/delete_user.py +0 -0
  33. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/describe_image.py +0 -0
  34. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/disable_user.py +0 -0
  35. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/dump_msgpack.py +0 -0
  36. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/dump_queues.py +0 -0
  37. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/enable_user.py +0 -0
  38. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/export_workspace.py +0 -0
  39. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/export_workspace_config.py +0 -0
  40. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/get_config_item.py +0 -0
  41. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/get_de_core.py +0 -0
  42. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/get_document_content.py +0 -0
  43. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/get_flow_blueprint.py +0 -0
  44. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/get_kg_core.py +0 -0
  45. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/get_ontology.py +0 -0
  46. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/graph_to_turtle.py +0 -0
  47. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/import_workspace.py +0 -0
  48. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/import_workspace_config.py +0 -0
  49. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/init_pulsar_manager.py +0 -0
  50. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_agent.py +0 -0
  51. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_cloze.py +0 -0
  52. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_decision_scoring.py +0 -0
  53. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_document_embeddings.py +0 -0
  54. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_document_rag.py +0 -0
  55. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_embeddings.py +0 -0
  56. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_field_extraction.py +0 -0
  57. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_graph_embeddings.py +0 -0
  58. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_graph_rag.py +0 -0
  59. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_llm.py +0 -0
  60. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_mcp_tool.py +0 -0
  61. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_nl_sparql.py +0 -0
  62. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_nlp_query.py +0 -0
  63. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_ontology_subset.py +0 -0
  64. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_prompt.py +0 -0
  65. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_reranker.py +0 -0
  66. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_row_embeddings.py +0 -0
  67. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_rows_query.py +0 -0
  68. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_sparql_nl_query.py +0 -0
  69. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_sparql_query.py +0 -0
  70. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/invoke_structured_query.py +0 -0
  71. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/list_api_keys.py +0 -0
  72. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/list_cloze_models.py +0 -0
  73. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/list_collections.py +0 -0
  74. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/list_config_items.py +0 -0
  75. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/list_explain_traces.py +0 -0
  76. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/list_models.py +0 -0
  77. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/list_my_workspaces.py +0 -0
  78. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/list_ontologies.py +0 -0
  79. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/list_users.py +0 -0
  80. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/list_workspaces.py +0 -0
  81. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/load_doc_embeds.py +0 -0
  82. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/load_kg_core.py +0 -0
  83. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/load_knowledge.py +0 -0
  84. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/load_sample_documents.py +0 -0
  85. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/load_structured_data.py +0 -0
  86. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/load_turtle.py +0 -0
  87. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/login.py +0 -0
  88. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/mint_token.py +0 -0
  89. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/monitor_prompts.py +0 -0
  90. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/nquads.py +0 -0
  91. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/put_config_item.py +0 -0
  92. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/put_de_core.py +0 -0
  93. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/put_flow_blueprint.py +0 -0
  94. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/put_kg_core.py +0 -0
  95. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/put_ontology.py +0 -0
  96. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/query_graph.py +0 -0
  97. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/remove_library_document.py +0 -0
  98. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/reset_password.py +0 -0
  99. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/revoke_api_key.py +0 -0
  100. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/sample_documents/__init__.py +0 -0
  101. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/sample_documents/belgian-beer.md +0 -0
  102. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/sample_documents/bronze-age-collapse.pdf +0 -0
  103. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/sample_documents/corporate-scandals.pdf +0 -0
  104. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/sample_documents/history-of-pets.md +0 -0
  105. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/sample_documents/metadata.json +0 -0
  106. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/sample_documents/mil-fortifications-america-19th-c.md +0 -0
  107. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/sample_documents/recipes.md +0 -0
  108. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/sample_documents/trade-routes-europe.md +0 -0
  109. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/save_doc_embeds.py +0 -0
  110. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/set_collection.py +0 -0
  111. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/set_mcp_tool.py +0 -0
  112. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/set_prompt.py +0 -0
  113. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/set_token_costs.py +0 -0
  114. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/set_tool.py +0 -0
  115. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/show_config.py +0 -0
  116. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/show_explain_trace.py +0 -0
  117. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/show_extraction_provenance.py +0 -0
  118. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/show_flow_blueprints.py +0 -0
  119. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/show_flow_state.py +0 -0
  120. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/show_flows.py +0 -0
  121. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/show_graph.py +0 -0
  122. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/show_kg_cores.py +0 -0
  123. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/show_library_documents.py +0 -0
  124. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/show_library_processing.py +0 -0
  125. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/show_mcp_tools.py +0 -0
  126. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/show_parameter_types.py +0 -0
  127. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/show_processor_state.py +0 -0
  128. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/show_prompts.py +0 -0
  129. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/show_token_costs.py +0 -0
  130. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/show_token_rate.py +0 -0
  131. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/show_tools.py +0 -0
  132. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/start_flow.py +0 -0
  133. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/start_library_processing.py +0 -0
  134. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/stop_flow.py +0 -0
  135. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/stop_library_processing.py +0 -0
  136. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/unload_kg_core.py +0 -0
  137. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/update_user.py +0 -0
  138. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/verify_system_status.py +0 -0
  139. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph/cli/whoami.py +0 -0
  140. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/trustgraph_cli.egg-info/dependency_links.txt +0 -0
  141. {trustgraph_cli-2.11.7 → trustgraph_cli-3.0.0}/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.11.7
3
+ Version: 3.0.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
  Author-email: "trustgraph.ai" <security@trustgraph.ai>
6
6
  Project-URL: Homepage, https://github.com/trustgraph-ai/trustgraph
@@ -8,7 +8,7 @@ Classifier: Programming Language :: Python :: 3
8
8
  Classifier: Operating System :: OS Independent
9
9
  Requires-Python: >=3.10
10
10
  Description-Content-Type: text/markdown
11
- Requires-Dist: trustgraph-base<2.12,>=2.11
11
+ Requires-Dist: trustgraph-base<3.1,>=3.0
12
12
  Requires-Dist: requests
13
13
  Requires-Dist: pulsar-client
14
14
  Requires-Dist: aiohttp
@@ -10,7 +10,7 @@ description = "TrustGraph provides a means to run a pipeline of flexible AI proc
10
10
  readme = "README.md"
11
11
  requires-python = ">=3.10"
12
12
  dependencies = [
13
- "trustgraph-base>=2.11,<2.12",
13
+ "trustgraph-base>=3.0,<3.1",
14
14
  "requests",
15
15
  "pulsar-client",
16
16
  "aiohttp",
@@ -62,10 +62,16 @@ tg-list-my-workspaces = "trustgraph.cli.list_my_workspaces:main"
62
62
  tg-create-workspace = "trustgraph.cli.create_workspace:main"
63
63
  tg-list-models = "trustgraph.cli.list_models:main"
64
64
  tg-invoke-agent = "trustgraph.cli.invoke_agent:main"
65
+ tg-invoke-planner = "trustgraph.cli.invoke_planner:main"
66
+ tg-invoke-verification = "trustgraph.cli.invoke_verification:main"
67
+ tg-invoke-policy = "trustgraph.cli.invoke_policy:main"
68
+ tg-invoke-action = "trustgraph.cli.invoke_action:main"
65
69
  tg-invoke-document-rag = "trustgraph.cli.invoke_document_rag:main"
66
70
  tg-invoke-graph-rag = "trustgraph.cli.invoke_graph_rag:main"
67
71
  tg-invoke-llm = "trustgraph.cli.invoke_llm:main"
68
72
  tg-list-cloze-models = "trustgraph.cli.list_cloze_models:main"
73
+ tg-invoke-concept-extraction = "trustgraph.cli.invoke_concept_extraction:main"
74
+ tg-invoke-knowledge-retrieval = "trustgraph.cli.invoke_knowledge_retrieval:main"
69
75
  tg-invoke-cloze = "trustgraph.cli.invoke_cloze:main"
70
76
  tg-invoke-decision-scoring = "trustgraph.cli.invoke_decision_scoring:main"
71
77
  tg-invoke-field-extract = "trustgraph.cli.invoke_field_extraction:main"
@@ -0,0 +1,229 @@
1
+ """
2
+ Invoke the action worker with a capability and parameters.
3
+ Displays the resulting artifact.
4
+ """
5
+
6
+ import argparse
7
+ import json
8
+ import os
9
+ import sys
10
+ from trustgraph.api import Api
11
+
12
+ default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8888/')
13
+ default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
14
+ default_workspace = os.getenv("TRUSTGRAPH_WORKSPACE", "default")
15
+
16
+
17
+ def main():
18
+
19
+ parser = argparse.ArgumentParser(
20
+ prog='tg-invoke-action',
21
+ description=__doc__,
22
+ )
23
+
24
+ parser.add_argument(
25
+ '-u', '--url',
26
+ default=default_url,
27
+ help=f'API URL (default: {default_url})',
28
+ )
29
+
30
+ parser.add_argument(
31
+ '-t', '--token',
32
+ default=default_token,
33
+ help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
34
+ )
35
+
36
+ parser.add_argument(
37
+ '-w', '--workspace',
38
+ default=default_workspace,
39
+ help=f'Workspace (default: {default_workspace})',
40
+ )
41
+
42
+ parser.add_argument(
43
+ '-f', '--flow-id',
44
+ default="default",
45
+ help='Flow ID (default: default)',
46
+ )
47
+
48
+ parser.add_argument(
49
+ '-r', '--run-id',
50
+ default="run-cli",
51
+ help='Run ID (default: run-cli)',
52
+ )
53
+
54
+ parser.add_argument(
55
+ '-s', '--step-id',
56
+ default="step-cli",
57
+ help='Step ID (default: step-cli)',
58
+ )
59
+
60
+ parser.add_argument(
61
+ '-j', '--json',
62
+ action='store_true',
63
+ help='Output as JSON',
64
+ )
65
+
66
+ parser.add_argument(
67
+ '-p', '--param',
68
+ action='append',
69
+ default=[],
70
+ metavar='KEY=VALUE',
71
+ help='Step parameter (repeatable)',
72
+ )
73
+
74
+ parser.add_argument(
75
+ '-i', '--input-artifact',
76
+ action='append',
77
+ default=[],
78
+ metavar='TYPE:FILE',
79
+ help='Input artifact as TYPE:FILE e.g. TabularArtifact:data.json (repeatable)',
80
+ )
81
+
82
+ parser.add_argument(
83
+ 'capability',
84
+ help='Capability to invoke (e.g. erp-finance-query)',
85
+ )
86
+
87
+ args = parser.parse_args()
88
+
89
+ params = {}
90
+ for p in args.param:
91
+ if '=' not in p:
92
+ print(f"Error: parameter must be KEY=VALUE: {p}", file=sys.stderr)
93
+ sys.exit(1)
94
+ key, value = p.split('=', 1)
95
+ params[key] = value
96
+
97
+ input_artifacts = []
98
+ for spec in args.input_artifact:
99
+ if ':' not in spec:
100
+ print(
101
+ f"Error: input artifact must be TYPE:FILE: {spec}",
102
+ file=sys.stderr,
103
+ )
104
+ sys.exit(1)
105
+ artifact_type, path = spec.split(':', 1)
106
+ with open(path) as f:
107
+ input_artifacts.append({
108
+ "artifact-type": artifact_type,
109
+ "artifact": json.load(f),
110
+ })
111
+
112
+ try:
113
+
114
+ api = Api(
115
+ url=args.url, token=args.token, workspace=args.workspace,
116
+ )
117
+ socket = api.socket()
118
+
119
+ try:
120
+ result = socket._send_request_sync(
121
+ "action", args.flow_id,
122
+ {
123
+ "run-id": args.run_id,
124
+ "step-id": args.step_id,
125
+ "capability": args.capability,
126
+ "params": params,
127
+ "input-artifacts": input_artifacts,
128
+ },
129
+ )
130
+ finally:
131
+ socket.close()
132
+
133
+ if result.get("error"):
134
+ err = result["error"]
135
+ print(
136
+ f"Error: [{err.get('type', '?')}] {err.get('message', '?')}",
137
+ file=sys.stderr,
138
+ )
139
+ sys.exit(1)
140
+
141
+ if args.json:
142
+ print(json.dumps(result, indent=2))
143
+ else:
144
+ artifact_type = result.get("artifact-type", "?")
145
+ artifact = result.get("artifact", {})
146
+
147
+ print(f"Artifact type: {artifact_type}")
148
+ print()
149
+
150
+ if artifact_type == "TabularArtifact":
151
+ _print_tabular(artifact)
152
+ elif artifact_type == "TextBlobArtifact":
153
+ _print_text_blob(artifact)
154
+ elif artifact_type == "SubgraphArtifact":
155
+ _print_subgraph(artifact)
156
+ elif artifact_type == "ReportArtifact":
157
+ _print_report(artifact)
158
+ else:
159
+ print(json.dumps(artifact, indent=2))
160
+
161
+ except Exception as e:
162
+ print("Exception:", e, flush=True)
163
+ sys.exit(1)
164
+
165
+
166
+ def _print_tabular(artifact):
167
+ columns = artifact.get("columns", [])
168
+ rows = artifact.get("rows", [])
169
+ col_names = [c.get("name", "?") for c in columns]
170
+
171
+ if not col_names:
172
+ print("(empty table)")
173
+ return
174
+
175
+ try:
176
+ import tabulate
177
+ table = [
178
+ [row.get(c, "") for c in col_names]
179
+ for row in rows
180
+ ]
181
+ print(tabulate.tabulate(
182
+ table,
183
+ headers=col_names,
184
+ tablefmt="pretty",
185
+ stralign="left",
186
+ ))
187
+ except ImportError:
188
+ print(" | ".join(col_names))
189
+ print(" | ".join("---" for _ in col_names))
190
+ for row in rows:
191
+ print(" | ".join(str(row.get(c, "")) for c in col_names))
192
+
193
+ print(f"\n{len(rows)} rows")
194
+
195
+
196
+ def _print_text_blob(artifact):
197
+ text = artifact.get("text", "")
198
+ print(text)
199
+
200
+
201
+ def _print_subgraph(artifact):
202
+ triples = artifact.get("triples", [])
203
+ summary = artifact.get("summary", "")
204
+
205
+ if summary:
206
+ print("Summary:")
207
+ print(summary)
208
+ print()
209
+
210
+ print(f"Triples ({len(triples)}):")
211
+ for t in triples[:20]:
212
+ s = t.get("s", "?")
213
+ p = t.get("p", "?")
214
+ o = t.get("o", "?")
215
+ print(f" {s} {p} {o}")
216
+ if len(triples) > 20:
217
+ print(f" ... and {len(triples) - 20} more")
218
+
219
+
220
+ def _print_report(artifact):
221
+ fmt = artifact.get("format", "?")
222
+ narrative = artifact.get("narrative", "")
223
+ print(f"Format: {fmt}")
224
+ print()
225
+ print(narrative)
226
+
227
+
228
+ if __name__ == "__main__":
229
+ main()
@@ -0,0 +1,113 @@
1
+ """
2
+ Invoke the concept extraction service with a natural-language query.
3
+ Displays the extracted concepts.
4
+ """
5
+
6
+ import argparse
7
+ import json
8
+ import os
9
+ import sys
10
+ from trustgraph.api import Api
11
+
12
+ default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8888/')
13
+ default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
14
+ default_workspace = os.getenv("TRUSTGRAPH_WORKSPACE", "default")
15
+
16
+
17
+ def main():
18
+
19
+ parser = argparse.ArgumentParser(
20
+ prog='tg-invoke-concept-extraction',
21
+ description=__doc__,
22
+ )
23
+
24
+ parser.add_argument(
25
+ '-u', '--url',
26
+ default=default_url,
27
+ help=f'API URL (default: {default_url})',
28
+ )
29
+
30
+ parser.add_argument(
31
+ '-t', '--token',
32
+ default=default_token,
33
+ help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
34
+ )
35
+
36
+ parser.add_argument(
37
+ '-w', '--workspace',
38
+ default=default_workspace,
39
+ help=f'Workspace (default: {default_workspace})',
40
+ )
41
+
42
+ parser.add_argument(
43
+ '-f', '--flow-id',
44
+ default="default",
45
+ help='Flow ID (default: default)',
46
+ )
47
+
48
+ parser.add_argument(
49
+ '-j', '--json',
50
+ action='store_true',
51
+ help='Output as JSON',
52
+ )
53
+
54
+ parser.add_argument(
55
+ 'query',
56
+ nargs='?',
57
+ help='Query text (or read from stdin)',
58
+ )
59
+
60
+ args = parser.parse_args()
61
+
62
+ if args.query:
63
+ query = args.query
64
+ else:
65
+ if sys.stdin.isatty():
66
+ print("Enter query (Ctrl-D to finish):", file=sys.stderr)
67
+ query = sys.stdin.read().strip()
68
+
69
+ if not query:
70
+ print("Error: no query provided", file=sys.stderr)
71
+ sys.exit(1)
72
+
73
+ try:
74
+
75
+ api = Api(
76
+ url=args.url, token=args.token, workspace=args.workspace,
77
+ )
78
+ socket = api.socket()
79
+
80
+ try:
81
+ result = socket._send_request_sync(
82
+ "concept-extraction", args.flow_id,
83
+ {
84
+ "query": query,
85
+ },
86
+ )
87
+ finally:
88
+ socket.close()
89
+
90
+ if result.get("error"):
91
+ err = result["error"]
92
+ print(
93
+ f"Error: [{err.get('type', '?')}] {err.get('message', '?')}",
94
+ file=sys.stderr,
95
+ )
96
+ sys.exit(1)
97
+
98
+ if args.json:
99
+ print(json.dumps(result, indent=2))
100
+ else:
101
+ concepts = result.get("concepts", [])
102
+ print(f"Concepts ({len(concepts)}):")
103
+ print()
104
+ for i, concept in enumerate(concepts, 1):
105
+ print(f" {i}. {concept}")
106
+
107
+ except Exception as e:
108
+ print("Exception:", e, flush=True)
109
+ sys.exit(1)
110
+
111
+
112
+ if __name__ == "__main__":
113
+ main()
@@ -0,0 +1,230 @@
1
+ """
2
+ Invoke the knowledge retrieval service. Retrieves a ranked subgraph
3
+ from a query, concepts, or entity URIs.
4
+
5
+ By default, extracts concepts from the query string using the
6
+ concept extraction service, then retrieves matching edges.
7
+ Use -c to provide concepts directly, or -e to provide entity URIs.
8
+ """
9
+
10
+ import argparse
11
+ import json
12
+ import os
13
+ import sys
14
+ from trustgraph.api import Api
15
+
16
+ default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8888/')
17
+ default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
18
+ default_workspace = os.getenv("TRUSTGRAPH_WORKSPACE", "default")
19
+
20
+
21
+ def main():
22
+
23
+ parser = argparse.ArgumentParser(
24
+ prog='tg-invoke-knowledge-retrieval',
25
+ description=__doc__,
26
+ )
27
+
28
+ parser.add_argument(
29
+ '-u', '--url',
30
+ default=default_url,
31
+ help=f'API URL (default: {default_url})',
32
+ )
33
+
34
+ parser.add_argument(
35
+ '-t', '--token',
36
+ default=default_token,
37
+ help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
38
+ )
39
+
40
+ parser.add_argument(
41
+ '-w', '--workspace',
42
+ default=default_workspace,
43
+ help=f'Workspace (default: {default_workspace})',
44
+ )
45
+
46
+ parser.add_argument(
47
+ '-f', '--flow-id',
48
+ default="default",
49
+ help='Flow ID (default: default)',
50
+ )
51
+
52
+ parser.add_argument(
53
+ '-j', '--json',
54
+ action='store_true',
55
+ help='Output as JSON',
56
+ )
57
+
58
+ parser.add_argument(
59
+ '-T', '--turtle',
60
+ action='store_true',
61
+ help='Output as Turtle RDF',
62
+ )
63
+
64
+ parser.add_argument(
65
+ '-L', '--jsonld',
66
+ action='store_true',
67
+ help='Output as JSON-LD',
68
+ )
69
+
70
+ parser.add_argument(
71
+ '-c', '--concept',
72
+ action='append',
73
+ dest='concepts',
74
+ default=[],
75
+ help='Concept to search for, skips extraction (repeatable)',
76
+ )
77
+
78
+ parser.add_argument(
79
+ '-e', '--entity',
80
+ action='append',
81
+ dest='entities',
82
+ default=[],
83
+ help='Entity URI to traverse from, skips embedding (repeatable)',
84
+ )
85
+
86
+ parser.add_argument(
87
+ '--entity-limit',
88
+ type=int, default=50,
89
+ help='Max entities from embedding search (default: 50)',
90
+ )
91
+
92
+ parser.add_argument(
93
+ '--edge-limit',
94
+ type=int, default=25,
95
+ help='Max edges returned (default: 25)',
96
+ )
97
+
98
+ parser.add_argument(
99
+ '--max-hops',
100
+ type=int, default=2,
101
+ help='Max traversal hops (default: 2)',
102
+ )
103
+
104
+ parser.add_argument(
105
+ 'query',
106
+ nargs='?',
107
+ help='Query text (extracts concepts automatically)',
108
+ )
109
+
110
+ args = parser.parse_args()
111
+
112
+ if not args.query and not args.concepts and not args.entities:
113
+ print(
114
+ "Error: provide a query, --concept, or --entity",
115
+ file=sys.stderr,
116
+ )
117
+ sys.exit(1)
118
+
119
+ try:
120
+
121
+ api = Api(
122
+ url=args.url, token=args.token, workspace=args.workspace,
123
+ )
124
+ socket = api.socket()
125
+
126
+ try:
127
+
128
+ concepts = list(args.concepts)
129
+
130
+ # If a query is provided and no explicit concepts/entities,
131
+ # call concept extraction first
132
+ if args.query and not concepts and not args.entities:
133
+ print(
134
+ f"Extracting concepts from query...",
135
+ file=sys.stderr,
136
+ )
137
+ ce_result = socket._send_request_sync(
138
+ "concept-extraction", args.flow_id,
139
+ {"query": args.query},
140
+ )
141
+ if ce_result.get("error"):
142
+ err = ce_result["error"]
143
+ print(
144
+ f"Error: [{err.get('type', '?')}] "
145
+ f"{err.get('message', '?')}",
146
+ file=sys.stderr,
147
+ )
148
+ sys.exit(1)
149
+
150
+ concepts = ce_result.get("concepts", [])
151
+ print(
152
+ f"Concepts: {', '.join(concepts)}",
153
+ file=sys.stderr,
154
+ )
155
+
156
+ request = {}
157
+ if concepts:
158
+ request["concepts"] = concepts
159
+ if args.entities:
160
+ request["entities"] = args.entities
161
+ if args.entity_limit != 50:
162
+ request["entity-limit"] = args.entity_limit
163
+ if args.edge_limit != 25:
164
+ request["edge-limit"] = args.edge_limit
165
+ if args.max_hops != 2:
166
+ request["max-path-length"] = args.max_hops
167
+
168
+ result = socket._send_request_sync(
169
+ "knowledge-retrieval", args.flow_id,
170
+ request,
171
+ )
172
+
173
+ finally:
174
+ socket.close()
175
+
176
+ if result.get("error"):
177
+ err = result["error"]
178
+ print(
179
+ f"Error: [{err.get('type', '?')}] {err.get('message', '?')}",
180
+ file=sys.stderr,
181
+ )
182
+ sys.exit(1)
183
+
184
+ if args.json:
185
+ print(json.dumps(result, indent=2))
186
+ elif args.turtle or args.jsonld:
187
+ from rdflib import Graph, URIRef, Literal, Namespace
188
+ g = Graph()
189
+ edges = result.get("edges", [])
190
+ for e in edges:
191
+ s_val = e.get("s", "")
192
+ p_val = e.get("p", "")
193
+ o_val = e.get("o", "")
194
+ s = URIRef(s_val) if s_val.startswith(("http://", "https://", "urn:")) else Literal(s_val)
195
+ p = URIRef(p_val) if p_val.startswith(("http://", "https://", "urn:")) else URIRef(f"urn:predicate:{p_val}")
196
+ o = URIRef(o_val) if o_val.startswith(("http://", "https://", "urn:")) else Literal(o_val)
197
+ g.add((s, p, o))
198
+ fmt = "json-ld" if args.jsonld else "turtle"
199
+ print(g.serialize(format=fmt))
200
+ else:
201
+ edges = result.get("edges", [])
202
+ seeds = result.get("seed-entities", [])
203
+ concepts = result.get("concepts", [])
204
+
205
+ print(f"Concepts: {', '.join(concepts)}")
206
+ print(f"Seed entities: {len(seeds)}")
207
+ print(f"Edges: {len(edges)}")
208
+ print()
209
+
210
+ for i, e in enumerate(edges, 1):
211
+ s_label = e.get("s-label", e.get("s", "?"))
212
+ p_label = e.get("p-label", e.get("p", "?"))
213
+ o_label = e.get("o-label", e.get("o", "?"))
214
+ score = e.get("score", 0)
215
+ concept = e.get("concept", "")
216
+
217
+ print(f" {i:3d}. [{score:.4f}] {s_label}")
218
+ print(f" -- {p_label} -->")
219
+ print(f" {o_label}")
220
+ if concept:
221
+ print(f" (concept: {concept})")
222
+ print()
223
+
224
+ except Exception as e:
225
+ print("Exception:", e, flush=True)
226
+ sys.exit(1)
227
+
228
+
229
+ if __name__ == "__main__":
230
+ main()