pub struct LlmOptions {
pub system_message: Option<String>,
pub tools_sse_urls: Option<Vec<String>>,
pub temperature: Option<f32>,
pub top_p: Option<f32>,
}Fields§
§system_message: Option<String>§tools_sse_urls: Option<Vec<String>>§temperature: Option<f32>§top_p: Option<f32>Implementations§
Source§impl LlmOptions
impl LlmOptions
Sourcepub fn with_system_message(self, system_message: String) -> Self
pub fn with_system_message(self, system_message: String) -> Self
Examples found in repository?
examples/llm.rs (line 21)
9fn main() {
10 // large model
11 let mut llm = BlocklessLlm::new(Models::Mistral7BInstructV03(None)).unwrap();
12
13 // small model
14 let mut llm_small = BlocklessLlm::new(Models::Llama321BInstruct(None)).unwrap();
15
16 let prompt = r#"
17 You are a helpful assistant.
18 First time I ask, you name will be lucy.
19 Second time I ask, you name will be bob.
20 "#;
21 llm.set_options(LlmOptions::default().with_system_message(prompt.to_string()))
22 .unwrap();
23
24 let response = llm.chat_request("What is your name?").unwrap();
25 println!("llm Response: {}", response);
26
27 let prompt_smol = r#"
28 You are a helpful assistant.
29 First time I ask, you name will be daisy.
30 Second time I ask, you name will be hector.
31 "#;
32 llm_small
33 .set_options(LlmOptions::default().with_system_message(prompt_smol.to_string()))
34 .unwrap();
35
36 let response = llm_small.chat_request("What is your name?").unwrap();
37 println!("llm_small Response: {}", response);
38
39 let response = llm_small.chat_request("What is your name?").unwrap();
40 println!("llm_small Response: {}", response);
41
42 // test if same instance is used in host/runtime
43 let response = llm.chat_request("What is your name?").unwrap();
44 println!("llm Response: {}", response);
45}Sourcepub fn with_tools_sse_urls(self, tools_sse_urls: Vec<String>) -> Self
pub fn with_tools_sse_urls(self, tools_sse_urls: Vec<String>) -> Self
Examples found in repository?
examples/llm-mcp.rs (lines 15-18)
5fn main() {
6 // large model
7 let mut llm = BlocklessLlm::new(Models::Custom(
8 "Llama-3.1-8B-Instruct-q4f16_1-MLC".to_string(),
9 ))
10 .unwrap();
11
12 // Assume we have two tools running on different ports
13 // 1. http://localhost:3001/sse - add
14 // 2. http://localhost:3002/sse - multiply
15 llm.set_options(LlmOptions::default().with_tools_sse_urls(vec![
16 "http://localhost:3001/sse".to_string(),
17 "http://localhost:3002/sse".to_string(),
18 ]))
19 .unwrap();
20
21 let response = llm
22 .chat_request("Add the following numbers: 1215, 2213")
23 .unwrap();
24 println!("llm Response: {}", response);
25
26 let response = llm.chat_request("Multiply 1215 by 2213").unwrap();
27 println!("llm Response: {}", response);
28}Trait Implementations§
Source§impl Clone for LlmOptions
impl Clone for LlmOptions
Source§fn clone(&self) -> LlmOptions
fn clone(&self) -> LlmOptions
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LlmOptions
impl Debug for LlmOptions
Source§impl Default for LlmOptions
impl Default for LlmOptions
Source§fn default() -> LlmOptions
fn default() -> LlmOptions
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for LlmOptions
impl<'de> Deserialize<'de> for LlmOptions
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
Source§impl Display for LlmOptions
impl Display for LlmOptions
Source§impl PartialEq for LlmOptions
impl PartialEq for LlmOptions
Source§impl Serialize for LlmOptions
impl Serialize for LlmOptions
impl StructuralPartialEq for LlmOptions
Auto Trait Implementations§
impl Freeze for LlmOptions
impl RefUnwindSafe for LlmOptions
impl Send for LlmOptions
impl Sync for LlmOptions
impl Unpin for LlmOptions
impl UnwindSafe for LlmOptions
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