pub struct LlmEmbedding { /* private fields */ }Implementations§
Source§impl LlmEmbedding
impl LlmEmbedding
Sourcepub fn detect_available() -> Result<Self, AppError>
pub fn detect_available() -> Result<Self, AppError>
Detects which LLM CLI is available on PATH and returns the matching embedding client.
v1.0.76: PREFERS codex over claude because:
- Claude Code 2.1+ ships a 180k+ token system context (plugins,
skills, agents, MCP) that overflows the 200k context window
for even trivial embedding prompts and returns “Prompt is too
long”. (v1.0.79/S6 mitigates this with an empty
CLAUDE_CONFIG_DIR, but codex stays the lighter default.) - Codex 0.134+ is lightweight (~5k system context) and the
StructuredOutputtool reliably returns the requested vectors.
pub fn with_codex() -> Result<Self, AppError>
pub fn with_claude() -> Result<Self, AppError>
Sourcepub fn embed_passage(&self, text: &str) -> Result<Vec<f32>, AppError>
pub fn embed_passage(&self, text: &str) -> Result<Vec<f32>, AppError>
Embeds a single passage (chunk of a memory body). Returns an f32 vector of the active dimensionality.
Sourcepub fn embed_query(&self, text: &str) -> Result<Vec<f32>, AppError>
pub fn embed_query(&self, text: &str) -> Result<Vec<f32>, AppError>
Embeds a single query. The LLM uses a different prompt prefix to disambiguate query from passage.
Sourcepub async fn embed_batch_async(
&self,
prefix: &str,
batch: &[(usize, String)],
) -> Result<Vec<(usize, Vec<f32>)>, AppError>
pub async fn embed_batch_async( &self, prefix: &str, batch: &[(usize, String)], ) -> Result<Vec<(usize, Vec<f32>)>, AppError>
G42/S2: embeds a batch of (global_index, text) pairs in ONE
LLM call. Returns (global_index, vector) pairs. Async — this
is the unit of work scheduled by the bounded fan-out in
crate::embedder.
Cancel safety: the future owns its subprocess via
kill_on_drop(true), so dropping it (e.g. losing a
tokio::select! race against a cancellation token) kills the
child and leaks nothing.
Trait Implementations§
Source§impl Clone for LlmEmbedding
impl Clone for LlmEmbedding
Source§fn clone(&self) -> LlmEmbedding
fn clone(&self) -> LlmEmbedding
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for LlmEmbedding
impl !UnwindSafe for LlmEmbedding
impl Freeze for LlmEmbedding
impl Send for LlmEmbedding
impl Sync for LlmEmbedding
impl Unpin for LlmEmbedding
impl UnsafeUnpin for LlmEmbedding
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more