QueryBuilder

Struct QueryBuilder 

Source
pub struct QueryBuilder { /* private fields */ }
Expand description

Query builder for fluent API

ImplementationsΒ§

SourceΒ§

impl QueryBuilder

Source

pub fn new() -> Self

Examples found in repository?
examples/basic_usage.rs (line 82)
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9    println!("🧠 ExoGenesis Omega - Cosmic Memory System Demo\n");
10
11    // Initialize the cosmic memory system
12    let memory = CosmicMemory::new().await?;
13    println!("βœ… Initialized 12-tier cosmic memory system\n");
14
15    // Store memories in different tiers
16    println!("πŸ“ Storing memories across tiers...\n");
17
18    // Tier 1: Instant memory
19    let instant_mem = Memory::new(
20        MemoryTier::Instant,
21        MemoryContent::Text("Current thought: Processing user input".to_string()),
22        vec![0.1, 0.2, 0.3, 0.4],
23        0.3,
24    );
25    memory.store(instant_mem).await?;
26    println!("  [T1] Instant: Working memory stored");
27
28    // Tier 2: Session memory
29    let session_mem = Memory::new(
30        MemoryTier::Session,
31        MemoryContent::Text("Conversation context about Rust programming".to_string()),
32        vec![0.5, 0.6, 0.7, 0.8],
33        0.5,
34    );
35    memory.store(session_mem).await?;
36    println!("  [T2] Session: Conversation context stored");
37
38    // Tier 3: Episodic memory
39    let episodic_mem = Memory::new(
40        MemoryTier::Episodic,
41        MemoryContent::Text("Completed implementation of memory system on 2025-12-04".to_string()),
42        vec![0.2, 0.4, 0.6, 0.8],
43        0.7,
44    );
45    memory.store(episodic_mem).await?;
46    println!("  [T3] Episodic: Event memory stored");
47
48    // Tier 4: Semantic memory
49    let semantic_mem = Memory::new(
50        MemoryTier::Semantic,
51        MemoryContent::Text("Knowledge: Rust uses ownership for memory safety".to_string()),
52        vec![0.9, 0.8, 0.7, 0.6],
53        0.8,
54    );
55    memory.store(semantic_mem).await?;
56    println!("  [T4] Semantic: Knowledge stored");
57
58    // Tier 5: Collective memory
59    let collective_mem = Memory::new(
60        MemoryTier::Collective,
61        MemoryContent::Text("Shared pattern: Async/await improves concurrency".to_string()),
62        vec![0.7, 0.7, 0.7, 0.7],
63        0.75,
64    );
65    memory.store(collective_mem).await?;
66    println!("  [T5] Collective: Shared knowledge stored");
67
68    // Tier 12: Omega memory
69    let omega_mem = Memory::new(
70        MemoryTier::Omega,
71        MemoryContent::Text("Universal principle: Information cannot be destroyed".to_string()),
72        vec![1.0, 1.0, 1.0, 1.0],
73        0.99,
74    );
75    memory.store(omega_mem).await?;
76    println!("  [T12] Omega: Universal truth stored\n");
77
78    // Query memories
79    println!("πŸ” Querying memories...\n");
80
81    // Query individual scale memories
82    let query = QueryBuilder::new()
83        .individual()
84        .min_importance(0.5)
85        .build();
86
87    let results = memory.recall(&query, &[
88        MemoryTier::Instant,
89        MemoryTier::Session,
90        MemoryTier::Episodic,
91        MemoryTier::Semantic,
92    ]).await?;
93
94    println!("  Found {} memories in individual scale (T1-T4):", results.len());
95    for mem in &results {
96        if let MemoryContent::Text(text) = &mem.content {
97            println!("    - {}: {}", mem.tier, text);
98        }
99    }
100
101    // Memory statistics
102    println!("\nπŸ“Š Memory Statistics:\n");
103    let stats = memory.stats().await;
104    println!("  Individual Scale (T1-T4):");
105    println!("    - Instant: {}", stats.individual.instant);
106    println!("    - Session: {}", stats.individual.session);
107    println!("    - Episodic: {}", stats.individual.episodic);
108    println!("    - Semantic: {}", stats.individual.semantic);
109    println!("  Species Scale (T5-T8):");
110    println!("    - Collective: {}", stats.species.collective);
111    println!("    - Evolutionary: {}", stats.species.evolutionary);
112    println!("    - Architectural: {}", stats.species.architectural);
113    println!("    - Substrate: {}", stats.species.substrate);
114    println!("  Cosmic Scale (T9-T12):");
115    println!("    - Civilizational: {}", stats.cosmic.civilizational);
116    println!("    - Temporal: {}", stats.cosmic.temporal);
117    println!("    - Physical: {}", stats.cosmic.physical);
118    println!("    - Omega: {}", stats.cosmic.omega);
119    println!("\n  Total memories: {}", stats.total_memories);
120
121    // Run consolidation
122    println!("\nπŸ”„ Running automatic consolidation...");
123    memory.auto_consolidate().await?;
124    println!("βœ… Consolidation complete\n");
125
126    println!("πŸŽ‰ Demo complete!");
127
128    Ok(())
129}
Source

