trustgraph-base 1.4.4__tar.gz → 1.4.6__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-base might be problematic. Click here for more details.

Files changed (131) hide show
  1. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/PKG-INFO +1 -1
  2. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/api/flow.py +138 -2
  3. trustgraph_base-1.4.6/trustgraph/base_version.py +1 -0
  4. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/__init__.py +9 -2
  5. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/__init__.py +1 -0
  6. trustgraph_base-1.4.6/trustgraph/messaging/translators/diagnosis.py +67 -0
  7. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/services/__init__.py +2 -1
  8. trustgraph_base-1.4.6/trustgraph/schema/services/diagnosis.py +33 -0
  9. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph_base.egg-info/PKG-INFO +1 -1
  10. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph_base.egg-info/SOURCES.txt +2 -0
  11. trustgraph_base-1.4.4/trustgraph/base_version.py +0 -1
  12. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/README.md +0 -0
  13. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/pyproject.toml +0 -0
  14. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/setup.cfg +0 -0
  15. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/api/__init__.py +0 -0
  16. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/api/api.py +0 -0
  17. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/api/config.py +0 -0
  18. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/api/exceptions.py +0 -0
  19. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/api/knowledge.py +0 -0
  20. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/api/library.py +0 -0
  21. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/api/types.py +0 -0
  22. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/__init__.py +0 -0
  23. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/agent_client.py +0 -0
  24. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/agent_service.py +0 -0
  25. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/async_processor.py +0 -0
  26. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/cassandra_config.py +0 -0
  27. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/consumer.py +0 -0
  28. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/consumer_spec.py +0 -0
  29. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/document_embeddings_client.py +0 -0
  30. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/document_embeddings_query_service.py +0 -0
  31. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/document_embeddings_store_service.py +0 -0
  32. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/embeddings_client.py +0 -0
  33. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/embeddings_service.py +0 -0
  34. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/flow.py +0 -0
  35. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/flow_processor.py +0 -0
  36. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/graph_embeddings_client.py +0 -0
  37. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/graph_embeddings_query_service.py +0 -0
  38. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/graph_embeddings_store_service.py +0 -0
  39. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/graph_rag_client.py +0 -0
  40. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/llm_service.py +0 -0
  41. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/metrics.py +0 -0
  42. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/producer.py +0 -0
  43. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/producer_spec.py +0 -0
  44. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/prompt_client.py +0 -0
  45. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/publisher.py +0 -0
  46. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/pubsub.py +0 -0
  47. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/request_response_spec.py +0 -0
  48. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/setting_spec.py +0 -0
  49. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/spec.py +0 -0
  50. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/structured_query_client.py +0 -0
  51. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/subscriber.py +0 -0
  52. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/subscriber_spec.py +0 -0
  53. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/text_completion_client.py +0 -0
  54. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/tool_client.py +0 -0
  55. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/tool_service.py +0 -0
  56. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/triples_client.py +0 -0
  57. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/triples_query_service.py +0 -0
  58. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/base/triples_store_service.py +0 -0
  59. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/clients/__init__.py +0 -0
  60. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/clients/agent_client.py +0 -0
  61. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/clients/base.py +0 -0
  62. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/clients/config_client.py +0 -0
  63. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/clients/document_embeddings_client.py +0 -0
  64. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/clients/document_rag_client.py +0 -0
  65. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/clients/embeddings_client.py +0 -0
  66. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/clients/graph_embeddings_client.py +0 -0
  67. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/clients/graph_rag_client.py +0 -0
  68. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/clients/llm_client.py +0 -0
  69. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/clients/prompt_client.py +0 -0
  70. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/clients/triples_query_client.py +0 -0
  71. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/exceptions.py +0 -0
  72. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/knowledge/__init__.py +0 -0
  73. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/knowledge/defs.py +0 -0
  74. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/knowledge/document.py +0 -0
  75. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/knowledge/identifier.py +0 -0
  76. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/knowledge/organization.py +0 -0
  77. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/knowledge/publication.py +0 -0
  78. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/log_level.py +0 -0
  79. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/registry.py +0 -0
  80. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/agent.py +0 -0
  81. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/base.py +0 -0
  82. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/config.py +0 -0
  83. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/document_loading.py +0 -0
  84. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/embeddings.py +0 -0
  85. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/embeddings_query.py +0 -0
  86. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/flow.py +0 -0
  87. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/knowledge.py +0 -0
  88. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/library.py +0 -0
  89. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/metadata.py +0 -0
  90. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/nlp_query.py +0 -0
  91. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/objects_query.py +0 -0
  92. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/primitives.py +0 -0
  93. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/prompt.py +0 -0
  94. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/retrieval.py +0 -0
  95. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/structured_query.py +0 -0
  96. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/text_completion.py +0 -0
  97. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/tool.py +0 -0
  98. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/messaging/translators/triples.py +0 -0
  99. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/objects/__init__.py +0 -0
  100. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/objects/field.py +0 -0
  101. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/objects/object.py +0 -0
  102. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/rdf.py +0 -0
  103. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/__init__.py +0 -0
  104. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/core/__init__.py +0 -0
  105. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/core/metadata.py +0 -0
  106. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/core/primitives.py +0 -0
  107. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/core/topic.py +0 -0
  108. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/knowledge/__init__.py +0 -0
  109. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/knowledge/document.py +0 -0
  110. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/knowledge/embeddings.py +0 -0
  111. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/knowledge/graph.py +0 -0
  112. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/knowledge/knowledge.py +0 -0
  113. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/knowledge/nlp.py +0 -0
  114. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/knowledge/object.py +0 -0
  115. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/knowledge/rows.py +0 -0
  116. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/knowledge/structured.py +0 -0
  117. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/services/agent.py +0 -0
  118. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/services/config.py +0 -0
  119. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/services/flow.py +0 -0
  120. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/services/library.py +0 -0
  121. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/services/llm.py +0 -0
  122. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/services/lookup.py +0 -0
  123. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/services/nlp_query.py +0 -0
  124. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/services/objects_query.py +0 -0
  125. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/services/prompt.py +0 -0
  126. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/services/query.py +0 -0
  127. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/services/retrieval.py +0 -0
  128. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph/schema/services/structured_query.py +0 -0
  129. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph_base.egg-info/dependency_links.txt +0 -0
  130. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/trustgraph_base.egg-info/requires.txt +0 -0
  131. {trustgraph_base-1.4.4 → trustgraph_base-1.4.6}/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.4.4
