From 7f2210dbcab017ee30e8f95771e68494b4860c59 Mon Sep 17 00:00:00 2001 From: sigoden Date: Wed, 1 Nov 2023 10:28:54 +0800 Subject: 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 --- src/config/model_info.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/config/model_info.rs (limited to 'src/config/model_info.rs') diff --git a/src/config/model_info.rs b/src/config/model_info.rs new file mode 100644 index 0000000..1f8d6f0 --- /dev/null +++ b/src/config/model_info.rs @@ -0,0 +1,27 @@ +#[derive(Debug, Clone)] +pub struct ModelInfo { + pub client: String, + pub name: String, + pub max_tokens: Option, + pub index: usize, +} + +impl Default for ModelInfo { + fn default() -> Self { + ModelInfo::new("", "", None, 0) + } +} + +impl ModelInfo { + pub fn new(client: &str, name: &str, max_tokens: Option, index: usize) -> Self { + Self { + client: client.into(), + name: name.into(), + max_tokens, + index, + } + } + pub fn stringify(&self) -> String { + format!("{}:{}", self.client, self.name) + } +} -- cgit v1.2.3