trustgraph-base 1.3.6__tar.gz → 1.3.8__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.
Files changed (129) hide show
  1. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/PKG-INFO +1 -1
  2. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/api/flow.py +59 -0
  3. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/__init__.py +1 -0
  4. trustgraph_base-1.3.8/trustgraph/base/structured_query_client.py +33 -0
  5. trustgraph_base-1.3.8/trustgraph/base_version.py +1 -0
  6. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/__init__.py +14 -0
  7. trustgraph_base-1.3.8/trustgraph/messaging/translators/nlp_query.py +47 -0
  8. trustgraph_base-1.3.8/trustgraph/messaging/translators/structured_query.py +56 -0
  9. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/services/structured_query.py +2 -4
  10. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph_base.egg-info/PKG-INFO +1 -1
  11. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph_base.egg-info/SOURCES.txt +3 -0
  12. trustgraph_base-1.3.6/trustgraph/base_version.py +0 -1
  13. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/README.md +0 -0
  14. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/pyproject.toml +0 -0
  15. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/setup.cfg +0 -0
  16. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/api/__init__.py +0 -0
  17. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/api/api.py +0 -0
  18. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/api/config.py +0 -0
  19. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/api/exceptions.py +0 -0
  20. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/api/knowledge.py +0 -0
  21. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/api/library.py +0 -0
  22. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/api/types.py +0 -0
  23. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/agent_client.py +0 -0
  24. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/agent_service.py +0 -0
  25. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/async_processor.py +0 -0
  26. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/cassandra_config.py +0 -0
  27. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/consumer.py +0 -0
  28. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/consumer_spec.py +0 -0
  29. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/document_embeddings_client.py +0 -0
  30. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/document_embeddings_query_service.py +0 -0
  31. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/document_embeddings_store_service.py +0 -0
  32. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/embeddings_client.py +0 -0
  33. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/embeddings_service.py +0 -0
  34. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/flow.py +0 -0
  35. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/flow_processor.py +0 -0
  36. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/graph_embeddings_client.py +0 -0
  37. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/graph_embeddings_query_service.py +0 -0
  38. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/graph_embeddings_store_service.py +0 -0
  39. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/graph_rag_client.py +0 -0
  40. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/llm_service.py +0 -0
  41. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/metrics.py +0 -0
  42. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/producer.py +0 -0
  43. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/producer_spec.py +0 -0
  44. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/prompt_client.py +0 -0
  45. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/publisher.py +0 -0
  46. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/pubsub.py +0 -0
  47. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/request_response_spec.py +0 -0
  48. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/setting_spec.py +0 -0
  49. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/spec.py +0 -0
  50. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/subscriber.py +0 -0
  51. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/subscriber_spec.py +0 -0
  52. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/text_completion_client.py +0 -0
  53. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/tool_client.py +0 -0
  54. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/tool_service.py +0 -0
  55. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/triples_client.py +0 -0
  56. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/triples_query_service.py +0 -0
  57. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/base/triples_store_service.py +0 -0
  58. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/clients/__init__.py +0 -0
  59. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/clients/agent_client.py +0 -0
  60. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/clients/base.py +0 -0
  61. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/clients/config_client.py +0 -0
  62. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/clients/document_embeddings_client.py +0 -0
  63. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/clients/document_rag_client.py +0 -0
  64. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/clients/embeddings_client.py +0 -0
  65. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/clients/graph_embeddings_client.py +0 -0
  66. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/clients/graph_rag_client.py +0 -0
  67. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/clients/llm_client.py +0 -0
  68. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/clients/prompt_client.py +0 -0
  69. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/clients/triples_query_client.py +0 -0
  70. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/exceptions.py +0 -0
  71. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/knowledge/__init__.py +0 -0
  72. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/knowledge/defs.py +0 -0
  73. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/knowledge/document.py +0 -0
  74. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/knowledge/identifier.py +0 -0
  75. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/knowledge/organization.py +0 -0
  76. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/knowledge/publication.py +0 -0
  77. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/log_level.py +0 -0
  78. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/registry.py +0 -0
  79. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/translators/__init__.py +0 -0
  80. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/translators/agent.py +0 -0
  81. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/translators/base.py +0 -0
  82. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/translators/config.py +0 -0
  83. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/translators/document_loading.py +0 -0
  84. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/translators/embeddings.py +0 -0
  85. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/translators/embeddings_query.py +0 -0
  86. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/translators/flow.py +0 -0
  87. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/translators/knowledge.py +0 -0
  88. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/translators/library.py +0 -0
  89. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/translators/metadata.py +0 -0
  90. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/translators/objects_query.py +0 -0
  91. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/translators/primitives.py +0 -0
  92. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/translators/prompt.py +0 -0
  93. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/translators/retrieval.py +0 -0
  94. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/translators/text_completion.py +0 -0
  95. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/translators/tool.py +0 -0
  96. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/messaging/translators/triples.py +0 -0
  97. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/objects/__init__.py +0 -0
  98. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/objects/field.py +0 -0
  99. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/objects/object.py +0 -0
  100. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/rdf.py +0 -0
  101. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/__init__.py +0 -0
  102. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/core/__init__.py +0 -0
  103. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/core/metadata.py +0 -0
  104. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/core/primitives.py +0 -0
  105. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/core/topic.py +0 -0
  106. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/knowledge/__init__.py +0 -0
  107. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/knowledge/document.py +0 -0
  108. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/knowledge/embeddings.py +0 -0
  109. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/knowledge/graph.py +0 -0
  110. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/knowledge/knowledge.py +0 -0
  111. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/knowledge/nlp.py +0 -0
  112. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/knowledge/object.py +0 -0
  113. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/knowledge/rows.py +0 -0
  114. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/knowledge/structured.py +0 -0
  115. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/services/__init__.py +0 -0
  116. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/services/agent.py +0 -0
  117. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/services/config.py +0 -0
  118. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/services/flow.py +0 -0
  119. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/services/library.py +0 -0
  120. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/services/llm.py +0 -0
  121. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/services/lookup.py +0 -0
  122. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/services/nlp_query.py +0 -0
  123. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/services/objects_query.py +0 -0
  124. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/services/prompt.py +0 -0
  125. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/services/query.py +0 -0
  126. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph/schema/services/retrieval.py +0 -0
  127. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph_base.egg-info/dependency_links.txt +0 -0
  128. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/trustgraph_base.egg-info/requires.txt +0 -0
  129. {trustgraph_base-1.3.6 → trustgraph_base-1.3.8}/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.3.6
