From a32e6bf45247cbce0d81365e92911abc35f37af1 Mon Sep 17 00:00:00 2001 From: Badr Date: Mon, 25 Nov 2024 11:32:13 +0100 Subject: [PATCH] bump dep + fix linting --- Cargo.lock | 40 ++++++++++++++++++++++++++-------------- Cargo.toml | 8 ++++---- src/chatgpt.rs | 4 ++-- src/llamacpp.rs | 3 +-- src/main.rs | 10 +++++----- 5 files changed, 38 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 14fde19..0930b5f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -52,9 +52,9 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "ansi-to-tui" -version = "6.0.0" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00c4af0bef1b514c9b6a32a773caf604c1390fa7913f4eaa23bfe76f251d6a42" +checksum = "67555e1f1ece39d737e28c8a017721287753af3f93225e4a445b29ccb0f5912c" dependencies = [ "nom", "ratatui", @@ -209,7 +209,7 @@ dependencies = [ "shell-words", "syntect", "thiserror", - "unicode-width", + "unicode-width 0.1.13", "walkdir", "wild", ] @@ -425,7 +425,7 @@ dependencies = [ "encode_unicode", "lazy_static", "libc", - "unicode-width", + "unicode-width 0.1.13", "windows-sys 0.52.0", ] @@ -1001,6 +1001,12 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "indoc" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" + [[package]] name = "instability" version = "0.3.2" @@ -1610,24 +1616,24 @@ dependencies = [ [[package]] name = "ratatui" -version = "0.28.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdef7f9be5c0122f890d58bdf4d964349ba6a6161f705907526d891efabba57d" +checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b" dependencies = [ "bitflags 2.6.0", "cassowary", "compact_str", "crossterm", + "indoc", "instability", "itertools", "lru", "paste", "strum", - "strum_macros", "time", "unicode-segmentation", "unicode-truncate", - "unicode-width", + "unicode-width 0.2.0", ] [[package]] @@ -2121,7 +2127,7 @@ dependencies = [ "tokio", "toml", "tui-textarea", - "unicode-width", + "unicode-width 0.2.0", ] [[package]] @@ -2350,13 +2356,13 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tui-textarea" -version = "0.6.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c07084342a575cea919eea996b9658a358c800b03d435df581c1d7c60e065a" +checksum = "0a5318dd619ed73c52a9417ad19046724effc1287fb75cdcc4eca1d6ac1acbae" dependencies = [ "crossterm", "ratatui", - "unicode-width", + "unicode-width 0.2.0", ] [[package]] @@ -2394,7 +2400,7 @@ checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf" dependencies = [ "itertools", "unicode-segmentation", - "unicode-width", + "unicode-width 0.1.13", ] [[package]] @@ -2403,6 +2409,12 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "unsafe-libyaml" version = "0.2.11" diff --git a/Cargo.toml b/Cargo.toml index 9dbe303..7c252fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ homepage = "https://github.com/pythops/tenere" repository = "https://github.com/pythops/tenere" [dependencies] -ansi-to-tui = "6" +ansi-to-tui = "7" arboard = "3" async-trait = "0.1" bat = "0.24" @@ -22,7 +22,7 @@ reqwest = { version = "0.12", default-features = false, features = [ "json", "rustls-tls", ] } -ratatui = { version = "0.28", features = ["all-widgets"] } +ratatui = { version = "0.29", features = ["all-widgets"] } regex = "1" serde = { version = "1", features = ["derive"] } serde_json = "1" @@ -30,8 +30,8 @@ strum = "0.26" strum_macros = "0.26" tokio = { version = "1", features = ["full"] } toml = { version = "0.8" } -tui-textarea = "0.6" -unicode-width = "0.1" +tui-textarea = "0.7" +unicode-width = "0.2" [profile.release] lto = "fat" diff --git a/src/chatgpt.rs b/src/chatgpt.rs index 74d4df9..cf27bb6 100644 --- a/src/chatgpt.rs +++ b/src/chatgpt.rs @@ -104,11 +104,11 @@ impl LLM for ChatGPT { match response.error_for_status() { Ok(mut res) => { sender.send(Event::LLMEvent(LLMAnswer::StartAnswer))?; + let re = Regex::new(r"data:\s(.*)")?; + while let Some(chunk) = res.chunk().await? { let chunk = std::str::from_utf8(&chunk)?; - let re = Regex::new(r"data:\s(.*)")?; - for captures in re.captures_iter(chunk) { if let Some(data_json) = captures.get(1) { if terminate_response_signal.load(Ordering::Relaxed) { diff --git a/src/llamacpp.rs b/src/llamacpp.rs index dcf3917..67962de 100644 --- a/src/llamacpp.rs +++ b/src/llamacpp.rs @@ -90,11 +90,10 @@ impl LLM for LLamacpp { match response.error_for_status() { Ok(mut res) => { sender.send(Event::LLMEvent(LLMAnswer::StartAnswer))?; + let re = Regex::new(r"data:\s(.*)")?; while let Some(chunk) = res.chunk().await? { let chunk = std::str::from_utf8(&chunk)?; - let re = Regex::new(r"data:\s(.*)")?; - for captures in re.captures_iter(chunk) { if let Some(data_json) = captures.get(1) { if terminate_response_signal.load(Ordering::Relaxed) { diff --git a/src/main.rs b/src/main.rs index 9e0b1ea..680f452 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,7 +14,7 @@ use tenere::llm::LLMModel; use std::sync::Arc; use tokio::sync::Mutex; -use clap::{crate_description, crate_version, Command, Arg}; +use clap::{crate_description, crate_version, Arg, Command}; #[tokio::main] async fn main() -> AppResult<()> { @@ -23,10 +23,10 @@ async fn main() -> AppResult<()> { .version(crate_version!()) .arg( Arg::new("config") - .short('c') - .long("config") - .help("Path to custom config file") - .value_name("FILE") + .short('c') + .long("config") + .help("Path to custom config file") + .value_name("FILE"), ) .get_matches();