mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-25 13:11:02 +02:00
New schemas
This commit is contained in:
parent
edf9b8b1db
commit
e606ed6e40
8 changed files with 101 additions and 4 deletions
|
|
@ -17,11 +17,15 @@ class Triple(Record):
|
||||||
|
|
||||||
class Field(Record):
|
class Field(Record):
|
||||||
name = String()
|
name = String()
|
||||||
# int, string, long, bool, float, double
|
# int, string, long, bool, float, double, timestamp
|
||||||
type = String()
|
type = String()
|
||||||
size = Integer()
|
size = Integer()
|
||||||
primary = Boolean()
|
primary = Boolean()
|
||||||
description = String()
|
description = String()
|
||||||
|
# NEW FIELDS for structured data:
|
||||||
|
required = Boolean() # Whether field is required
|
||||||
|
enum_values = Array(String()) # For enum type fields
|
||||||
|
indexed = Boolean() # Whether field should be indexed
|
||||||
|
|
||||||
class RowSchema(Record):
|
class RowSchema(Record):
|
||||||
name = String()
|
name = String()
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,6 @@ from .document import *
|
||||||
from .embeddings import *
|
from .embeddings import *
|
||||||
from .knowledge import *
|
from .knowledge import *
|
||||||
from .nlp import *
|
from .nlp import *
|
||||||
from .rows import *
|
from .rows import *
|
||||||
|
from .structured import *
|
||||||
|
from .extraction import *
|
||||||
|
|
@ -40,4 +40,17 @@ class ObjectEmbeddings(Record):
|
||||||
vectors = Array(Array(Double()))
|
vectors = Array(Array(Double()))
|
||||||
name = String()
|
name = String()
|
||||||
key_name = String()
|
key_name = String()
|
||||||
id = String()
|
id = String()
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
# Structured object embeddings with enhanced capabilities
|
||||||
|
|
||||||
|
class StructuredObjectEmbedding(Record):
|
||||||
|
metadata = Metadata()
|
||||||
|
vectors = Array(Array(Double()))
|
||||||
|
schema_name = String()
|
||||||
|
object_id = String() # Primary key value
|
||||||
|
field_embeddings = Map(Array(Double())) # Per-field embeddings
|
||||||
|
|
||||||
|
############################################################################
|
||||||
17
trustgraph-base/trustgraph/schema/knowledge/extraction.py
Normal file
17
trustgraph-base/trustgraph/schema/knowledge/extraction.py
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
from pulsar.schema import Record, String, Map, Double
|
||||||
|
|
||||||
|
from ..core.metadata import Metadata
|
||||||
|
from ..core.topic import topic
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
# Extracted object from text processing
|
||||||
|
|
||||||
|
class ExtractedObject(Record):
|
||||||
|
metadata = Metadata()
|
||||||
|
schema_name = String() # Which schema this object belongs to
|
||||||
|
values = Map(String()) # Field name -> value
|
||||||
|
confidence = Double()
|
||||||
|
source_span = String() # Text span where object was found
|
||||||
|
|
||||||
|
############################################################################
|
||||||
17
trustgraph-base/trustgraph/schema/knowledge/structured.py
Normal file
17
trustgraph-base/trustgraph/schema/knowledge/structured.py
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
from pulsar.schema import Record, String, Bytes, Map
|
||||||
|
|
||||||
|
from ..core.metadata import Metadata
|
||||||
|
from ..core.topic import topic
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
# Structured data submission for fire-and-forget processing
|
||||||
|
|
||||||
|
class StructuredDataSubmission(Record):
|
||||||
|
metadata = Metadata()
|
||||||
|
format = String() # "json", "csv", "xml"
|
||||||
|
schema_name = String() # Reference to schema in config
|
||||||
|
data = Bytes() # Raw data to ingest
|
||||||
|
options = Map(String()) # Format-specific options
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
|
@ -6,4 +6,6 @@ from .flow import *
|
||||||
from .prompt import *
|
from .prompt import *
|
||||||
from .config import *
|
from .config import *
|
||||||
from .library import *
|
from .library import *
|
||||||
from .lookup import *
|
from .lookup import *
|
||||||
|
from .nlp_query import *
|
||||||
|
from .structured_query import *
|
||||||
22
trustgraph-base/trustgraph/schema/services/nlp_query.py
Normal file
22
trustgraph-base/trustgraph/schema/services/nlp_query.py
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
from pulsar.schema import Record, String, Array, Map, Integer, Double
|
||||||
|
|
||||||
|
from ..core.primitives import Error
|
||||||
|
from ..core.topic import topic
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
# NLP to Structured Query Service - converts natural language to GraphQL
|
||||||
|
|
||||||
|
class NLPToStructuredQueryRequest(Record):
|
||||||
|
natural_language_query = String()
|
||||||
|
max_results = Integer()
|
||||||
|
context_hints = Map(String()) # Optional context for query generation
|
||||||
|
|
||||||
|
class NLPToStructuredQueryResponse(Record):
|
||||||
|
error = Error()
|
||||||
|
graphql_query = String() # Generated GraphQL query
|
||||||
|
variables = Map(String()) # GraphQL variables if any
|
||||||
|
detected_schemas = Array(String()) # Which schemas the query targets
|
||||||
|
confidence = Double()
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
from pulsar.schema import Record, String, Map, Array
|
||||||
|
|
||||||
|
from ..core.primitives import Error
|
||||||
|
from ..core.topic import topic
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
# Structured Query Service - executes GraphQL queries
|
||||||
|
|
||||||
|
class StructuredQueryRequest(Record):
|
||||||
|
query = String() # GraphQL query
|
||||||
|
variables = Map(String()) # GraphQL variables
|
||||||
|
operation_name = String() # Optional operation name for multi-operation documents
|
||||||
|
|
||||||
|
class StructuredQueryResponse(Record):
|
||||||
|
error = Error()
|
||||||
|
data = String() # JSON-encoded GraphQL response data
|
||||||
|
errors = Array(String()) # GraphQL errors if any
|
||||||
|
|
||||||
|
############################################################################
|
||||||
Loading…
Add table
Add a link
Reference in a new issue