pub struct OllamaClient { /* private fields */ }Implementations§
Source§impl OllamaClient
impl OllamaClient
Sourcepub fn new(model: &str) -> Result<Self>
pub fn new(model: &str) -> Result<Self>
Creates a new OllamaClient with the default Ollama URL (http://localhost:11434).
Checks that Ollama is reachable before returning.
Sourcepub fn new_with_url(base_url: &str, model: &str) -> Result<Self>
pub fn new_with_url(base_url: &str, model: &str) -> Result<Self>
Creates a new OllamaClient with a custom base URL.
Checks that Ollama is reachable before returning.
Sourcepub fn is_available(&self) -> bool
pub fn is_available(&self) -> bool
Quick health check – returns true if Ollama responds to GET /api/tags.
Sourcepub fn ensure_model(&self) -> Result<()>
pub fn ensure_model(&self) -> Result<()>
Checks if the configured model is already pulled. If not, pulls it.
Sourcepub fn generate(&self, prompt: &str, system: Option<&str>) -> Result<String>
pub fn generate(&self, prompt: &str, system: Option<&str>) -> Result<String>
Generates a completion using the /api/chat endpoint (Ollama chat format). This is compatible with both Ollama and vMLX/OpenAI-compatible servers. Returns the response text.
Sourcepub fn expand_query(&self, query: &str) -> Result<Vec<String>>
pub fn expand_query(&self, query: &str) -> Result<Vec<String>>
Uses the LLM to expand a search query into additional search terms.
Sourcepub fn summarize_memories(
&self,
memories: &[(String, String)],
) -> Result<String>
pub fn summarize_memories( &self, memories: &[(String, String)], ) -> Result<String>
Takes (title, content) pairs and returns a consolidated summary.
Sourcepub fn auto_tag(&self, title: &str, content: &str) -> Result<Vec<String>>
pub fn auto_tag(&self, title: &str, content: &str) -> Result<Vec<String>>
Generates suggested tags for a memory.
Sourcepub fn embed_text(&self, text: &str, embed_model: &str) -> Result<Vec<f32>>
pub fn embed_text(&self, text: &str, embed_model: &str) -> Result<Vec<f32>>
Generate an embedding vector via Ollama’s /api/embed endpoint.
Used for nomic-embed-text-v1.5 on smart/autonomous tiers.
Sourcepub fn ensure_embed_model(&self, model: &str) -> Result<()>
pub fn ensure_embed_model(&self, model: &str) -> Result<()>
Ensure an embedding model is pulled in Ollama.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OllamaClient
impl !RefUnwindSafe for OllamaClient
impl Send for OllamaClient
impl Sync for OllamaClient
impl Unpin for OllamaClient
impl UnsafeUnpin for OllamaClient
impl !UnwindSafe for OllamaClient
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
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>
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>
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