pub struct ModelConfig {
pub name: String,
pub system_instruction: Option<String>,
pub temperature: f32,
pub top_p: f32,
pub top_k: Option<u32>,
pub max_tokens: Option<u32>,
pub thinking_mode: Option<bool>,
pub stop_sequences: Vec<String>,
}Expand description
Configuration for a language model
Fields§
§name: String§system_instruction: Option<String>§temperature: f32§top_p: f32§top_k: Option<u32>§max_tokens: Option<u32>§thinking_mode: Option<bool>§stop_sequences: Vec<String>Implementations§
Source§impl ModelConfig
impl ModelConfig
Sourcepub fn new<S: Into<String>>(name: S) -> Self
pub fn new<S: Into<String>>(name: S) -> Self
Create a new model configuration with the given model name
Examples found in repository?
examples/basic_usage.rs (line 88)
83async fn custom_configuration() -> Result<()> {
84 println!("⚙️ Example 3: Custom Configuration");
85 println!("===============================================================================");
86
87 // Create a custom model configuration
88 let config = ModelConfig::new("gemini-2.5-flash")
89 .with_system_instruction("You are a helpful Rust programming tutor. Always provide practical examples and explain concepts clearly.")
90 .with_temperature(0.7)?
91 .with_top_p(0.9)?;
92
93 // Create LLM with custom configuration
94 let llm =
95 LLM::new(ProviderSource::Gemini, "gemini-2.5-flash".to_string()).with_custom_config(config);
96
97 let response = llm
98 .prompt("Explain Rust's Result type and how to use it")
99 .await?;
100 println!("🤖 Response: {}\n", response.text);
101 Ok(())
102}Sourcepub fn with_system_instruction<S: Into<String>>(self, instruction: S) -> Self
pub fn with_system_instruction<S: Into<String>>(self, instruction: S) -> Self
Set the system instruction
Examples found in repository?
examples/basic_usage.rs (line 89)
83async fn custom_configuration() -> Result<()> {
84 println!("⚙️ Example 3: Custom Configuration");
85 println!("===============================================================================");
86
87 // Create a custom model configuration
88 let config = ModelConfig::new("gemini-2.5-flash")
89 .with_system_instruction("You are a helpful Rust programming tutor. Always provide practical examples and explain concepts clearly.")
90 .with_temperature(0.7)?
91 .with_top_p(0.9)?;
92
93 // Create LLM with custom configuration
94 let llm =
95 LLM::new(ProviderSource::Gemini, "gemini-2.5-flash".to_string()).with_custom_config(config);
96
97 let response = llm
98 .prompt("Explain Rust's Result type and how to use it")
99 .await?;
100 println!("🤖 Response: {}\n", response.text);
101 Ok(())
102}Sourcepub fn with_temperature(self, temperature: f32) -> Result<Self>
pub fn with_temperature(self, temperature: f32) -> Result<Self>
Set the temperature (0.0 to 2.0)
Examples found in repository?
examples/basic_usage.rs (line 90)
83async fn custom_configuration() -> Result<()> {
84 println!("⚙️ Example 3: Custom Configuration");
85 println!("===============================================================================");
86
87 // Create a custom model configuration
88 let config = ModelConfig::new("gemini-2.5-flash")
89 .with_system_instruction("You are a helpful Rust programming tutor. Always provide practical examples and explain concepts clearly.")
90 .with_temperature(0.7)?
91 .with_top_p(0.9)?;
92
93 // Create LLM with custom configuration
94 let llm =
95 LLM::new(ProviderSource::Gemini, "gemini-2.5-flash".to_string()).with_custom_config(config);
96
97 let response = llm
98 .prompt("Explain Rust's Result type and how to use it")
99 .await?;
100 println!("🤖 Response: {}\n", response.text);
101 Ok(())
102}Sourcepub fn with_top_p(self, top_p: f32) -> Result<Self>
pub fn with_top_p(self, top_p: f32) -> Result<Self>
Set the top_p (0.0 to 1.0)
Examples found in repository?
examples/basic_usage.rs (line 91)
83async fn custom_configuration() -> Result<()> {
84 println!("⚙️ Example 3: Custom Configuration");
85 println!("===============================================================================");
86
87 // Create a custom model configuration
88 let config = ModelConfig::new("gemini-2.5-flash")
89 .with_system_instruction("You are a helpful Rust programming tutor. Always provide practical examples and explain concepts clearly.")
90 .with_temperature(0.7)?
91 .with_top_p(0.9)?;
92
93 // Create LLM with custom configuration
94 let llm =
95 LLM::new(ProviderSource::Gemini, "gemini-2.5-flash".to_string()).with_custom_config(config);
96
97 let response = llm
98 .prompt("Explain Rust's Result type and how to use it")
99 .await?;
100 println!("🤖 Response: {}\n", response.text);
101 Ok(())
102}Sourcepub fn with_top_k(self, top_k: u32) -> Self
pub fn with_top_k(self, top_k: u32) -> Self
Set the top_k
Sourcepub fn with_max_tokens(self, max_tokens: u32) -> Self
pub fn with_max_tokens(self, max_tokens: u32) -> Self
Set the maximum number of tokens to generate
Sourcepub fn with_thinking_mode(self, thinking_mode: bool) -> Self
pub fn with_thinking_mode(self, thinking_mode: bool) -> Self
Enable or disable thinking mode
Sourcepub fn with_stop_sequence<S: Into<String>>(self, stop_sequence: S) -> Self
pub fn with_stop_sequence<S: Into<String>>(self, stop_sequence: S) -> Self
Add a stop sequence
Sourcepub fn with_stop_sequences<I, S>(self, stop_sequences: I) -> Self
pub fn with_stop_sequences<I, S>(self, stop_sequences: I) -> Self
Set multiple stop sequences
Sourcepub fn conservative<S: Into<String>>(name: S) -> Self
pub fn conservative<S: Into<String>>(name: S) -> Self
Create a conservative configuration (lower temperature, more focused)
Trait Implementations§
Source§impl Clone for ModelConfig
impl Clone for ModelConfig
Source§fn clone(&self) -> ModelConfig
fn clone(&self) -> ModelConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 ModelConfig
impl Debug for ModelConfig
Source§impl Default for ModelConfig
impl Default for ModelConfig
Source§impl<'de> Deserialize<'de> for ModelConfig
impl<'de> Deserialize<'de> for ModelConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ModelConfig
impl RefUnwindSafe for ModelConfig
impl Send for ModelConfig
impl Sync for ModelConfig
impl Unpin for ModelConfig
impl UnsafeUnpin for ModelConfig
impl UnwindSafe for ModelConfig
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