pub struct OllamaClient { /* private fields */ }Expand description
Client for Ollama local LLM inference
§API Details
- Base URL: http://localhost:11434/api (default)
- No rate limit (local service)
- No API key required
- Falls back to mock data when Ollama is not running
Implementations§
Source§impl OllamaClient
impl OllamaClient
Sourcepub fn with_base_url(base_url: &str) -> Self
pub fn with_base_url(base_url: &str) -> Self
Create a new Ollama client with custom base URL
§Arguments
base_url- Ollama API base URL (e.g., “http://localhost:11434/api”)
Sourcepub async fn is_available(&self) -> bool
pub async fn is_available(&self) -> bool
Check if Ollama is available
Sourcepub async fn list_models(&mut self) -> Result<Vec<OllamaModel>>
pub async fn list_models(&mut self) -> Result<Vec<OllamaModel>>
List available models
Sourcepub async fn generate(&mut self, model: &str, prompt: &str) -> Result<String>
pub async fn generate(&mut self, model: &str, prompt: &str) -> Result<String>
Generate text completion
§Arguments
model- Model name (e.g., “llama2”, “mistral”)prompt- Prompt text
Sourcepub async fn chat(
&mut self,
model: &str,
messages: Vec<OllamaChatMessage>,
) -> Result<String>
pub async fn chat( &mut self, model: &str, messages: Vec<OllamaChatMessage>, ) -> Result<String>
Sourcepub async fn pull_model(&mut self, name: &str) -> Result<bool>
pub async fn pull_model(&mut self, name: &str) -> Result<bool>
Sourcepub fn model_to_vector(&self, model: &OllamaModel) -> SemanticVector
pub fn model_to_vector(&self, model: &OllamaModel) -> SemanticVector
Convert Ollama model to SemanticVector
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 !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
Mutably borrows from an owned value. Read more
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