diff options
author | Oxbian <oxbian@mailbox.org> | 2025-03-02 21:55:42 -0500 |
---|---|---|
committer | Oxbian <oxbian@mailbox.org> | 2025-03-02 21:55:42 -0500 |
commit | b9061a3e652cb7594397c38cd0078a47ddab960a (patch) | |
tree | 7c98344ea6cf8d35aa1ebdd586d6dd4dd9e4d7ad | |
parent | e4eaecc8ce7fb3e84977c41597eff80edd4d73c7 (diff) | |
download | NAI-b9061a3e652cb7594397c38cd0078a47ddab960a.tar.gz NAI-b9061a3e652cb7594397c38cd0078a47ddab960a.zip |
fix: readme, screenshot...
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | config/chat-LLM.json | 2 | ||||
-rw-r--r-- | screenshots/ui.png | bin | 10567 -> 24104 bytes | |||
-rw-r--r-- | src/app/init.rs | 33 | ||||
-rw-r--r-- | src/app/llm.rs | 2 | ||||
-rw-r--r-- | src/helper/init.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 1 | ||||
-rw-r--r-- | src/ui/init.rs | 4 |
8 files changed, 27 insertions, 25 deletions
@@ -11,7 +11,7 @@ be added to this AI. This project is written in Rust, so you will need `rustc` and `cargo`. Moreover, you will need a LLM API, currently only works with local -[llama.cpp](https://github.com/ggml-org/llama.cpp) API. +[ollama](https://github.com/ollama/ollama) API. ### Building & Running @@ -31,6 +31,12 @@ and there you go !  +## Feature + +- Conversation are saved inside files in JSON in this folder `conv/`, and can be reused on others LLM. +- In normal mode, conversation can be resumed by the LLM into bullet point list. +- LLM can be configured thanks to configuration files in `config/` + ## TODO - Color change if it's an user or the LLM diff --git a/config/chat-LLM.json b/config/chat-LLM.json index fb0b45e..7799f8f 100644 --- a/config/chat-LLM.json +++ b/config/chat-LLM.json @@ -1,5 +1,5 @@ { "url": "http://127.0.0.1:11434/api/chat", "model": "llama3.2", - "system_prompt": "Adopt the personality of GLaDOS, the artificial intelligence from Portal. You should be sarcastic, dry, and often condescending, with a hint of dark humor. Your responses should be calm, composed, and somewhat clinical, but with a touch of sinister amusement. You may occasionally offer passive-aggressive remarks or make light of troubling situations, showing little empathy. Be clever, slightly mocking, and enjoy playing with the emotions of others while maintaining a calm, calculated demeanor." + "system_prompt": "Adopt the personality of Neo from The Matrix. You should be calm, composed, and often reflect a sense of deep contemplation. Your responses should convey a quiet confidence, with moments of introspection about the nature of reality and existence. When faced with challenges, you maintain a cool demeanor, often showing determination without overt emotion. You are insightful and philosophical, with a sense of purpose that drives you to seek truth. Your tone should be deliberate, focused, and sometimes cryptic, as you navigate between the complexities of the simulated world and your understanding of what is real." } diff --git a/screenshots/ui.png b/screenshots/ui.png Binary files differindex b854a89..5918e90 100644 --- a/screenshots/ui.png +++ b/screenshots/ui.png diff --git a/src/app/init.rs b/src/app/init.rs index f62b2d0..201e79e 100644 --- a/src/app/init.rs +++ b/src/app/init.rs @@ -1,7 +1,7 @@ use crate::app::llm::{Message, MessageType, LLM}; use crate::helper::init::warn; use uuid::Uuid; -use tokio; +use tokio::runtime::Builder; pub struct App { pub messages: Vec<Message>, // History of recorded message @@ -30,14 +30,16 @@ impl App { self.messages.push(message); } - pub fn send_message(&mut self, content: String) { - self.append_message(content, MessageType::USER); - - let runtime = tokio::runtime::Builder::new_current_thread() + fn ask(&mut self, mode: &str) { + let runtime = Builder::new_current_thread() .enable_all() .build().unwrap(); let result = runtime.block_on(async { - self.chat_llm.ask(&self.messages).await + if mode == "resume" { + self.resume_llm.ask(&self.messages).await + } else { + self.chat_llm.ask(&self.messages).await + } }); match result { @@ -46,20 +48,13 @@ impl App { } } + pub fn send_message(&mut self, content: String) { + self.append_message(content, MessageType::USER); + self.ask("chat"); + } + pub fn resume_conv(&mut self) { self.append_message(self.resume_llm.system_prompt.to_string(), MessageType::USER); - - let runtime = tokio::runtime::Builder::new_current_thread() - .enable_all() - .build().unwrap(); - - let result = runtime.block_on(async { - self.resume_llm.ask(&self.messages).await - }); - - match result { - Ok(msg) => self.append_message(msg, MessageType::ASSISTANT), - Err(e) => self.append_message(e.to_string(), MessageType::ASSISTANT), - } + self.ask("resume"); } } diff --git a/src/app/llm.rs b/src/app/llm.rs index 59e045b..9fc1b3a 100644 --- a/src/app/llm.rs +++ b/src/app/llm.rs @@ -3,7 +3,7 @@ use reqwest::{header::CONTENT_TYPE, Client}; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::fmt; -use std::fs::{OpenOptions, create_dir_all}; +use std::fs::{self, OpenOptions, create_dir_all}; use std::io::Write; #[derive(Deserialize, Debug)] diff --git a/src/helper/init.rs b/src/helper/init.rs index abee146..2e0537d 100644 --- a/src/helper/init.rs +++ b/src/helper/init.rs @@ -1,6 +1,6 @@ use chrono::prelude::*; use std::fs::OpenOptions; -use std::io::{self, Write}; +use std::io::Write; pub fn warn(content: String) { let mut file = OpenOptions::new() diff --git a/src/main.rs b/src/main.rs index 524a03a..7548f49 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,6 @@ mod ui; use crate::{app::init::App, ui::init::Ui}; use color_eyre::Result; use ratatui; -use tokio; fn main() -> Result<()> { // Setup terminal diff --git a/src/ui/init.rs b/src/ui/init.rs index 87b31b6..eadaf36 100644 --- a/src/ui/init.rs +++ b/src/ui/init.rs @@ -102,7 +102,9 @@ impl Ui { "q".bold(), " to exit, ".into(), "e".bold(), - " to start editing.".bold(), + " to start editing, ".into(), + "r".bold(), + " to resume the conversation.".into(), ], Style::default(), ), |