3
+ Version: 1.3.8
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
@@ -426,3 +426,62 @@ class FlowInstance:
426
426
 
427
427
  return result
428
428
 
429
+ def nlp_query(self, question, max_results=100):
430
+ """
431
+ Convert a natural language question to a GraphQL query.
432
+
433
+ Args:
434
+ question: Natural language question
435
+ max_results: Maximum number of results to return (default: 100)
436
+
437
+ Returns:
438
+ dict with graphql_query, variables, detected_schemas, confidence
439
+ """
440
+
441
+ input = {
442
+ "question": question,
443
+ "max_results": max_results
444
+ }
445
+
446
+ response = self.request(
447
+ "service/nlp-query",
448
+ input
449
+ )
450
+
451
+ # Check for system-level error
452
+ if "error" in response and response["error"]:
453
+ error_type = response["error"].get("type", "unknown")
454
+ error_message = response["error"].get("message", "Unknown error")
455
+ raise ProtocolException(f"{error_type}: {error_message}")
456
+
457
+ return response
458
+
459
+ def structured_query(self, question):
460
+ """
461
+ Execute a natural language question against structured data.
462
+ Combines NLP query conversion and GraphQL execution.
463
+
464
+ Args:
465
+ question: Natural language question
466
+
467
+ Returns:
468
+ dict with data and optional errors
469
+ """
470
+
471
+ input = {
472
+ "question": question
473
+ }
474
+
475
+ response = self.request(
476
+ "service/structured-query",
477
+ input
478
+ )
479
+
480
+ # Check for system-level error
481
+ if "error" in response and response["error"]:
482
+ error_type = response["error"].get("type", "unknown")
483
+ error_message = response["error"].get("message", "Unknown error")
484
+ raise ProtocolException(f"{error_type}: {error_message}")
485
+
486
+ return response
487
+
@@ -31,4 +31,5 @@ from . graph_rag_client import GraphRagClientSpec
31
31
  from . tool_service import ToolService
32
32
  from . tool_client import ToolClientSpec
33
33
  from . agent_client import AgentClientSpec
34
+ from . structured_query_client import StructuredQueryClientSpec
34
35
 
