use artificial_core::{
generic::{GenericMessage, GenericRole},
template::IntoPrompt,
};
use artificial_prompt::builder::PromptBuilder;
use chrono::Datelike as _;
#[derive(Default)]
pub struct CurrentDateFragment;
impl CurrentDateFragment {
pub fn new() -> Self {
Self
}
}
impl IntoPrompt for CurrentDateFragment {
type Message = GenericMessage;
fn into_prompt(self) -> Vec<Self::Message> {
let now = chrono::Utc::now();
let builder = PromptBuilder::new()
.add_key_value("Current ISO Timestamp", now.to_rfc3339())
.add_key_value("Current Date and Time", now.format("%Y-%m-%d %H:%M:%S"))
.add_key_value("Current Weekday", now.weekday().to_string())
.add_key_value("Timezone", "UTC")
.add_line(format!(
"You are currently reasoning in the context of {}, {}, {}, {}",
now.weekday(),
now.format("%Y-%m-%d"),
now.format("%H:%M:%S"),
now.timezone()
))
.add_blank_line()
.add_line(
"Use this information when interpreting natural language \
expressions like 'next week' or 'in 3 days'.",
);
vec![GenericMessage::new(builder.finalize(), GenericRole::System)]
}
}