pub struct Client { /* private fields */ }Expand description
High-level RSLLM client
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(config: ClientConfig) -> RsllmResult<Self>
pub fn new(config: ClientConfig) -> RsllmResult<Self>
Create a new client with configuration
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Create a client builder
Sourcepub fn from_env() -> RsllmResult<Self>
pub fn from_env() -> RsllmResult<Self>
Create a client from environment variables
Sourcepub fn config(&self) -> &ClientConfig
pub fn config(&self) -> &ClientConfig
Get client configuration
Sourcepub fn provider(&self) -> &Arc<dyn LLMProvider>
pub fn provider(&self) -> &Arc<dyn LLMProvider>
Get provider instance
Sourcepub fn add_metadata(&mut self, key: impl Into<String>, value: Value)
pub fn add_metadata(&mut self, key: impl Into<String>, value: Value)
Add client metadata
Sourcepub async fn health_check(&self) -> RsllmResult<bool>
pub async fn health_check(&self) -> RsllmResult<bool>
Health check for the underlying provider
Sourcepub fn supported_models(&self) -> Vec<String>
pub fn supported_models(&self) -> Vec<String>
Get supported models from the provider
Sourcepub async fn chat_completion(
&self,
messages: Vec<ChatMessage>,
) -> RsllmResult<ChatResponse>
pub async fn chat_completion( &self, messages: Vec<ChatMessage>, ) -> RsllmResult<ChatResponse>
Chat completion (non-streaming)
Sourcepub async fn chat_completion_with_options(
&self,
messages: Vec<ChatMessage>,
model: Option<&str>,
temperature: Option<f32>,
max_tokens: Option<u32>,
) -> RsllmResult<ChatResponse>
pub async fn chat_completion_with_options( &self, messages: Vec<ChatMessage>, model: Option<&str>, temperature: Option<f32>, max_tokens: Option<u32>, ) -> RsllmResult<ChatResponse>
Chat completion with custom options
Sourcepub async fn chat_completion_with_tools(
&self,
messages: Vec<ChatMessage>,
tools: Vec<ToolDefinition>,
) -> RsllmResult<ChatResponse>
pub async fn chat_completion_with_tools( &self, messages: Vec<ChatMessage>, tools: Vec<ToolDefinition>, ) -> RsllmResult<ChatResponse>
Chat completion with tool calling support
Sourcepub async fn chat_completion_with_tools_and_options(
&self,
messages: Vec<ChatMessage>,
tools: Vec<ToolDefinition>,
model: Option<&str>,
temperature: Option<f32>,
max_tokens: Option<u32>,
) -> RsllmResult<ChatResponse>
pub async fn chat_completion_with_tools_and_options( &self, messages: Vec<ChatMessage>, tools: Vec<ToolDefinition>, model: Option<&str>, temperature: Option<f32>, max_tokens: Option<u32>, ) -> RsllmResult<ChatResponse>
Chat completion with tools and custom options
Sourcepub async fn chat_completion_stream(
&self,
messages: Vec<ChatMessage>,
) -> RsllmResult<ChatStream>
pub async fn chat_completion_stream( &self, messages: Vec<ChatMessage>, ) -> RsllmResult<ChatStream>
Chat completion (streaming)
Sourcepub async fn chat_completion_stream_with_options(
&self,
messages: Vec<ChatMessage>,
model: Option<&str>,
temperature: Option<f32>,
max_tokens: Option<u32>,
) -> RsllmResult<ChatStream>
pub async fn chat_completion_stream_with_options( &self, messages: Vec<ChatMessage>, model: Option<&str>, temperature: Option<f32>, max_tokens: Option<u32>, ) -> RsllmResult<ChatStream>
Chat completion streaming with custom options
Sourcepub async fn complete(&self, prompt: impl Into<String>) -> RsllmResult<String>
pub async fn complete(&self, prompt: impl Into<String>) -> RsllmResult<String>
Simple text completion
Sourcepub async fn complete_stream(
&self,
prompt: impl Into<String>,
) -> RsllmResult<ChatStream>
pub async fn complete_stream( &self, prompt: impl Into<String>, ) -> RsllmResult<ChatStream>
Simple streaming text completion
Sourcepub async fn create_embeddings(
&self,
_inputs: Vec<String>,
) -> RsllmResult<EmbeddingResponse>
pub async fn create_embeddings( &self, _inputs: Vec<String>, ) -> RsllmResult<EmbeddingResponse>
Create embeddings (placeholder - would need provider support)
Sourcepub fn count_tokens(&self, _text: &str) -> RsllmResult<u32>
pub fn count_tokens(&self, _text: &str) -> RsllmResult<u32>
Count tokens in text (placeholder - would need tokenizer)
Trait Implementations§
Source§impl AsyncClient for Client
impl AsyncClient for Client
Source§fn chat_completion<'life0, 'async_trait>(
&'life0 self,
messages: Vec<ChatMessage>,
) -> Pin<Box<dyn Future<Output = RsllmResult<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn chat_completion<'life0, 'async_trait>(
&'life0 self,
messages: Vec<ChatMessage>,
) -> Pin<Box<dyn Future<Output = RsllmResult<ChatResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Chat completion
Source§fn chat_completion_stream<'life0, 'async_trait>(
&'life0 self,
messages: Vec<ChatMessage>,
) -> Pin<Box<dyn Future<Output = RsllmResult<ChatStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn chat_completion_stream<'life0, 'async_trait>(
&'life0 self,
messages: Vec<ChatMessage>,
) -> Pin<Box<dyn Future<Output = RsllmResult<ChatStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Chat completion streaming
Source§fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = RsllmResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = RsllmResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Health check
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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