pub fn text(self, text: impl Into<String>) -> Self

Source

pub fn embedding(self, embedding: Vec<f32>) -> Self

Source

pub fn min_importance(self, importance: f64) -> Self

Examples found in repository?
examples/basic_usage.rs (line 84)
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9    println!("🧠 ExoGenesis Omega - Cosmic Memory System Demo\n");
10
11    // Initialize the cosmic memory system
12    let memory = CosmicMemory::new().await?;
13    println!("βœ… Initialized 12-tier cosmic memory system\n");
14
15    // Store memories in different tiers
16    println!("πŸ“ Storing memories across tiers...\n");
17
18    // Tier 1: Instant memory
19    let instant_mem = Memory::new(
20        MemoryTier::Instant,
21        MemoryContent::Text("Current thought: Processing user input".to_string()),
22        vec![0.1, 0.2, 0.3, 0.4],
23        0.3,
24    );
25    memory.store(instant_mem).await?;
26    println!("  [T1] Instant: Working memory stored");
27
28    // Tier 2: Session memory
29    let session_mem = Memory::new(
30        MemoryTier::Session,
31        MemoryContent::Text("Conversation context about Rust programming".to_string()),
32        vec![0.5, 0.6, 0.7, 0.8],
33        0.5,
34    );
35    memory.store(session_mem).await?;
36    println!("  [T2] Session: Conversation context stored");
37
38    // Tier 3: Episodic memory
39    let episodic_mem = Memory::new(
40        MemoryTier::Episodic,
41        MemoryContent::Text("Completed implementation of memory system on 2025-12-04".to_string()),
42        vec![0.2, 0.4, 0.6, 0.8],
43        0.7,
44    );
45    memory.store(episodic_mem).await?;
46    println!("  [T3] Episodic: Event memory stored");
47
48    // Tier 4: Semantic memory
49    let semantic_mem = Memory::new(
50        MemoryTier::Semantic,
51        MemoryContent::Text("Knowledge: Rust uses ownership for memory safety".to_string()),
52        vec![0.9, 0.8, 0.7, 0.6],
53        0.8,
54    );
55    memory.store(semantic_mem).await?;
56    println!("  [T4] Semantic: Knowledge stored");
57
58    // Tier 5: Collective memory
59    let collective_mem = Memory::new(
60        MemoryTier::Collective,
61        MemoryContent::Text("Shared pattern: Async/await improves concurrency".to_string()),
62        vec![0.7, 0.7, 0.7, 0.7],
63        0.75,
64    );
65    memory.store(collective_mem).await?;
66    println!("  [T5] Collective: Shared knowledge stored");
67
68    // Tier 12: Omega memory
69    let omega_mem = Memory::new(
70        MemoryTier::Omega,
71        MemoryContent::Text("Universal principle: Information cannot be destroyed".to_string()),
72        vec![1.0, 1.0, 1.0, 1.0],
73        0.99,
74    );
75    memory.store(omega_mem).await?;
76    println!("  [T12] Omega: Universal truth stored\n");
77
78    // Query memories
79    println!("πŸ” Querying memories...\n");
80
81    // Query individual scale memories
82    let query = QueryBuilder::new()
83        .individual()
84        .min_importance(0.5)
85        .build();
86
87    let results = memory.recall(&query, &[
88        MemoryTier::Instant,
89        MemoryTier::Session,
90        MemoryTier::Episodic,
91        MemoryTier::Semantic,
92    ]).await?;
93
94    println!("  Found {} memories in individual scale (T1-T4):", results.len());
95    for mem in &results {
96        if let MemoryContent::Text(text) = &mem.content {
97            println!("    - {}: {}", mem.tier, text);
98        }
99    }
100
101    // Memory statistics
102    println!("\nπŸ“Š Memory Statistics:\n");
103    let stats = memory.stats().await;
104    println!("  Individual Scale (T1-T4):");
105    println!("    - Instant: {}", stats.individual.instant);
106    println!("    - Session: {}", stats.individual.session);
107    println!("    - Episodic: {}", stats.individual.episodic);
108    println!("    - Semantic: {}", stats.individual.semantic);
109    println!("  Species Scale (T5-T8):");
110    println!("    - Collective: {}", stats.species.collective);
111    println!("    - Evolutionary: {}", stats.species.evolutionary);
112    println!("    - Architectural: {}", stats.species.architectural);
113    println!("    - Substrate: {}", stats.species.substrate);
114    println!("  Cosmic Scale (T9-T12):");
115    println!("    - Civilizational: {}", stats.cosmic.civilizational);
116    println!("    - Temporal: {}", stats.cosmic.temporal);
117    println!("    - Physical: {}", stats.cosmic.physical);
118    println!("    - Omega: {}", stats.cosmic.omega);
119    println!("\n  Total memories: {}", stats.total_memories);
120
121    // Run consolidation
122    println!("\nπŸ”„ Running automatic consolidation...");
123    memory.auto_consolidate().await?;
124    println!("βœ… Consolidation complete\n");
125
126    println!("πŸŽ‰ Demo complete!");
127
128    Ok(())
129}
Source

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

