pub struct MonoAI { /* private fields */ }
Implementations§
Source§impl MonoAI
impl MonoAI
Sourcepub fn ollama(endpoint: String, model: String) -> Self
pub fn ollama(endpoint: String, model: String) -> Self
Create Ollama client with endpoint URL and model name
Sourcepub fn anthropic(api_key: String, model: String) -> Self
pub fn anthropic(api_key: String, model: String) -> Self
Create Anthropic client with API key and model name
Sourcepub fn openai(api_key: String, model: String) -> Self
pub fn openai(api_key: String, model: String) -> Self
Create OpenAI client with API key and model name
Sourcepub fn openrouter(api_key: String, model: String) -> Self
pub fn openrouter(api_key: String, model: String) -> Self
Create OpenRouter client with API key and model name
Sourcepub async fn add_tool(&mut self, tool: Tool) -> Result<(), Box<dyn Error>>
pub async fn add_tool(&mut self, tool: Tool) -> Result<(), Box<dyn Error>>
Add function tool to client. Automatically enables fallback mode for non-supporting models
Sourcepub async fn is_fallback_mode(&self) -> bool
pub async fn is_fallback_mode(&self) -> bool
Check if client is using fallback tool calling (XML prompting vs native tools)
Sourcepub fn set_debug_mode(&mut self, debug: bool)
pub fn set_debug_mode(&mut self, debug: bool)
Enable/disable debug mode to show raw tool call XML in fallback mode
Sourcepub fn debug_mode(&self) -> bool
pub fn debug_mode(&self) -> bool
Check if debug mode is enabled
Sourcepub async fn supports_tool_calls(&self) -> Result<bool, Box<dyn Error>>
pub async fn supports_tool_calls(&self) -> Result<bool, Box<dyn Error>>
Check if model supports native tool calling by examining template
Sourcepub async fn send_chat_request(
&self,
messages: &[Message],
) -> Result<Pin<Box<dyn Stream<Item = Result<ChatStreamItem, String>> + Send>>, Box<dyn Error>>
pub async fn send_chat_request( &self, messages: &[Message], ) -> Result<Pin<Box<dyn Stream<Item = Result<ChatStreamItem, String>> + Send>>, Box<dyn Error>>
Send chat request with real-time streaming response
Sourcepub async fn send_chat_request_no_stream(
&self,
messages: &[Message],
) -> Result<(String, Option<Vec<ToolCall>>), Box<dyn Error>>
pub async fn send_chat_request_no_stream( &self, messages: &[Message], ) -> Result<(String, Option<Vec<ToolCall>>), Box<dyn Error>>
Send chat request without streaming, returns complete response and tool calls
Sourcepub async fn send_chat_request_with_images(
&self,
messages: &[Message],
image_paths: Vec<String>,
) -> Result<Pin<Box<dyn Stream<Item = Result<ChatStreamItem, String>> + Send>>, Box<dyn Error>>
pub async fn send_chat_request_with_images( &self, messages: &[Message], image_paths: Vec<String>, ) -> Result<Pin<Box<dyn Stream<Item = Result<ChatStreamItem, String>> + Send>>, Box<dyn Error>>
Send chat request with images from file paths, returns real-time streaming response
Sourcepub async fn send_chat_request_with_images_no_stream(
&self,
messages: &[Message],
image_paths: Vec<String>,
) -> Result<(String, Option<Vec<ToolCall>>), Box<dyn Error>>
pub async fn send_chat_request_with_images_no_stream( &self, messages: &[Message], image_paths: Vec<String>, ) -> Result<(String, Option<Vec<ToolCall>>), Box<dyn Error>>
Send chat request with images from file paths, returns complete response and tool calls
Sourcepub async fn send_chat_request_with_image_data(
&self,
messages: &[Message],
images_data: Vec<Vec<u8>>,
) -> Result<Pin<Box<dyn Stream<Item = Result<ChatStreamItem, String>> + Send>>, Box<dyn Error>>
pub async fn send_chat_request_with_image_data( &self, messages: &[Message], images_data: Vec<Vec<u8>>, ) -> Result<Pin<Box<dyn Stream<Item = Result<ChatStreamItem, String>> + Send>>, Box<dyn Error>>
Send chat request with image data from memory, returns real-time streaming response (single image: vec![data], multiple: vec![data1, data2])
Sourcepub async fn send_chat_request_with_image_data_no_stream(
&self,
messages: &[Message],
images_data: Vec<Vec<u8>>,
) -> Result<(String, Option<Vec<ToolCall>>), Box<dyn Error>>
pub async fn send_chat_request_with_image_data_no_stream( &self, messages: &[Message], images_data: Vec<Vec<u8>>, ) -> Result<(String, Option<Vec<ToolCall>>), Box<dyn Error>>
Send chat request with image data from memory, returns complete response and tool calls (single image: vec![data], multiple: vec![data1, data2])
Sourcepub async fn generate(&self, prompt: &str) -> Result<String, Box<dyn Error>>
pub async fn generate(&self, prompt: &str) -> Result<String, Box<dyn Error>>
Generate single completion from prompt without conversation context
Sourcepub async fn generate_stream(
&self,
prompt: &str,
) -> Result<Pin<Box<dyn Stream<Item = Result<String, String>> + Send>>, Box<dyn Error>>
pub async fn generate_stream( &self, prompt: &str, ) -> Result<Pin<Box<dyn Stream<Item = Result<String, String>> + Send>>, Box<dyn Error>>
Generate streaming completion from prompt without conversation context
Sourcepub async fn get_available_models(
&self,
) -> Result<Vec<MonoModel>, Box<dyn Error>>
pub async fn get_available_models( &self, ) -> Result<Vec<MonoModel>, Box<dyn Error>>
Get available models from any provider
Sourcepub async fn list_local_models(&self) -> Result<Vec<Model>, Box<dyn Error>>
pub async fn list_local_models(&self) -> Result<Vec<Model>, Box<dyn Error>>
List locally installed models (legacy method, use get_available_models instead)
Sourcepub async fn show_model_info(
&self,
model_name: &str,
) -> Result<ModelInfo, Box<dyn Error>>
pub async fn show_model_info( &self, model_name: &str, ) -> Result<ModelInfo, Box<dyn Error>>
Get detailed model information including template and parameters
Sourcepub async fn pull_model(&self, model_name: &str) -> Result<(), Box<dyn Error>>
pub async fn pull_model(&self, model_name: &str) -> Result<(), Box<dyn Error>>
Download model from provider registry (provider-specific operation)
Sourcepub async fn pull_model_stream(
&self,
model_name: &str,
) -> Result<Pin<Box<dyn Stream<Item = Result<PullProgress, String>> + Send>>, Box<dyn Error>>
pub async fn pull_model_stream( &self, model_name: &str, ) -> Result<Pin<Box<dyn Stream<Item = Result<PullProgress, String>> + Send>>, Box<dyn Error>>
Download model with streaming progress updates (provider-specific operation)
Sourcepub async fn handle_tool_calls(&self, tool_calls: Vec<ToolCall>) -> Vec<Message>
pub async fn handle_tool_calls(&self, tool_calls: Vec<ToolCall>) -> Vec<Message>
Execute tool calls and return formatted messages for conversation continuation
Sourcepub async fn process_fallback_response(
&self,
content: &str,
) -> (String, Option<Vec<ToolCall>>)
pub async fn process_fallback_response( &self, content: &str, ) -> (String, Option<Vec<ToolCall>>)
Parse fallback tool calls from response content and clean XML artifacts
Sourcepub fn as_ollama(&self) -> Option<&OllamaClient>
pub fn as_ollama(&self) -> Option<&OllamaClient>
Access underlying Ollama client for provider-specific operations
Sourcepub fn as_ollama_mut(&mut self) -> Option<&mut OllamaClient>
pub fn as_ollama_mut(&mut self) -> Option<&mut OllamaClient>
Access underlying Ollama client mutably for provider-specific operations
Sourcepub fn as_anthropic(&self) -> Option<&AnthropicClient>
pub fn as_anthropic(&self) -> Option<&AnthropicClient>
Access underlying Anthropic client for provider-specific operations
Sourcepub fn as_anthropic_mut(&mut self) -> Option<&mut AnthropicClient>
pub fn as_anthropic_mut(&mut self) -> Option<&mut AnthropicClient>
Access underlying Anthropic client mutably for provider-specific operations