Skip to content

Commit

Permalink
Add chatbot crate
Browse files Browse the repository at this point in the history
  • Loading branch information
willcrichton committed Jul 20, 2024
1 parent f2087bb commit 8de28e1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions crates/chatbot/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "chatbot"
version = "0.1.0"
edition = "2021"

[dependencies]
tokio = { workspace = true }
21 changes: 21 additions & 0 deletions crates/chatbot/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use std::time::Duration;
use tokio::time::sleep;

/// Generates a random `usize`.
///
/// Warning: may take a few seconds!
pub async fn gen_random_number() -> usize {
sleep(Duration::from_secs(2)).await;
4
}

/// Generates a list of possible responses given the current chat.
///
/// Warning: may take a few seconds!
pub async fn query_chat(_messages: &[String]) -> Vec<String> {
sleep(Duration::from_secs(2)).await;
vec![
"And how does that make you feel?".to_string(),
"Interesting! Go on...".to_string(),
]
}

0 comments on commit 8de28e1

Please sign in to comment.