summaryrefslogtreecommitdiffstats
path: root/src/repl
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-03-09 15:30:39 +0800
committerGitHub <noreply@github.com>2023-03-09 15:30:39 +0800
commit05d20f207fedf03c2a564438a0d44a2d85d4ed2d (patch)
treeeb7c9ae402632c5827cd4faa323b138510716f22 /src/repl
parentc7eb261abc32ac4d6fc5364244a6246bcdc462d9 (diff)
downloadaichat-05d20f207fedf03c2a564438a0d44a2d85d4ed2d.tar.gz
feat: add remain tokens indicator and max tokens guard (#50)
Diffstat (limited to 'src/repl')
-rw-r--r--src/repl/handler.rs2
-rw-r--r--src/repl/init.rs7
-rw-r--r--src/repl/mod.rs2
3 files changed, 8 insertions, 3 deletions
diff --git a/src/repl/handler.rs b/src/repl/handler.rs
index b5651c3..30a75c5 100644
--- a/src/repl/handler.rs
+++ b/src/repl/handler.rs
@@ -63,7 +63,7 @@ impl ReplCmdHandler {
wg.wait();
let buffer = ret?;
self.config.lock().save_message(&input, &buffer)?;
- self.config.lock().record_conversation(&input, &buffer)?;
+ self.config.lock().save_conversation(&input, &buffer)?;
*self.reply.borrow_mut() = buffer;
}
ReplCmd::SetRole(name) => {
diff --git a/src/repl/init.rs b/src/repl/init.rs
index a14265c..faafd9d 100644
--- a/src/repl/init.rs
+++ b/src/repl/init.rs
@@ -135,7 +135,12 @@ impl Prompt for ReplPrompt {
}
fn render_prompt_right(&self) -> Cow<str> {
- Cow::Borrowed("")
+ let config = self.0.lock();
+ if let Some(conversation) = config.conversation.as_ref() {
+ conversation.reamind_tokens().to_string().into()
+ } else {
+ Cow::Borrowed("")
+ }
}
fn render_prompt_indicator(&self, _prompt_mode: reedline::PromptEditMode) -> Cow<str> {
diff --git a/src/repl/mod.rs b/src/repl/mod.rs
index 9407bcf..661be75 100644
--- a/src/repl/mod.rs
+++ b/src/repl/mod.rs
@@ -22,7 +22,7 @@ pub const REPL_COMMANDS: [(&str, &str, bool); 12] = [
(".role", "Select a role", false),
(".clear role", "Clear the currently selected role", false),
(".conversation", "Start a conversation.", false),
- (".clear conversation", "End the conversation.", false),
+ (".clear conversation", "End current conversation.", false),
(".history", "Print the history", false),
(".clear history", "Clear the history", false),
(".editor", "Enter editor mode for multiline input", true),