pub struct PythonEmbeddingProvider { /* private fields */ }Expand description
Real embedding provider backed by the bundled embed.py subprocess
(sentence-transformers / MiniLM). Wire protocol (see embed.py):
the script writes a u32 LE dimension header on stdout, then for every
line it reads on stdin it writes dim * f32 LE bytes on stdout.
The child is spawned once and kept alive; reads are bounded by a timeout so a hung model can never block the host process forever.
Implementations§
Source§impl PythonEmbeddingProvider
impl PythonEmbeddingProvider
Sourcepub fn new(model: &str) -> Result<Self, EmbeddingError>
pub fn new(model: &str) -> Result<Self, EmbeddingError>
Spawn embed.py with the given HuggingFace model id and read the
dimension header. Python binary, script path and timeout can be
overridden via MICROSCOPE_PYTHON, MICROSCOPE_EMBED_SCRIPT and
MICROSCOPE_EMBED_TIMEOUT_MS respectively.
Trait Implementations§
Source§impl Drop for PythonEmbeddingProvider
Available on non-WebAssembly only.
impl Drop for PythonEmbeddingProvider
Available on non-WebAssembly only.
Source§impl EmbeddingProvider for PythonEmbeddingProvider
Available on non-WebAssembly only.
impl EmbeddingProvider for PythonEmbeddingProvider
Available on non-WebAssembly only.
Auto Trait Implementations§
impl !Freeze for PythonEmbeddingProvider
impl RefUnwindSafe for PythonEmbeddingProvider
impl Send for PythonEmbeddingProvider
impl Sync for PythonEmbeddingProvider
impl Unpin for PythonEmbeddingProvider
impl UnsafeUnpin for PythonEmbeddingProvider
impl UnwindSafe for PythonEmbeddingProvider
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
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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