pub struct ChatMessage {
pub role: Role,
pub content: String,
pub name: Option<String>,
pub tool_calls: Option<Vec<ToolCall>>,
pub tool_call_id: Option<String>,
}Fields§
§role: Role§content: String§name: Option<String>§tool_calls: Option<Vec<ToolCall>>§tool_call_id: Option<String>Implementations§
Source§impl ChatMessage
impl ChatMessage
Sourcepub fn system(content: impl Into<String>) -> Self
pub fn system(content: impl Into<String>) -> Self
Examples found in repository?
examples/direct_llm_usage.rs (line 67)
51async fn simple_call() -> helios_engine::Result<()> {
52 // Create configuration
53 let llm_config = LLMConfig {
54 model_name: "gpt-3.5-turbo".to_string(),
55 base_url: "https://api.openai.com/v1".to_string(),
56 api_key: std::env::var("OPENAI_API_KEY")
57 .unwrap_or_else(|_| "your-api-key-here".to_string()),
58 temperature: 0.7,
59 max_tokens: 2048,
60 };
61
62 // Create client
63 let client = LLMClient::new(llm_config);
64
65 // Prepare messages
66 let messages = vec![
67 ChatMessage::system("You are a helpful assistant that gives concise answers."),
68 ChatMessage::user("What is the capital of France? Answer in one sentence."),
69 ];
70
71 // Make the call
72 println!("Sending request...");
73 match client.chat(messages, None).await {
74 Ok(response) => {
75 println!("✓ Response: {}", response.content);
76 }
77 Err(e) => {
78 println!("✗ Error: {}", e);
79 println!(" (Make sure to set OPENAI_API_KEY environment variable)");
80 }
81 }
82
83 Ok(())
84}Sourcepub fn user(content: impl Into<String>) -> Self
pub fn user(content: impl Into<String>) -> Self
Examples found in repository?
examples/direct_llm_usage.rs (line 68)
51async fn simple_call() -> helios_engine::Result<()> {
52 // Create configuration
53 let llm_config = LLMConfig {
54 model_name: "gpt-3.5-turbo".to_string(),
55 base_url: "https://api.openai.com/v1".to_string(),
56 api_key: std::env::var("OPENAI_API_KEY")
57 .unwrap_or_else(|_| "your-api-key-here".to_string()),
58 temperature: 0.7,
59 max_tokens: 2048,
60 };
61
62 // Create client
63 let client = LLMClient::new(llm_config);
64
65 // Prepare messages
66 let messages = vec![
67 ChatMessage::system("You are a helpful assistant that gives concise answers."),
68 ChatMessage::user("What is the capital of France? Answer in one sentence."),
69 ];
70
71 // Make the call
72 println!("Sending request...");
73 match client.chat(messages, None).await {
74 Ok(response) => {
75 println!("✓ Response: {}", response.content);
76 }
77 Err(e) => {
78 println!("✗ Error: {}", e);
79 println!(" (Make sure to set OPENAI_API_KEY environment variable)");
80 }
81 }
82
83 Ok(())
84}pub fn assistant(content: impl Into<String>) -> Self
pub fn tool(content: impl Into<String>, tool_call_id: impl Into<String>) -> Self
Trait Implementations§
Source§impl Clone for ChatMessage
impl Clone for ChatMessage
Source§fn clone(&self) -> ChatMessage
fn clone(&self) -> ChatMessage
Returns a duplicate of the value. Read more
1.0.0 · 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 ChatMessage
impl Debug for ChatMessage
Source§impl<'de> Deserialize<'de> for ChatMessage
impl<'de> Deserialize<'de> for ChatMessage
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 ChatMessage
impl RefUnwindSafe for ChatMessage
impl Send for ChatMessage
impl Sync for ChatMessage
impl Unpin for ChatMessage
impl UnwindSafe for ChatMessage
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