Skip to main content

SemanticEngineClient

Struct SemanticEngineClient 

Source
pub struct SemanticEngineClient<T> { /* private fields */ }

Implementations§

Source§

impl SemanticEngineClient<Channel>

Source

pub async fn connect<D>(dst: D) -> Result<Self, Error>
where D: TryInto<Endpoint>, D::Error: Into<StdError>,

Attempt to create a new client by connecting to a given endpoint.

Examples found in repository?
examples/grpc_verify.rs (line 10)
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9    println!("Connecting to Synapse gRPC server...");
10    let mut client = SemanticEngineClient::connect("http://[::1]:50051").await?;
11
12    println!("✅ Connected!");
13
14    // 1. Ingest Data
15    let triple = Triple {
16        subject: "http://example.org/Socrates".to_string(),
17        predicate: "http://www.w3.org/1999/02/22-rdf-syntax-ns#type".to_string(),
18        object: "http://example.org/Human".to_string(),
19        provenance: Some(Provenance {
20            source: "client_test".to_string(),
21            timestamp: "now".to_string(),
22            method: "grpc".to_string(),
23        }),
24        embedding: vec![],
25    };
26    
27    let triple2 = Triple {
28        subject: "http://example.org/Human".to_string(),
29        predicate: "http://www.w3.org/2000/01/rdf-schema#subClassOf".to_string(),
30        object: "http://example.org/Mortal".to_string(),
31        provenance: Some(Provenance {
32            source: "client_test".to_string(),
33            timestamp: "now".to_string(),
34            method: "grpc".to_string(),
35        }),
36        embedding: vec![],
37    };
38
39    println!("Sending IngestRequest...");
40    let response = client.ingest_triples(IngestRequest {
41        triples: vec![triple, triple2],
42        namespace: "test_verification".to_string(),
43    }).await?;
44    println!("Response: {:?}", response.into_inner());
45
46    // 2. Apply Reasoning (RDFS Transitivity)
47    println!("\nApplying RDFS Reasoning (Internal)...");
48    let reasoning_response = client.apply_reasoning(ReasoningRequest {
49        namespace: "test_verification".to_string(),
50        strategy: ReasoningStrategy::Rdfs as i32,
51        materialize: false,
52    }).await?;
53    println!("Reasoning Result: {:?}", reasoning_response.into_inner());
54
55    // 3. Hybrid Search
56    println!("\nPerforming Hybrid Search for 'Socrates'...");
57    let search_response = client.hybrid_search(HybridSearchRequest {
58        query: "Socrates".to_string(),
59        namespace: "test_verification".to_string(),
60        vector_k: 5,
61        graph_depth: 1,
62        mode: SearchMode::Hybrid as i32,
63        limit: 10,
64    }).await?;
65    
66    println!("Search Results:");
67    for result in search_response.into_inner().results {
68        println!(" - [Score: {:.4}] {} ({})", result.score, result.content, result.uri);
69    }
70
71    Ok(())
72}
Source§

impl<T> SemanticEngineClient<T>
where T: GrpcService<BoxBody>, T::Error: Into<StdError>, T::ResponseBody: Body<Data = Bytes> + Send + 'static, <T::ResponseBody as Body>::Error: Into<StdError> + Send,

Source

pub fn new(inner: T) -> Self

Source

pub fn with_origin(inner: T, origin: Uri) -> Self

Source

pub fn with_interceptor<F>( inner: T, interceptor: F, ) -> SemanticEngineClient<InterceptedService<T, F>>
where F: Interceptor, T::ResponseBody: Default, T: Service<Request<BoxBody>, Response = Response<<T as GrpcService<BoxBody>>::ResponseBody>>, <T as Service<Request<BoxBody>>>::Error: Into<StdError> + Send + Sync,

Source

pub fn send_compressed(self, encoding: CompressionEncoding) -> Self

Compress requests with the given encoding.

This requires the server to support it otherwise it might respond with an error.

Source

pub fn accept_compressed(self, encoding: CompressionEncoding) -> Self

Enable decompressing responses.

Source

pub fn max_decoding_message_size(self, limit: usize) -> Self

Limits the maximum size of a decoded message.

Default: 4MB

Source

pub fn max_encoding_message_size(self, limit: usize) -> Self

Limits the maximum size of an encoded message.

Default: usize::MAX

Source

pub async fn ingest_triples( &mut self, request: impl IntoRequest<IngestRequest>, ) -> Result<Response<IngestResponse>, Status>

Ingests a batch of triples