Source

pub fn tier(self, tier: MemoryTier) -> Self

Source

pub fn tiers(self, tiers: Vec<MemoryTier>) -> Self

Source

pub fn instant(self) -> Self

Source

pub fn session(self) -> Self

Source

pub fn episodic(self) -> Self

Source

pub fn semantic(self) -> Self

Source

pub fn individual(self) -> Self

Examples found in repository?
examples/basic_usage.rs (line 83)
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9    println!("🧠 ExoGenesis Omega - Cosmic Memory System Demo\n");
10
11    // Initialize the cosmic memory system
12    let memory = CosmicMemory::new().await?;
13    println!("βœ… Initialized 12-tier cosmic memory system\n");
14
15    // Store memories in different tiers
16    println!("πŸ“ Storing memories across tiers...\n");
17
18    // Tier 1: Instant memory
19    let instant_mem = Memory::new(
20        MemoryTier::Instant,
21        MemoryContent::Text("Current thought: Processing user input".to_string()),
22        vec![0.1, 0.2, 0.3, 0.4],
23        0.3,
24    );
25    memory.store(instant_mem).await?;
26    println!("  [T1] Instant: Working memory stored");
27
28    // Tier 2: Session memory
29    let session_mem = Memory::new(
30        MemoryTier::Session,
31        MemoryContent::Text("Conversation context about Rust programming".to_string()),
32        vec![0.5, 0.6, 0.7, 0.8],
33        0.5,
34    );
35    memory.store(session_mem).await?;
36    println!("  [T2] Session: Conversation context stored");
37
38    // Tier 3: Episodic memory
39    let episodic_mem = Memory::new(
40        MemoryTier::Episodic,
41        MemoryContent::Text("Completed implementation of memory system on 2025-12-04".to_string()),
42        vec![0.2, 0.4, 0.6, 0.8],
43        0.7,
44    );
45    memory.store(episodic_mem).await?;
46    println!("  [T3] Episodic: Event memory stored");
47
48    // Tier 4: Semantic memory
49    let semantic_mem = Memory::new(
50        MemoryTier::Semantic,
51        MemoryContent::Text("Knowledge: Rust uses ownership for memory safety".to_string()),
52        vec![0.9, 0.8, 0.7, 0.6],
53        0.8,
54    );
55    memory.store(semantic_mem).await?;
56    println!("  [T4] Semantic: Knowledge stored");
57
58    // Tier 5: Collective memory
59    let collective_mem = Memory::new(
60        MemoryTier::Collective,
61        MemoryContent::Text("Shared pattern: Async/await improves concurrency".to_string()),
62        vec![0.7, 0.7, 0.7, 0.7],
63        0.75,
64    );
65    memory.store(collective_mem).await?;
66    println!("  [T5] Collective: Shared knowledge stored");
67
68    // Tier 12: Omega memory
69    let omega_mem = Memory::new(
70        MemoryTier::Omega,
71        MemoryContent::Text("Universal principle: Information cannot be destroyed".to_string()),
72        vec![1.0, 1.0, 1.0, 1.0],
73        0.99,
74    );
75    memory.store(omega_mem).await?;
76    println!("  [T12] Omega: Universal truth stored\n");
77
78    // Query memories
79    println!("πŸ” Querying memories...\n");
80
81    // Query individual scale memories
82    let query = QueryBuilder::new()
83        .individual()
84        .min_importance(0.5)
85        .build();
86
87    let results = memory.recall(&query, &[
88        MemoryTier::Instant,
89        MemoryTier::Session,
90        MemoryTier::Episodic,
91        MemoryTier::Semantic,
92    ]).await?;
93
94    println!("  Found {} memories in individual scale (T1-T4):", results.len());
95    for mem in &results {
96        if let MemoryContent::Text(text) = &mem.content {
97            println!("    - {}: {}", mem.tier, text);
98        }
99    }
100
101    // Memory statistics
102    println!("\nπŸ“Š Memory Statistics:\n");
103    let stats = memory.stats().await;
104    println!("  Individual Scale (T1-T4):");
105    println!("    - Instant: {}", stats.individual.instant);
106    println!("    - Session: {}", stats.individual.session);
107    println!("    - Episodic: {}", stats.individual.episodic);
108    println!("    - Semantic: {}", stats.individual.semantic);
109    println!("  Species Scale (T5-T8):");
110    println!("    - Collective: {}", stats.species.collective);
111    println!("    - Evolutionary: {}", stats.species.evolutionary);
112    println!("    - Architectural: {}", stats.species.architectural);
113    println!("    - Substrate: {}", stats.species.substrate);
114    println!("  Cosmic Scale (T9-T12):");
115    println!("    - Civilizational: {}", stats.cosmic.civilizational);
116    println!("    - Temporal: {}", stats.cosmic.temporal);
117    println!("    - Physical: {}", stats.cosmic.physical);
118    println!("    - Omega: {}", stats.cosmic.omega);
119    println!("\n  Total memories: {}", stats.total_memories);
120
121    // Run consolidation
122    println!("\nπŸ”„ Running automatic consolidation...");
123    memory.auto_consolidate().await?;
124    println!("βœ… Consolidation complete\n");
125
126    println!("πŸŽ‰ Demo complete!");
127
128    Ok(())
129}
Source

