|
1 | 1 | use rand::{rngs::SmallRng, Rng, SeedableRng}; |
2 | | -use std::{cell::RefCell, time::Duration}; |
| 2 | +use std::{cell::RefCell, path::PathBuf, time::Duration}; |
3 | 3 |
|
4 | 4 | thread_local! { |
5 | 5 | static RNG: RefCell<SmallRng> = RefCell::new(SmallRng::from_entropy()); |
@@ -33,17 +33,26 @@ impl Chatbot { |
33 | 33 | } |
34 | 34 | } |
35 | 35 |
|
| 36 | + pub fn retrieval_documents(&self, _messages: &[String]) -> Vec<PathBuf> { |
| 37 | + vec![ |
| 38 | + PathBuf::from("data/doc1.txt"), |
| 39 | + PathBuf::from("data/doc2.txt"), |
| 40 | + ] |
| 41 | + } |
| 42 | + |
36 | 43 | /// Generates a list of possible responses given the current chat. |
37 | 44 | /// |
38 | 45 | /// Warning: may take a few seconds! |
39 | | - pub async fn query_chat(&mut self, messages: &[String]) -> Vec<String> { |
| 46 | + pub async fn query_chat(&mut self, messages: &[String], docs: &[String]) -> Vec<String> { |
40 | 47 | std::thread::sleep(Duration::from_secs(2)); |
41 | 48 | let most_recent = messages.last().unwrap(); |
42 | 49 | let emoji = &self.emojis[self.emoji_counter]; |
43 | 50 | self.emoji_counter = (self.emoji_counter + 1) % self.emojis.len(); |
44 | 51 | vec![ |
45 | 52 | format!("\"{most_recent}\"? And how does that make you feel? {emoji}",), |
46 | 53 | format!("\"{most_recent}\"! Interesting! Go on... {emoji}"), |
| 54 | + format!("Have you considered: {}", docs.first().unwrap()), |
| 55 | + format!("I might recommend: {}", docs.last().unwrap()), |
47 | 56 | ] |
48 | 57 | } |
49 | 58 | } |
0 commit comments