cognis-core 0.2.0

Core traits and types for the Cognis LLM framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use serde::{Deserialize, Serialize};

use super::base::{BaseMessageFields, MessageContent};

/// A legacy function message (deprecated in favor of ToolMessage).
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct FunctionMessage {
    #[serde(flatten)]
    pub base: BaseMessageFields,
}

impl FunctionMessage {
    pub fn new(name: impl Into<String>, content: impl Into<String>) -> Self {
        Self {
            base: BaseMessageFields::new(MessageContent::Text(content.into())).with_name(name),
        }
    }
}