pub fn species(self) -> Self

Source

pub fn cosmic(self) -> Self

Source

pub fn all_tiers(self) -> Self

Source

pub fn metadata(self, metadata: Value) -> Self

Source

pub fn build(self) -> Query

Examples found in repository?
examples/basic_usage.rs (line 85)
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9    println!("🧠 ExoGenesis Omega - Cosmic Memory System Demo\n");
10
11    // Initialize the cosmic memory system
12    let memory = CosmicMemory::new().await?;
13    println!("βœ… Initialized 12-tier cosmic memory system\n");
14
15    // Store memories in different tiers
16    println!("πŸ“ Storing memories across tiers...\n");
17
18    // Tier 1: Instant memory
19    let instant_mem = Memory::new(
20        MemoryTier::Instant,
21        MemoryContent::Text("Current thought: Processing user input".to_string()),
22        vec![0.1, 0.2, 0.3, 0.4],
23        0.3,
24    );
25    memory.store(instant_mem).await?;
26    println!("  [T1] Instant: Working memory stored");
27
28    // Tier 2: Session memory
29    let session_mem = Memory::new(
30        MemoryTier::Session,
31        MemoryContent::Text("Conversation context about Rust programming".to_string()),
32        vec![0.5, 0.6, 0.7, 0.8],
33        0.5,
34    );
35    memory.store(session_mem).await?;
36    println!("  [T2] Session: Conversation context stored");
37
38    // Tier 3: Episodic memory
39    let episodic_mem = Memory::new(
40        MemoryTier::Episodic,
41        MemoryContent::Text("Completed implementation of memory system on 2025-12-04".to_string()),
42        vec![0.2, 0.4, 0.6, 0.8],
43        0.7,
44    );
45    memory.store(episodic_mem).await?;
46    println!("  [T3] Episodic: Event memory stored");
47
48    // Tier 4: Semantic memory
49    let semantic_mem = Memory::new(
50        MemoryTier::Semantic,
51        MemoryContent::Text("Knowledge: Rust uses ownership for memory safety".to_string()),
52        vec![0.9, 0.8, 0.7, 0.6],
53        0.8,
54    );
55    memory.store(semantic_mem).await?;
56    println!("  [T4] Semantic: Knowledge stored");
57
58    // Tier 5: Collective memory
59    let collective_mem = Memory::new(
60        MemoryTier::Collective,
61        MemoryContent::Text("Shared pattern: Async/await improves concurrency".to_string()),
62        vec![0.7, 0.7, 0.7, 0.7],
63        0.75,
64    );
65    memory.store(collective_mem).await?;
66    println!("  [T5] Collective: Shared knowledge stored");
67
68    // Tier 12: Omega memory
69    let omega_mem = Memory::new(
70        MemoryTier::Omega,
71        MemoryContent::Text("Universal principle: Information cannot be destroyed".to_string()),
72        vec![1.0, 1.0, 1.0, 1.0],
73        0.99,
74    );
75    memory.store(omega_mem).await?;
76    println!("  [T12] Omega: Universal truth stored\n");
77
78    // Query memories
79    println!("πŸ” Querying memories...\n");
80
81    // Query individual scale memories
82    let query = QueryBuilder::new()
83        .individual()
84        .min_importance(0.5)
85        .build();
86
87    let results = memory.recall(&query, &[
88        MemoryTier::Instant,
89        MemoryTier::Session,
90        MemoryTier::Episodic,
91        MemoryTier::Semantic,
92    ]).await?;
93
94    println!("  Found {} memories in individual scale (T1-T4):", results.len());
95    for mem in &results {
96        if let MemoryContent::Text(text) = &mem.content {
97            println!("    - {}: {}", mem.tier, text);
98        }
99    }
100
101    // Memory statistics
102    println!("\nπŸ“Š Memory Statistics:\n");
103    let stats = memory.stats().await;
104    println!("  Individual Scale (T1-T4):");
105    println!("    - Instant: {}", stats.individual.instant);
106    println!("    - Session: {}", stats.individual.session);
107    println!("    - Episodic: {}", stats.individual.episodic);
108    println!("    - Semantic: {}", stats.individual.semantic);
109    println!("  Species Scale (T5-T8):");
110    println!("    - Collective: {}", stats.species.collective);
111    println!("    - Evolutionary: {}", stats.species.evolutionary);
112    println!("    - Architectural: {}", stats.species.architectural);
113    println!("    - Substrate: {}", stats.species.substrate);
114    println!("  Cosmic Scale (T9-T12):");
115    println!("    - Civilizational: {}", stats.cosmic.civilizational);
116    println!("    - Temporal: {}", stats.cosmic.temporal);
117    println!("    - Physical: {}", stats.cosmic.physical);
118    println!("    - Omega: {}", stats.cosmic.omega);
119    println!("\n  Total memories: {}", stats.total_memories);
120
121    // Run consolidation
122    println!("\nπŸ”„ Running automatic consolidation...");
123    memory.auto_consolidate().await?;
124    println!("βœ… Consolidation complete\n");
125
126    println!("πŸŽ‰ Demo complete!");
127
128    Ok(())
129}

Trait ImplementationsΒ§

SourceΒ§

impl Default for QueryBuilder

SourceΒ§

fn default() -> Self

Returns the β€œdefault value” for a type. Read more

Auto Trait ImplementationsΒ§

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> From<T> for T

SourceΒ§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.