@@ -0,0 +1,33 @@
1
+ from . request_response_spec import RequestResponse, RequestResponseSpec
2
+ from .. schema import StructuredQueryRequest, StructuredQueryResponse
3
+
4
+ class StructuredQueryClient(RequestResponse):
5
+ async def structured_query(self, question, timeout=600):
6
+ resp = await self.request(
7
+ StructuredQueryRequest(
8
+ question = question
9
+ ),
10
+ timeout=timeout
11
+ )
12
+
13
+ if resp.error:
14
+ raise RuntimeError(resp.error.message)
15
+
16
+ # Return the full response structure for the tool to handle
17
+ return {
18
+ "data": resp.data,
19
+ "errors": resp.errors if resp.errors else [],
20
+ "error": resp.error
21
+ }
22
+
23
+ class StructuredQueryClientSpec(RequestResponseSpec):
24
+ def __init__(
25
+ self, request_name, response_name,
26
+ ):
27
+ super(StructuredQueryClientSpec, self).__init__(
28
+ request_name = request_name,
29
+ request_schema = StructuredQueryRequest,
30
+ response_name = response_name,
31
+ response_schema = StructuredQueryResponse,
32
+ impl = StructuredQueryClient,
33
+ )
@@ -0,0 +1 @@
1
+ __version__ = "1.3.8"
@@ -22,6 +22,8 @@ from .translators.embeddings_query import (
22
22
  GraphEmbeddingsRequestTranslator, GraphEmbeddingsResponseTranslator
23
23
  )
24
24
  from .translators.objects_query import ObjectsQueryRequestTranslator, ObjectsQueryResponseTranslator
25
+ from .translators.nlp_query import QuestionToStructuredQueryRequestTranslator, QuestionToStructuredQueryResponseTranslator
26
+ from .translators.structured_query import StructuredQueryRequestTranslator, StructuredQueryResponseTranslator
25
27
 
26
28
  # Register all service translators