Examples found in repository?
examples/grpc_verify.rs (lines 40-43)
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9    println!("Connecting to Synapse gRPC server...");
10    let mut client = SemanticEngineClient::connect("http://[::1]:50051").await?;
11
12    println!("✅ Connected!");
13
14    // 1. Ingest Data
15    let triple = Triple {
16        subject: "http://example.org/Socrates".to_string(),
17        predicate: "http://www.w3.org/1999/02/22-rdf-syntax-ns#type".to_string(),
18        object: "http://example.org/Human".to_string(),
19        provenance: Some(Provenance {
20            source: "client_test".to_string(),
21            timestamp: "now".to_string(),
22            method: "grpc".to_string(),
23        }),
24        embedding: vec![],
25    };
26    
27    let triple2 = Triple {
28        subject: "http://example.org/Human".to_string(),
29        predicate: "http://www.w3.org/2000/01/rdf-schema#subClassOf".to_string(),
30        object: "http://example.org/Mortal".to_string(),
31        provenance: Some(Provenance {
32            source: "client_test".to_string(),
33            timestamp: "now".to_string(),
34            method: "grpc".to_string(),
35        }),
36        embedding: vec![],
37    };
38
39    println!("Sending IngestRequest...");
40    let response = client.ingest_triples(IngestRequest {
41        triples: vec![triple, triple2],
42        namespace: "test_verification".to_string(),
43    }).await?;
44    println!("Response: {:?}", response.into_inner());
45
46    // 2. Apply Reasoning (RDFS Transitivity)
47    println!("\nApplying RDFS Reasoning (Internal)...");
48    let reasoning_response = client.apply_reasoning(ReasoningRequest {
49        namespace: "test_verification".to_string(),
50        strategy: ReasoningStrategy::Rdfs as i32,
51        materialize: false,
52    }).await?;
53    println!("Reasoning Result: {:?}", reasoning_response.into_inner());
54
55    // 3. Hybrid Search
56    println!("\nPerforming Hybrid Search for 'Socrates'...");
57    let search_response = client.hybrid_search(HybridSearchRequest {
58        query: "Socrates".to_string(),
59        namespace: "test_verification".to_string(),
60        vector_k: 5,
61        graph_depth: 1,
62        mode: SearchMode::Hybrid as i32,
63        limit: 10,
64    }).await?;
65    
66    println!("Search Results:");
67    for result in search_response.into_inner().results {
68        println!(" - [Score: {:.4}] {} ({})", result.score, result.content, result.uri);
69    }
70
71    Ok(())
72}
Source

pub async fn ingest_file( &mut self, request: impl IntoRequest<IngestFileRequest>, ) -> Result<Response<IngestResponse>, Status>

Ingests a file (CSV, Markdown)

Source

pub async fn get_neighbors( &mut self, request: impl IntoRequest<NodeRequest>, ) -> Result<Response<NeighborResponse>, Status>

Queries the graph (Basic traversal for now)

Source

pub async fn search( &mut self, request: impl IntoRequest<SearchRequest>, ) -> Result<Response<SearchResponse>, Status>

Vector Search (Placeholder for hybrid query)

Source

pub async fn resolve_id( &mut self, request: impl IntoRequest<ResolveRequest>, ) -> Result<Response<ResolveResponse>, Status>

Resolves a string URI to a Node ID

Source

pub async fn get_all_triples( &mut self, request: impl IntoRequest<EmptyRequest>, ) -> Result<Response<TriplesResponse>, Status>

Get all stored triples (for graph visualization)

Source

pub async fn query_sparql( &mut self, request: impl IntoRequest<SparqlRequest>, ) -> Result<Response<SparqlResponse>, Status>

Executes a SPARQL query

Source

pub async fn delete_namespace_data( &mut self, request: impl IntoRequest<EmptyRequest>, ) -> Result<Response<DeleteResponse>, Status>

Deletes all data associated with a namespace

Hybrid search combining vector similarity and graph traversal

