summaryrefslogtreecommitdiffstats
path: root/src/utils/mod.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-11-01 10:28:54 +0800
committerGitHub <noreply@github.com>2023-11-01 10:28:54 +0800
commit7f2210dbcab017ee30e8f95771e68494b4860c59 (patch)
tree7a0c7bdc8f6930e262bf8cfdc8ffbd57aa843e40 /src/utils/mod.rs
parent64202758ec8693dd18951c554728bb5c6b7e5eeb (diff)
downloadaichat-7f2210dbcab017ee30e8f95771e68494b4860c59.tar.gz
refactor: clients/* and config.rs (#193)
- add register_clients macro to make it easier to add a new client - no create_client_config, just add const PROMPTS - move ModelInfo from clients/ to config/ - model's max_tokens are optional - improve code quanity on config/mod.rs - add/use macro config_get_fn
Diffstat (limited to 'src/utils/mod.rs')
-rw-r--r--src/utils/mod.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index 9e999d4..ab922e3 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -1,6 +1,8 @@
+mod prompt_input;
mod split_line;
mod tiktoken;
+pub use self::prompt_input::*;
pub use self::split_line::*;
pub use self::tiktoken::cl100k_base_singleton;
@@ -63,3 +65,11 @@ pub fn light_theme_from_colorfgbg(colorfgbg: &str) -> Option<bool> {
let light = v > 128.0;
Some(light)
}
+
+pub fn init_tokio_runtime() -> anyhow::Result<tokio::runtime::Runtime> {
+ use anyhow::Context;
+ tokio::runtime::Builder::new_current_thread()
+ .enable_all()
+ .build()
+ .with_context(|| "Failed to init tokio")
+}