From 5535ea2656019160fa36a5e6efe475de6f1e1986 Mon Sep 17 00:00:00 2001 From: Will Crichton Date: Tue, 13 Aug 2024 14:13:39 -0700 Subject: [PATCH] Include most recent message in response --- crates/chatbot/src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/chatbot/src/lib.rs b/crates/chatbot/src/lib.rs index b3ab021..9506250 100644 --- a/crates/chatbot/src/lib.rs +++ b/crates/chatbot/src/lib.rs @@ -21,10 +21,11 @@ pub async fn gen_random_number() -> usize { /// Generates a list of possible responses given the current chat. /// /// Warning: may take a few seconds! -pub async fn query_chat(_messages: &[String]) -> Vec { +pub async fn query_chat(messages: &[String]) -> Vec { tokio::time::sleep(Duration::from_secs(2)).await; + let most_recent = messages.last().unwrap(); vec![ - "And how does that make you feel?".to_string(), - "Interesting! Go on...".to_string(), + format!("\"{most_recent}\"? And how does that make you feel?"), + format!("\"{most_recent}\"! Interesting! Go on..."), ] }