27
29
  TranslatorRegistry.register_service(
@@ -114,6 +116,18 @@ TranslatorRegistry.register_service(
114
116
  ObjectsQueryResponseTranslator()
115
117
  )
116
118
 
119
+ TranslatorRegistry.register_service(
120
+ "nlp-query",
121
+ QuestionToStructuredQueryRequestTranslator(),
122
+ QuestionToStructuredQueryResponseTranslator()
123
+ )
124
+
125
+ TranslatorRegistry.register_service(
126
+ "structured-query",
127
+ StructuredQueryRequestTranslator(),
128
+ StructuredQueryResponseTranslator()
129
+ )
130
+
117
131
  # Register single-direction translators for document loading
118
132
  TranslatorRegistry.register_request("document", DocumentTranslator())
119
133
  TranslatorRegistry.register_request("text-document", TextDocumentTranslator())
@@ -0,0 +1,47 @@
1
+ from typing import Dict, Any, Tuple
2
+ from ...schema import QuestionToStructuredQueryRequest, QuestionToStructuredQueryResponse
3
+ from .base import MessageTranslator
4
+
5
+
6
+ class QuestionToStructuredQueryRequestTranslator(MessageTranslator):
7
+ """Translator for QuestionToStructuredQueryRequest schema objects"""
8
+
9
+ def to_pulsar(self, data: Dict[str, Any]) -> QuestionToStructuredQueryRequest:
10
+ return QuestionToStructuredQueryRequest(
11
+ question=data.get("question", ""),
12
+ max_results=data.get("max_results", 100)
13
+ )
14
+
15
+ def from_pulsar(self, obj: QuestionToStructuredQueryRequest) -> Dict[str, Any]:
16
+ return {
17
+ "question": obj.question,
18
+ "max_results": obj.max_results
19
+ }
20
+
21
+
22
+ class QuestionToStructuredQueryResponseTranslator(MessageTranslator):
23
+ """Translator for QuestionToStructuredQueryResponse schema objects"""
24
+
25
+ def to_pulsar(self, data: Dict[str, Any]) -> QuestionToStructuredQueryResponse:
26
+ raise NotImplementedError("Response translation to Pulsar not typically needed")
27
+
28
+ def from_pulsar(self, obj: QuestionToStructuredQueryResponse) -> Dict[str, Any]:
29
+ result = {
30
+ "graphql_query": obj.graphql_query,
31
+ "variables": dict(obj.variables) if obj.variables else {},
32
+ "detected_schemas": list(obj.detected_schemas) if obj.detected_schemas else [],
33
+ "confidence": obj.confidence
34
+ }
35
+
36
+ # Handle system-level error
37
+ if obj.error:
38
+ result["error"] = {
39
+ "type": obj.error.type,
40
+ "message": obj.error.message
41
+ }
42
+
43
+ return result
44
+
45
+ def from_response_with_completion(self, obj: QuestionToStructuredQueryResponse) -> Tuple[Dict[str, Any], bool]:
46
+ """Returns (response_dict, is_final)"""
47
+ return self.from_pulsar(obj), True
@@ -0,0 +1,56 @@
1
+ from typing import Dict, Any, Tuple
2
+ from ...schema import StructuredQueryRequest, StructuredQueryResponse
3
+ from .base import MessageTranslator
4
+ import json
5
+
6
+
7
+ class StructuredQueryRequestTranslator(MessageTranslator):
8
+ """Translator for StructuredQueryRequest schema objects"""
9
+
10
+ def to_pulsar(self, data: Dict[str, Any]) -> StructuredQueryRequest:
11
+ return StructuredQueryRequest(
12
+ question=data.get("question", "")
13
+ )
14
+
15
+ def from_pulsar(self, obj: StructuredQueryRequest) -> Dict[str, Any]:
16
+ return {
17
+ "question": obj.question
18
+ }
19
+
20
+
21
+ class StructuredQueryResponseTranslator(MessageTranslator):
22
+ """Translator for StructuredQueryResponse schema objects"""
23
+
24
+ def to_pulsar(self, data: Dict[str, Any]) -> StructuredQueryResponse:
25
+ raise NotImplementedError("Response translation to Pulsar not typically needed")
26
+
27
+ def from_pulsar(self, obj: StructuredQueryResponse) -> Dict[str, Any]:
28
+ result = {}
29
+
30
+ # Handle structured query response data
31
+ if obj.data:
32
+ try:
33
+ result["data"] = json.loads(obj.data)
34
+ except json.JSONDecodeError:
35
+ result["data"] = obj.data
36
+ else:
37
+ result["data"] = None
38
+
39
+ # Handle errors (array of strings)
40
+ if obj.errors:
41
+ result["errors"] = list(obj.errors)
42
+ else:
43
+ result["errors"] = []
44
+
45
+ # Handle system-level error
46
+ if obj.error:
47
+ result["error"] = {
48
+ "type": obj.error.type,
49
+ "message": obj.error.message
50
+ }
51
+
52
+ return result
53
+
54
+ def from_response_with_completion(self, obj: StructuredQueryResponse) -> Tuple[Dict[str, Any], bool]:
55
+ """Returns (response_dict, is_final)"""
56
+ return self.from_pulsar(obj), True
@@ -8,13 +8,11 @@ from ..core.topic import topic
8
8
  # Structured Query Service - executes GraphQL queries
9
9
 
10
10
  class StructuredQueryRequest(Record):
11
- query = String() # GraphQL query
12
- variables = Map(String()) # GraphQL variables
13
- operation_name = String() # Optional operation name for multi-operation documents
11
+ question = String()
14
12
 
15
13
  class StructuredQueryResponse(Record):
16
14
  error = Error()
17
15
  data = String() # JSON-encoded GraphQL response data
18
16
  errors = Array(String()) # GraphQL errors if any
19
17
 
20
- ############################################################################
18
+ ############################################################################
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trustgraph-base
3
- Version: 1.3.6
3
+ Version: 1.3.8
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/base/pubsub.py
40
40
  trustgraph/base/request_response_spec.py
41
41
  trustgraph/base/setting_spec.py
42
42
  trustgraph/base/spec.py
43
+ trustgraph/base/structured_query_client.py
43
44
  trustgraph/base/subscriber.py
44
45
  trustgraph/base/subscriber_spec.py
45
46
  trustgraph/base/text_completion_client.py
@@ -79,10 +80,12 @@ trustgraph/messaging/translators/flow.py
79
80
  trustgraph/messaging/translators/knowledge.py
80
81
  trustgraph/messaging/translators/library.py
81
82
  trustgraph/messaging/translators/metadata.py
83
+ trustgraph/messaging/translators/nlp_query.py
82
84
  trustgraph/messaging/translators/objects_query.py
83
85
  trustgraph/messaging/translators/primitives.py
84
86
  trustgraph/messaging/translators/prompt.py
85
87
  trustgraph/messaging/translators/retrieval.py
88
+ trustgraph/messaging/translators/structured_query.py
86
89
  trustgraph/messaging/translators/text_completion.py
87
90
  trustgraph/messaging/translators/tool.py
88
91
  trustgraph/messaging/translators/triples.py
@@ -1 +0,0 @@
1
- __version__ = "1.3.6"