Examples found in repository?
examples/grpc_verify.rs (lines 57-64)
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9    println!("Connecting to Synapse gRPC server...");
10    let mut client = SemanticEngineClient::connect("http://[::1]:50051").await?;
11
12    println!("✅ Connected!");
13
14    // 1. Ingest Data
15    let triple = Triple {
16        subject: "http://example.org/Socrates".to_string(),
17        predicate: "http://www.w3.org/1999/02/22-rdf-syntax-ns#type".to_string(),
18        object: "http://example.org/Human".to_string(),
19        provenance: Some(Provenance {
20            source: "client_test".to_string(),
21            timestamp: "now".to_string(),
22            method: "grpc".to_string(),
23        }),
24        embedding: vec![],
25    };
26    
27    let triple2 = Triple {
28        subject: "http://example.org/Human".to_string(),
29        predicate: "http://www.w3.org/2000/01/rdf-schema#subClassOf".to_string(),
30        object: "http://example.org/Mortal".to_string(),
31        provenance: Some(Provenance {
32            source: "client_test".to_string(),
33            timestamp: "now".to_string(),
34            method: "grpc".to_string(),
35        }),
36        embedding: vec![],
37    };
38
39    println!("Sending IngestRequest...");
40    let response = client.ingest_triples(IngestRequest {
41        triples: vec![triple, triple2],
42        namespace: "test_verification".to_string(),
43    }).await?;
44    println!("Response: {:?}", response.into_inner());
45
46    // 2. Apply Reasoning (RDFS Transitivity)
47    println!("\nApplying RDFS Reasoning (Internal)...");
48    let reasoning_response = client.apply_reasoning(ReasoningRequest {
49        namespace: "test_verification".to_string(),
50        strategy: ReasoningStrategy::Rdfs as i32,
51        materialize: false,
52    }).await?;
53    println!("Reasoning Result: {:?}", reasoning_response.into_inner());
54
55    // 3. Hybrid Search
56    println!("\nPerforming Hybrid Search for 'Socrates'...");
57    let search_response = client.hybrid_search(HybridSearchRequest {
58        query: "Socrates".to_string(),
59        namespace: "test_verification".to_string(),
60        vector_k: 5,
61        graph_depth: 1,
62        mode: SearchMode::Hybrid as i32,
63        limit: 10,
64    }).await?;
65    
66    println!("Search Results:");
67    for result in search_response.into_inner().results {
68        println!(" - [Score: {:.4}] {} ({})", result.score, result.content, result.uri);
69    }
70
71    Ok(())
72}
Source

pub async fn apply_reasoning( &mut self, request: impl IntoRequest<ReasoningRequest>, ) -> Result<Response<ReasoningResponse>, Status>

Applies automated reasoning to a namespace

Examples found in repository?
examples/grpc_verify.rs (lines 48-52)
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9    println!("Connecting to Synapse gRPC server...");
10    let mut client = SemanticEngineClient::connect("http://[::1]:50051").await?;
11
12    println!("✅ Connected!");
13
14    // 1. Ingest Data
15    let triple = Triple {
16        subject: "http://example.org/Socrates".to_string(),
17        predicate: "http://www.w3.org/1999/02/22-rdf-syntax-ns#type".to_string(),
18        object: "http://example.org/Human".to_string(),
19        provenance: Some(Provenance {
20            source: "client_test".to_string(),
21            timestamp: "now".to_string(),
22            method: "grpc".to_string(),
23        }),
24        embedding: vec![],
25    };
26    
27    let triple2 = Triple {
28        subject: "http://example.org/Human".to_string(),
29        predicate: "http://www.w3.org/2000/01/rdf-schema#subClassOf".to_string(),
30        object: "http://example.org/Mortal".to_string(),
31        provenance: Some(Provenance {
32            source: "client_test".to_string(),
33            timestamp: "now".to_string(),
34            method: "grpc".to_string(),
35        }),
36        embedding: vec![],
37    };
38
39    println!("Sending IngestRequest...");
40    let response = client.ingest_triples(IngestRequest {
41        triples: vec![triple, triple2],
42        namespace: "test_verification".to_string(),
43    }).await?;
44    println!("Response: {:?}", response.into_inner());
45
46    // 2. Apply Reasoning (RDFS Transitivity)
47    println!("\nApplying RDFS Reasoning (Internal)...");
48    let reasoning_response = client.apply_reasoning(ReasoningRequest {
49        namespace: "test_verification".to_string(),
50        strategy: ReasoningStrategy::Rdfs as i32,
51        materialize: false,
52    }).await?;
53    println!("Reasoning Result: {:?}", reasoning_response.into_inner());
54
55    // 3. Hybrid Search
56    println!("\nPerforming Hybrid Search for 'Socrates'...");
57    let search_response = client.hybrid_search(HybridSearchRequest {
58        query: "Socrates".to_string(),
59        namespace: "test_verification".to_string(),
60        vector_k: 5,
61        graph_depth: 1,
62        mode: SearchMode::Hybrid as i32,
63        limit: 10,
64    }).await?;
65    
66    println!("Search Results:");
67    for result in search_response.into_inner().results {
68        println!(" - [Score: {:.4}] {} ({})", result.score, result.content, result.uri);
69    }
70
71    Ok(())
72}

Trait Implementations§

Source§

impl<T: Clone> Clone for SemanticEngineClient<T>

Source§

fn clone(&self) -> SemanticEngineClient<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for SemanticEngineClient<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for SemanticEngineClient<T>

§

impl<T> RefUnwindSafe for SemanticEngineClient<T>
where T: RefUnwindSafe,

§

impl<T> Send for SemanticEngineClient<T>
where T: Send,

§

impl<T> Sync for SemanticEngineClient<T>
where T: Sync,

§

impl<T> Unpin for SemanticEngineClient<T>
where T: Unpin,

§

impl<T> UnwindSafe for SemanticEngineClient<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more