Skip to main content

ThoughtQuery

Struct ThoughtQuery 

Source
pub struct ThoughtQuery {
Show 13 fields pub thought_types: Option<Vec<ThoughtType>>, pub roles: Option<Vec<ThoughtRole>>, pub agent_ids: Option<Vec<String>>, pub agent_names: Option<Vec<String>>, pub agent_owners: Option<Vec<String>>, pub tags_any: Vec<String>, pub concepts_any: Vec<String>, pub text_contains: Option<String>, pub min_importance: Option<f32>, pub min_confidence: Option<f32>, pub since: Option<DateTime<Utc>>, pub until: Option<DateTime<Utc>>, pub limit: Option<usize>,
}
Expand description

Retrieval filter for semantic memory queries.

ThoughtQuery lets callers ask for slices of memory without replaying the entire chain.

ThoughtQuery is read-only. It does not create or modify thoughts. Its job is to select already-committed Thought records by semantic type, operational role, agent identity, tags, concepts, text, confidence, importance, and time range.

The relationship between the three main data shapes is:

  • ThoughtInput: proposed memory to append
  • Thought: committed durable memory
  • ThoughtQuery: retrieval filter over committed memory

§Example

use thoughtchain::{ThoughtQuery, ThoughtType};

let query = ThoughtQuery::new()
    .with_types(vec![ThoughtType::Decision, ThoughtType::Constraint])
    .with_min_importance(0.8);

assert!(query.min_importance.is_some());

Fields§

§thought_types: Option<Vec<ThoughtType>>

Semantic thought types to match.

§roles: Option<Vec<ThoughtRole>>

Operational roles to match.

§agent_ids: Option<Vec<String>>

Agent ids to match.

§agent_names: Option<Vec<String>>

Agent names to match.

§agent_owners: Option<Vec<String>>

Agent owners to match.

§tags_any: Vec<String>

Match if any tag matches.

§concepts_any: Vec<String>

Match if any concept matches.

§text_contains: Option<String>

Text filter applied to content, tags, and concepts.

§min_importance: Option<f32>

Minimum importance threshold.

§min_confidence: Option<f32>

Minimum confidence threshold.

§since: Option<DateTime<Utc>>

Start of the timestamp window, inclusive.

§until: Option<DateTime<Utc>>

End of the timestamp window, inclusive.

§limit: Option<usize>

Maximum number of thoughts to return.

Implementations§

Source§

impl ThoughtQuery

Source

pub fn new() -> Self

Create an empty query that matches every thought.

Source

pub fn with_types(self, thought_types: Vec<ThoughtType>) -> Self

Limit matches to the provided semantic thought types.

Source

pub fn with_roles(self, roles: Vec<ThoughtRole>) -> Self

Limit matches to the provided thought roles.

Source

pub fn with_agent_ids<I, S>(self, agent_ids: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Limit matches to the provided agent identifiers.

Source

pub fn with_agent_names<I, S>(self, agent_names: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Limit matches to the provided agent names.

Source

pub fn with_agent_owners<I, S>(self, agent_owners: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Limit matches to the provided agent owner labels.

Source

pub fn with_tags_any<I, S>(self, tags: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Match thoughts that have at least one of the provided tags.

Source

pub fn with_concepts_any<I, S>(self, concepts: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Match thoughts that have at least one of the provided concepts.

Source

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

Match thoughts whose content, tags, or concepts contain the provided text.

Source

pub fn with_min_importance(self, importance: f32) -> Self

Only match thoughts whose importance is at least this value.

Source

pub fn with_min_confidence(self, confidence: f32) -> Self

Only match thoughts whose confidence is at least this value.

Source

pub fn with_since(self, since: DateTime<Utc>) -> Self

Only match thoughts at or after the given timestamp.

Source

pub fn with_until(self, until: DateTime<Utc>) -> Self

Only match thoughts at or before the given timestamp.

Source

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

Limit the number of returned thoughts.

Trait Implementations§

Source§

impl Clone for ThoughtQuery

Source§

fn clone(&self) -> ThoughtQuery

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 Debug for ThoughtQuery

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ThoughtQuery

Source§

fn default() -> ThoughtQuery

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