Skip to main content

Knowledge

Struct Knowledge 

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

A folder an agent can search: Knowledge::dir("docs") plus settings. At build the folder is ingested into index index of the store file (unchanged files skipped) and the agent gets the search_knowledge tool. The embedder defaults to the catalog’s for the agent’s vendor.

Implementations§

Source§

impl Knowledge

Source

pub fn dir(dir: impl AsRef<Path>) -> Self

Starts settings for folder dir, read at build. Index docs, the agent’s SQLite checkpoint file or ./troupekit.db, and the ingest_dir walk and chunk defaults.

Source

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

Sets the vector index and scope the folder is stored under. 1 to 64 of [a-z0-9_], checked at build. Default docs.

Source

pub fn store(self, path: impl AsRef<Path>) -> Self

Sets the SQLite file the index lives in. Default: the agent’s Storage::sqlite file, else ./troupekit.db. Returns the settings.

Source

pub fn embedder(self, embedder: Arc<dyn Embedder>) -> Self

Sets the embedder for the folder and for searches, overriding the catalog embedder of the agent’s vendor; dimensions must match an existing index of the same name. Returns the settings.

Source

pub fn on_device_embedder(self, embedder: Arc<dyn Embedder>) -> Self

Sets an embedder that runs on the device, with no network, and marks it so: a private agent accepts only such an embedder. Otherwise the same as embedder.

Source

pub fn local_embedder(self, choice: impl Into<LocalChoice>) -> Self

Embeds on the device with a local model: a catalog id, a GGUF file or a loaded Arc<dyn LocalModel>, loaded at build like Agent::local. Marks the embedder on-device for private agents.

Source

pub fn load(self, load: LoadSettings) -> Self

Sets the folder walk bounds and filters. Default LoadSettings::default(). Returns the settings.

Source

pub fn chunk(self, chunk: ChunkConfig) -> Self

Sets the chunk size and overlap, in estimated tokens. Default 200 tokens with 20 of overlap. Returns the settings.

Source§

impl Knowledge

Source

pub fn allow_failed(self, allow: bool) -> Self

Lets build succeed when some files fail to ingest; the rest is searchable and failed files are retried on the next build. Default false: build fails and lists the failed files.

Trait Implementations§

Source§

impl Clone for Knowledge

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Knowledge

Source§

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

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

impl From<&Path> for Knowledge

Source§

fn from(dir: &Path) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for Knowledge

Source§

fn from(dir: &str) -> Self

Converts to this type from the input type.
Source§

impl From<PathBuf> for Knowledge

Source§

fn from(dir: PathBuf) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Knowledge

§

impl !UnwindSafe for Knowledge

§

impl Forget for Knowledge

§

impl Freeze for Knowledge
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const ArcInner<dyn Embedder> is !null: Freeze, PhantomData<ArcInner<dyn Embedder>>: Freeze, *const ArcInner<dyn LocalModel> is !null: Freeze, PhantomData<ArcInner<dyn LocalModel>>: Freeze, PhantomData<String>: Freeze,

§

impl Move for Knowledge

§

impl Send for Knowledge
where RawVecInner: Send, Arc<dyn Embedder>: Send, Arc<dyn LocalModel>: Send,

§

impl Sync for Knowledge
where RawVecInner: Sync, Arc<dyn Embedder>: Sync, Arc<dyn LocalModel>: Sync,

§

impl Unpin for Knowledge
where *const u8 is !null: Unpin, Arc<dyn Embedder>: Unpin, Arc<dyn LocalModel>: Unpin,

§

impl UnsafeUnpin for Knowledge

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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