pub struct OllamaProvider { /* private fields */ }Expand description
Ollama provider implementing Provider.
Connects to a locally running Ollama instance. No authentication is required by default.
§Example
use llm_stack_ollama::{OllamaConfig, OllamaProvider};
use llm_stack::{ChatParams, ChatMessage, Provider};
let provider = OllamaProvider::new(OllamaConfig::default());
let response = provider.generate(&ChatParams {
messages: vec![ChatMessage::user("Hello!")],
..Default::default()
}).await?;Implementations§
Source§impl OllamaProvider
impl OllamaProvider
Sourcepub fn new(config: OllamaConfig) -> Self
pub fn new(config: OllamaConfig) -> Self
Create a new Ollama provider from configuration.
If config.client is Some, that client is reused for connection
pooling. Otherwise a new client is built with the configured timeout.
Trait Implementations§
Source§impl Debug for OllamaProvider
impl Debug for OllamaProvider
Source§impl Provider for OllamaProvider
impl Provider for OllamaProvider
Source§async fn generate(&self, params: &ChatParams) -> Result<ChatResponse, LlmError>
async fn generate(&self, params: &ChatParams) -> Result<ChatResponse, LlmError>
Sends a chat completion request and returns the full response.
Source§async fn stream(&self, params: &ChatParams) -> Result<ChatStream, LlmError>
async fn stream(&self, params: &ChatParams) -> Result<ChatStream, LlmError>
Sends a chat completion request and returns a stream of events. Read more
Source§fn metadata(&self) -> ProviderMetadata
fn metadata(&self) -> ProviderMetadata
Returns static metadata describing this provider instance.
Auto Trait Implementations§
impl Freeze for OllamaProvider
impl !RefUnwindSafe for OllamaProvider
impl Send for OllamaProvider
impl Sync for OllamaProvider
impl Unpin for OllamaProvider
impl !UnwindSafe for OllamaProvider
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> DynProvider for Twhere
T: Provider,
impl<T> DynProvider for Twhere
T: Provider,
Source§fn generate_boxed<'a>(
&'a self,
params: &'a ChatParams,
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, LlmError>> + Send + 'a>>
fn generate_boxed<'a>( &'a self, params: &'a ChatParams, ) -> Pin<Box<dyn Future<Output = Result<ChatResponse, LlmError>> + Send + 'a>>
Boxed-future version of
Provider::generate.Source§fn stream_boxed<'a>(
&'a self,
params: &'a ChatParams,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamEvent, LlmError>> + Send>>, LlmError>> + Send + 'a>>
fn stream_boxed<'a>( &'a self, params: &'a ChatParams, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamEvent, LlmError>> + Send>>, LlmError>> + Send + 'a>>
Boxed-future version of
Provider::stream.Source§fn metadata(&self) -> ProviderMetadata
fn metadata(&self) -> ProviderMetadata
Returns static metadata describing this provider instance.