3
+ Version: 1.4.6
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
@@ -492,12 +492,148 @@ class FlowInstance:
492
492
  "service/structured-query",
493
493
  input
494
494
  )
495
-
495
+
496
496
  # Check for system-level error
497
497
  if "error" in response and response["error"]:
498
498
  error_type = response["error"].get("type", "unknown")
499
499
  error_message = response["error"].get("message", "Unknown error")
500
500
  raise ProtocolException(f"{error_type}: {error_message}")
501
-
501
+
502
502
  return response
503
503
 
504
+ def detect_type(self, sample):
505
+ """
506
+ Detect the data type of a structured data sample.
507
+
508
+ Args:
509
+ sample: Data sample to analyze (string content)
510
+
511
+ Returns:
512
+ dict with detected_type, confidence, and optional metadata
513
+ """
514
+
515
+ input = {
516
+ "operation": "detect-type",
517
+ "sample": sample
518
+ }
519
+
520
+ response = self.request(
521
+ "service/structured-diag",
522
+ input
523
+ )
524
+
525
+ # Check for system-level error
526
+ if "error" in response and response["error"]:
527
+ error_type = response["error"].get("type", "unknown")
528
+ error_message = response["error"].get("message", "Unknown error")
529
+ raise ProtocolException(f"{error_type}: {error_message}")
530
+
531
+ return response["detected-type"]
532
+
533
+ def generate_descriptor(self, sample, data_type, schema_name, options=None):
534
+ """
535
+ Generate a descriptor for structured data mapping to a specific schema.
536
+
537
+ Args:
538
+ sample: Data sample to analyze (string content)
539
+ data_type: Data type (csv, json, xml)
540
+ schema_name: Target schema name for descriptor generation
541
+ options: Optional parameters (e.g., delimiter for CSV)
542
+
543
+ Returns:
544
+ dict with descriptor and metadata
545
+ """
546
+
547
+ input = {
548
+ "operation": "generate-descriptor",
549
+ "sample": sample,
550
+ "type": data_type,
551
+ "schema-name": schema_name
552
+ }
553
+
554
+ if options:
555
+ input["options"] = options
556
+
557
+ response = self.request(
558
+ "service/structured-diag",
559
+ input
560
+ )
561
+
562
+ # Check for system-level error
563
+ if "error" in response and response["error"]:
564
+ error_type = response["error"].get("type", "unknown")
565
+ error_message = response["error"].get("message", "Unknown error")
566
+ raise ProtocolException(f"{error_type}: {error_message}")
567
+
568
+ return response["descriptor"]
569
+
570
+ def diagnose_data(self, sample, schema_name=None, options=None):
571
+ """
572
+ Perform combined data diagnosis: detect type and generate descriptor.
573
+
574
+ Args:
575
+ sample: Data sample to analyze (string content)
576
+ schema_name: Optional target schema name for descriptor generation
577
+ options: Optional parameters (e.g., delimiter for CSV)
578
+
579
+ Returns:
580
+ dict with detected_type, confidence, descriptor, and metadata
581
+ """
582
+
583
+ input = {
584
+ "operation": "diagnose",
585
+ "sample": sample
586
+ }
587
+
588
+ if schema_name:
589
+ input["schema-name"] = schema_name
590
+
591
+ if options:
592
+ input["options"] = options
593
+
594
+ response = self.request(
595
+ "service/structured-diag",
596
+ input
597
+ )
598
+
599
+ # Check for system-level error
600
+ if "error" in response and response["error"]:
601
+ error_type = response["error"].get("type", "unknown")
602
+ error_message = response["error"].get("message", "Unknown error")
603
+ raise ProtocolException(f"{error_type}: {error_message}")
604
+
605
+ return response
606
+
607
+ def schema_selection(self, sample, options=None):
608
+ """
609
+ Select matching schemas for a data sample using prompt analysis.
610
+
611
+ Args:
612
+ sample: Data sample to analyze (string content)
613
+ options: Optional parameters
614
+
615
+ Returns:
616
+ dict with schema_matches array and metadata
617
+ """
618
+
619
+ input = {
620
+ "operation": "schema-selection",
621
+ "sample": sample
622
+ }
623
+
624
+ if options:
625
+ input["options"] = options
626
+
627
+ response = self.request(
628
+ "service/structured-diag",
629
+ input
630
+ )
631
+
632
+ # Check for system-level error
633
+ if "error" in response and response["error"]:
634
+ error_type = response["error"].get("type", "unknown")
635
+ error_message = response["error"].get("message", "Unknown error")
636
+ raise ProtocolException(f"{error_type}: {error_message}")
637
+
638
+ return response["schema-matches"]
639
+
@@ -0,0 +1 @@
1
+ __version__ = "1.4.6"
@@ -24,6 +24,7 @@ from .translators.embeddings_query import (
24
24
  from .translators.objects_query import ObjectsQueryRequestTranslator, ObjectsQueryResponseTranslator
25
25
  from .translators.nlp_query import QuestionToStructuredQueryRequestTranslator, QuestionToStructuredQueryResponseTranslator
26
26
  from .translators.structured_query import StructuredQueryRequestTranslator, StructuredQueryResponseTranslator
27
+ from .translators.diagnosis import StructuredDataDiagnosisRequestTranslator, StructuredDataDiagnosisResponseTranslator
27
28
 
28
29
  # Register all service translators
29
30
  TranslatorRegistry.register_service(
@@ -123,11 +124,17 @@ TranslatorRegistry.register_service(
123
124
  )
124
125
 
125
126
  TranslatorRegistry.register_service(
126
- "structured-query",
127
- StructuredQueryRequestTranslator(),
127
+ "structured-query",
128
+ StructuredQueryRequestTranslator(),
128
129
  StructuredQueryResponseTranslator()
129
130
  )
130
131
 
132
+ TranslatorRegistry.register_service(
133
+ "structured-diag",
134
+ StructuredDataDiagnosisRequestTranslator(),
135
+ StructuredDataDiagnosisResponseTranslator()
136
+ )
137
+
131
138
  # Register single-direction translators for document loading
132
139
  TranslatorRegistry.register_request("document", DocumentTranslator())
133
140
  TranslatorRegistry.register_request("text-document", TextDocumentTranslator())
@@ -18,3 +18,4 @@ from .embeddings_query import (
18
18
  GraphEmbeddingsRequestTranslator, GraphEmbeddingsResponseTranslator
19
19
  )
20
20
  from .objects_query import ObjectsQueryRequestTranslator, ObjectsQueryResponseTranslator
21
+ from .diagnosis import StructuredDataDiagnosisRequestTranslator, StructuredDataDiagnosisResponseTranslator
@@ -0,0 +1,67 @@
1
+ from typing import Dict, Any, Tuple
2
+ import json
3
+ from ...schema import StructuredDataDiagnosisRequest, StructuredDataDiagnosisResponse
4
+ from .base import MessageTranslator
5
+
6
+
7
+ class StructuredDataDiagnosisRequestTranslator(MessageTranslator):
8
+ """Translator for StructuredDataDiagnosisRequest schema objects"""
9
+
10
+ def to_pulsar(self, data: Dict[str, Any]) -> StructuredDataDiagnosisRequest:
11
+ return StructuredDataDiagnosisRequest(
12
+ operation=data["operation"],
13
+ sample=data["sample"],
14
+ type=data.get("type", ""),
15
+ schema_name=data.get("schema-name", ""),
16
+ options=data.get("options", {})
17
+ )
18
+
19
+ def from_pulsar(self, obj: StructuredDataDiagnosisRequest) -> Dict[str, Any]:
20
+ result = {
21
+ "operation": obj.operation,
22
+ "sample": obj.sample,
23
+ }
24
+
25
+ # Add optional fields if they exist
26
+ if obj.type:
27
+ result["type"] = obj.type
28
+ if obj.schema_name:
29
+ result["schema-name"] = obj.schema_name
30
+ if obj.options:
31
+ result["options"] = obj.options
32
+
33
+ return result
34
+
35
+
36
+ class StructuredDataDiagnosisResponseTranslator(MessageTranslator):
37
+ """Translator for StructuredDataDiagnosisResponse schema objects"""
38
+
39
+ def to_pulsar(self, data: Dict[str, Any]) -> StructuredDataDiagnosisResponse:
40
+ raise NotImplementedError("Response translation to Pulsar not typically needed")
41
+
42
+ def from_pulsar(self, obj: StructuredDataDiagnosisResponse) -> Dict[str, Any]:
43
+ result = {
44
+ "operation": obj.operation
45
+ }
46
+
47
+ # Add optional response fields if they exist
48
+ if obj.detected_type:
49
+ result["detected-type"] = obj.detected_type
50
+ if obj.confidence is not None:
51
+ result["confidence"] = obj.confidence
52
+ if obj.descriptor:
53
+ # Parse JSON-encoded descriptor
54
+ try:
55
+ result["descriptor"] = json.loads(obj.descriptor)
56
+ except (json.JSONDecodeError, TypeError):
57
+ result["descriptor"] = obj.descriptor
58
+ if obj.metadata:
59
+ result["metadata"] = obj.metadata
60
+ if obj.schema_matches is not None:
61
+ result["schema-matches"] = obj.schema_matches
62
+
63
+ return result
64
+
65
+ def from_response_with_completion(self, obj: StructuredDataDiagnosisResponse) -> Tuple[Dict[str, Any], bool]:
66
+ """Returns (response_dict, is_final)"""
67
+ return self.from_pulsar(obj), True
@@ -9,4 +9,5 @@ from .library import *
9
9
  from .lookup import *
10
10
  from .nlp_query import *
11
11
  from .structured_query import *
12
- from .objects_query import *
12
+ from .objects_query import *
13
+ from .diagnosis import *
@@ -0,0 +1,33 @@
1
+ from pulsar.schema import Record, String, Map, Double, Array
2
+ from ..core.primitives import Error
3
+
4
+ ############################################################################
5
+
6
+ # Structured data diagnosis services
7
+
8
+ class StructuredDataDiagnosisRequest(Record):
9
+ operation = String() # "detect-type", "generate-descriptor", "diagnose", or "schema-selection"
10
+ sample = String() # Data sample to analyze (text content)
11
+ type = String() # Data type (csv, json, xml) - optional, required for generate-descriptor
12
+ schema_name = String() # Target schema name for descriptor generation - optional
13
+
14
+ # JSON encoded options (e.g., delimiter for CSV)
15
+ options = Map(String())
16
+
17
+ class StructuredDataDiagnosisResponse(Record):
18
+ error = Error()
19
+
20
+ operation = String() # The operation that was performed
21
+ detected_type = String() # Detected data type (for detect-type/diagnose) - optional
22
+ confidence = Double() # Confidence score for type detection - optional
23
+
24
+ # JSON encoded descriptor (for generate-descriptor/diagnose) - optional
25
+ descriptor = String()
26
+
27
+ # JSON encoded additional metadata (e.g., field count, sample records)
28
+ metadata = Map(String())
29
+
30
+ # Array of matching schema IDs (for schema-selection operation) - optional
31
+ schema_matches = Array(String())
32
+
33
+ ############################################################################
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trustgraph-base
3
- Version: 1.4.4
3
+ Version: 1.4.6
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
@@ -73,6 +73,7 @@ trustgraph/messaging/translators/__init__.py
73
73
  trustgraph/messaging/translators/agent.py
74
74
  trustgraph/messaging/translators/base.py
75
75
  trustgraph/messaging/translators/config.py
76
+ trustgraph/messaging/translators/diagnosis.py
76
77
  trustgraph/messaging/translators/document_loading.py
77
78
  trustgraph/messaging/translators/embeddings.py
78
79
  trustgraph/messaging/translators/embeddings_query.py
@@ -109,6 +110,7 @@ trustgraph/schema/knowledge/structured.py
109
110
  trustgraph/schema/services/__init__.py
110
111
  trustgraph/schema/services/agent.py
111
112
  trustgraph/schema/services/config.py
113
+ trustgraph/schema/services/diagnosis.py
112
114
  trustgraph/schema/services/flow.py
113
115
  trustgraph/schema/services/library.py
114
116
  trustgraph/schema/services/llm.py
@@ -1 +0,0 @@
1
- __version__ = "1.4.4"