aboutsummaryrefslogtreecommitdiff
path: root/src/app/modules
diff options
context:
space:
mode:
authorOxbian <oxbian@mailbox.org>2025-05-18 12:19:33 -0400
committerOxbian <oxbian@mailbox.org>2025-05-18 12:19:33 -0400
commitea5fe19ad751fd6fa686e502a5cf7f26a78668e9 (patch)
treecd005f10acc256613ef5a9b88cf36733659ea57f /src/app/modules
parentfecb211130ec487c7c617d28419c6d0097f19783 (diff)
downloadNAI-main.tar.gz
NAI-main.zip
feat: refactor chat, resume into modules + color in UImain
Diffstat (limited to 'src/app/modules')
-rw-r--r--src/app/modules/chat.rs9
-rw-r--r--src/app/modules/code.rs0
-rw-r--r--src/app/modules/resume.rs9
-rw-r--r--src/app/modules/wikipedia.rs6
4 files changed, 21 insertions, 3 deletions
diff --git a/src/app/modules/chat.rs b/src/app/modules/chat.rs
new file mode 100644
index 0000000..ee00c98
--- /dev/null
+++ b/src/app/modules/chat.rs
@@ -0,0 +1,9 @@
+use crate::app::llm::{LLM, Message, MessageType};
+
+pub async fn ask_chat(mut messages: Vec<Message>) -> Result<String, Box<dyn std::error::Error>> {
+ let chat_llm = LLM::new("config/chat-LLM.json");
+ messages.push(Message::new(MessageType::USER, chat_llm.system_prompt.to_string()));
+
+ let result: String = chat_llm.ask(&messages).await?;
+ Ok(result)
+}
diff --git a/src/app/modules/code.rs b/src/app/modules/code.rs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/app/modules/code.rs
diff --git a/src/app/modules/resume.rs b/src/app/modules/resume.rs
new file mode 100644
index 0000000..057314c
--- /dev/null
+++ b/src/app/modules/resume.rs
@@ -0,0 +1,9 @@
+use crate::app::llm::{LLM, Message, MessageType};
+
+pub async fn resume_conv(mut messages: Vec<Message>) -> Result<String, Box<dyn std::error::Error>> {
+ let resume_llm = LLM::new("config/resume-LLM.json");
+ messages.push(Message::new(MessageType::USER, resume_llm.system_prompt.to_string()));
+
+ let result: String = resume_llm.ask(&messages).await?;
+ Ok(result)
+}
diff --git a/src/app/modules/wikipedia.rs b/src/app/modules/wikipedia.rs
index 5864df4..86177ae 100644
--- a/src/app/modules/wikipedia.rs
+++ b/src/app/modules/wikipedia.rs
@@ -76,7 +76,7 @@ async fn find_get_best_article(articles: Vec<String>, user_query: &String, best_
let messages = vec![
Message::new(MessageType::SYSTEM, best_llm.system_prompt.clone()),
- Message::new(MessageType::USER, format!("The user's query is: {}. Here are the headings:\n{}\n\nPlease select the most relevant heading. Output the heading **only** and nothing else.", user_query, articles_headings))];
+ Message::new(MessageType::USER, format!("The user's query is: {}. Here are the headings:\n{}\n\nPlease select the most relevant heading. Output the heading only and nothing else.", user_query, articles_headings))];
let best_article = best_llm.ask(&messages).await?;
// wiki query get article content & parse
@@ -98,9 +98,9 @@ fn extract_text_from_tags(html: &str) -> String {
// Trouver le premier groupe capturé non vide (parmi cap[1] à cap[4])
(1..=4)
.filter_map(|i| cap.get(i))
- .map(|m| m.as_str()) // &str
+ .map(|m| m.as_str())
.flat_map(|s| s.split_whitespace())
- .collect::<Vec<_>>() // Vec<&str>
+ .collect::<Vec<_>>()
})
.collect::<Vec<_>>() // collect words
.join(" "); // join with spaces
ArKa projects. All rights to me, and your next child right arm.