pub struct OllamaModel { /* private fields */ }Available on crate feature
ollama only.Expand description
Ollama model client.
Implementations§
Source§impl OllamaModel
impl OllamaModel
Sourcepub const DEFAULT_BASE_URL: &'static str = "http://localhost:11434"
pub const DEFAULT_BASE_URL: &'static str = "http://localhost:11434"
Default Ollama base URL.
Sourcepub fn new(model_name: impl Into<String>) -> OllamaModel
pub fn new(model_name: impl Into<String>) -> OllamaModel
Create a new Ollama model.
Sourcepub fn from_env(
model_name: impl Into<String>,
) -> Result<OllamaModel, ModelError>
pub fn from_env( model_name: impl Into<String>, ) -> Result<OllamaModel, ModelError>
Create from environment variable OLLAMA_HOST.
Sourcepub fn with_base_url(self, url: impl Into<String>) -> OllamaModel
pub fn with_base_url(self, url: impl Into<String>) -> OllamaModel
Set custom base URL.
Sourcepub fn with_profile(self, profile: ModelProfile) -> OllamaModel
pub fn with_profile(self, profile: ModelProfile) -> OllamaModel
Set a custom profile.
Sourcepub fn with_timeout(self, timeout: Duration) -> OllamaModel
pub fn with_timeout(self, timeout: Duration) -> OllamaModel
Set the default timeout.
Sourcepub fn with_keep_alive(self, duration: impl Into<String>) -> OllamaModel
pub fn with_keep_alive(self, duration: impl Into<String>) -> OllamaModel
Set keep alive duration (e.g., “5m”, “1h”).
Trait Implementations§
Source§impl Clone for OllamaModel
impl Clone for OllamaModel
Source§fn clone(&self) -> OllamaModel
fn clone(&self) -> OllamaModel
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OllamaModel
impl Debug for OllamaModel
Source§impl Model for OllamaModel
impl Model for OllamaModel
Source§fn profile(&self) -> &ModelProfile
fn profile(&self) -> &ModelProfile
Get the model profile (capabilities, schema transforms).
Source§fn request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [ModelRequest],
settings: &'life2 ModelSettings,
params: &'life3 ModelRequestParameters,
) -> Pin<Box<dyn Future<Output = Result<ModelResponse, ModelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
OllamaModel: 'async_trait,
fn request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [ModelRequest],
settings: &'life2 ModelSettings,
params: &'life3 ModelRequestParameters,
) -> Pin<Box<dyn Future<Output = Result<ModelResponse, ModelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
OllamaModel: 'async_trait,
Make a request to the model.
Source§fn request_stream<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_messages: &'life1 [ModelRequest],
_settings: &'life2 ModelSettings,
_params: &'life3 ModelRequestParameters,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<ModelResponseStreamEvent, ModelError>> + Send>>, ModelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
OllamaModel: 'async_trait,
fn request_stream<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_messages: &'life1 [ModelRequest],
_settings: &'life2 ModelSettings,
_params: &'life3 ModelRequestParameters,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<ModelResponseStreamEvent, ModelError>> + Send>>, ModelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
OllamaModel: 'async_trait,
Make a streaming request to the model. Read more
Source§fn identifier(&self) -> String
fn identifier(&self) -> String
Get the full model identifier.
Source§fn count_tokens<'life0, 'life1, 'async_trait>(
&'life0 self,
_messages: &'life1 [ModelRequest],
) -> Pin<Box<dyn Future<Output = Result<u64, ModelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn count_tokens<'life0, 'life1, 'async_trait>(
&'life0 self,
_messages: &'life1 [ModelRequest],
) -> Pin<Box<dyn Future<Output = Result<u64, ModelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Count tokens for messages (if supported). Read more
Source§fn supports(&self, capability: ModelCapability) -> bool
fn supports(&self, capability: ModelCapability) -> bool
Check if the model supports a specific capability.
Auto Trait Implementations§
impl Freeze for OllamaModel
impl !RefUnwindSafe for OllamaModel
impl Send for OllamaModel
impl Sync for OllamaModel
impl Unpin for OllamaModel
impl !UnwindSafe for OllamaModel
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